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

sledujuserialyresolver.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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,urllib2,traceback
  23. __name__ = 'zkouknito.cz'
  24. def supports(url):
  25. return not _regex(url) == None
  26. def resolve(url):
  27. m = _regex(url)
  28. if not m == None:
  29. data = util.request(url)
  30. if data.find('jwplayer(\'mediaplayer') > 0:
  31. video = re.search('\'file\'\: \'(?P<url>.+?[flv|mp4])\'',data)
  32. if video:
  33. item = {}
  34. item['url'] = video.group('url')
  35. subs = re.search('\'file\'\: \'(?P<url>.+?srt)',data)
  36. if subs:
  37. item['subs'] = _furl(subs.group('url'))
  38. print item
  39. return [item]
  40. def _furl(url):
  41. if url.startswith('http'):
  42. return url
  43. url = url.lstrip('./')
  44. return 'http://www.sledujuserialy.cz/'+url
  45. def _regex(url):
  46. return re.search('(www\.)?sledujuserialy.cz/(.+?)',url,re.IGNORECASE | re.DOTALL)