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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # /*
  4. # * Copyright (C) 2015 Lubomir Kucera
  5. # *
  6. # *
  7. # * This Program is free software; you can redistribute it and/or modify
  8. # * it under the terms of the GNU General Public License as published by
  9. # * the Free Software Foundation; either version 2, or (at your option)
  10. # * any later version.
  11. # *
  12. # * This Program is distributed in the hope that it will be useful,
  13. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # * GNU General Public License for more details.
  16. # *
  17. # * You should have received a copy of the GNU General Public License
  18. # * along with this program; see the file COPYING. If not, write to
  19. # * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20. # * http://www.gnu.org/copyleft/gpl.html
  21. # *
  22. # */
  23. import re
  24. import util
  25. import urllib
  26. import pickle
  27. import demjson
  28. __author__ = 'Jose Riha'
  29. __name__ = 'myviru'
  30. UA = urllib.quote(util.UA)
  31. def supports(url):
  32. return re.search(r'http://myvi.ru/player/flash', url) is not None
  33. def resolve(url):
  34. cookies = {}
  35. result = []
  36. util.init_urllib(cookies)
  37. id = re.search(r'.*player/flash/(?P<url>.+)', url).group('url')
  38. r = util.request('http://myvi.ru/player/api/Video/Get/%s?sig' % id)
  39. jsondata = demjson.decode(r)
  40. playlist = jsondata['sprutoData']['playlist'][0]
  41. uuid = pickle.loads(util._cookie_jar.dump())[
  42. '.myvi.ru']['/']['UniversalUserID']
  43. for f in playlist['video']:
  44. streamurl = f['url']
  45. streamurl += '|Cookie=UniversalUserID%3D' + urllib.quote(uuid.value)
  46. streamurl += '&User-Agent=' + UA
  47. result.append({'url': streamurl})
  48. if result:
  49. return result
  50. else:
  51. return None