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

videonetresolver.py 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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__ = '24video'
  24. def supports(url):
  25. return not _regex(url) == None
  26. def latin2text(word):
  27. dict_hex = {'á' : 'á',
  28. 'č': 'č',
  29. 'ď': 'ď',
  30. 'é' : 'é',
  31. 'ě': 'ě',
  32. 'í' : 'í',
  33. 'ñ' : 'ñ',
  34. 'ó' : 'ó',
  35. 'ř': 'ř',
  36. 'š': 'š',
  37. 'ť': 'ť',
  38. 'ú' : 'ú',
  39. 'ü' : 'ü',
  40. 'ý' : 'ý',
  41. 'ž': 'ž',
  42. }
  43. for key in dict_hex.keys():
  44. word = word.replace(key,dict_hex[key])
  45. return word
  46. # returns the steam url
  47. def url(url):
  48. m = _regex(url)
  49. if not m == None:
  50. data = latin2text(util.request('%s%s%s?mode=play' % (m.group('url') ,m.group('html'),m.group('id'))))
  51. f = re.search('<videos><video url=\'(.+?)[^ ] rating',data,re.IGNORECASE | re.DOTALL)
  52. if f:
  53. return [f.group(1)]
  54. def resolve(u):
  55. stream = url(u)
  56. if stream:
  57. return [{'name':__name__,'quality':'480p','url':stream[0],'surl':u}]
  58. def _regex(url):
  59. return re.search('id=(?P<id>.+?)&idHtml=(?P<html>.+?)&.*rootUrl=(?P<url>.+?)&',url,re.IGNORECASE | re.DOTALL)