Enigma2 plugin to to play various online streams (mostly Latvian).

streamcloudresolver.py 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- coding: UTF-8 -*-
  2. #/*
  3. # * Copyright (C) 2011 Libor Zoubek
  4. # *
  5. # *
  6. # * This Program is free software; you can redistribute it and/or modify
  7. # * it under the terms of the GNU General Public License as published by
  8. # * the Free Software Foundation; either version 2, or (at your option)
  9. # * any later version.
  10. # *
  11. # * This Program is distributed in the hope that it will be useful,
  12. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # * GNU General Public License for more details.
  15. # *
  16. # * You should have received a copy of the GNU General Public License
  17. # * along with this program; see the file COPYING. If not, write to
  18. # * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19. # * http://www.gnu.org/copyleft/gpl.html
  20. # *
  21. # */
  22. import re,util
  23. __name__ = 'streamcloud'
  24. def supports(url):
  25. return not _regex(url) == None
  26. # returns the steam url
  27. def url(url):
  28. m = _regex(url)
  29. if not m == None:
  30. data = util.substr(util.request(url),'class=\"proform\"','</form>')
  31. #print data
  32. form_values = {}
  33. pattern = '<input.+?name="(?P<name>.*?)".+?value="(?P<value>.*?)"'
  34. for n in re.finditer(pattern,data,re.IGNORECASE | re.DOTALL ):
  35. form_values[n.group('name')] = n.group('value')
  36. #print form_values
  37. try:
  38. #time.sleep(10)
  39. resp = util.post(url,form_values)
  40. except:
  41. util.error('streamcloud: got http error fetching %s' % (url))
  42. return False
  43. r = re.search('file: "(.+?)",', resp)
  44. if r:
  45. return [r.group(1)]
  46. def resolve(u):
  47. stream = url(u)
  48. if stream:
  49. return [{'name':__name__,'quality':'640p','url':stream[0],'surl':u}]
  50. def _regex(url):
  51. return re.search('http://(www.)?streamcloud.eu/[0-9A-Za-z]+',url,re.IGNORECASE | re.DOTALL)