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

flashxresolver.py 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # -*- coding: UTF-8 -*-
  2. # *
  3. # *
  4. # * This Program is free software; you can redistribute it and/or modify
  5. # * it under the terms of the GNU General Public License as published by
  6. # * the Free Software Foundation; either version 2, or (at your option)
  7. # * any later version.
  8. # *
  9. # * This Program is distributed in the hope that it will be useful,
  10. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # * GNU General Public License for more details.
  13. # *
  14. # * You should have received a copy of the GNU General Public License
  15. # * along with this program; see the file COPYING. If not, write to
  16. # * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. # * http://www.gnu.org/copyleft/gpl.html
  18. # *
  19. import re
  20. from xml.etree import ElementTree
  21. import util
  22. from copy import deepcopy
  23. __name__ = 'flashx'
  24. def supports(url):
  25. return re.search(r'flashx\.tv/embed\-[^\.]+\.html', url) is not None
  26. def resolve(url):
  27. data = util.extract_jwplayer_setup(util.request(url))
  28. if data and 'sources' in data:
  29. result = []
  30. for source in data['sources']:
  31. items = []
  32. if source['file'].endswith('.smil'):
  33. tree = ElementTree.fromstring(util.request(source['file']))
  34. base_path = tree.find('./head/meta').get('base')
  35. for video in tree.findall('./body/switch/video'):
  36. items.append({
  37. 'url': '%s playpath=%s pageUrl=%s swfUrl=%s swfVfy=true' %
  38. (base_path, video.get('src'), url,
  39. 'http://static.flashx.tv/player6/jwplayer.flash.swf'),
  40. 'quality': video.get('height') + 'p'
  41. })
  42. else:
  43. items.append({'url': source['file']})
  44. if len(data['tracks']) > 0:
  45. for item in items:
  46. for track in data['tracks']:
  47. new_item = deepcopy(item)
  48. new_item['subs'] = track['file']
  49. new_item['lang'] = ' %s subtitles' % track['label']
  50. result.append(new_item)
  51. else:
  52. result += items
  53. return result
  54. return None