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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # -*- coding: UTF-8 -*-
  2. # /*
  3. # * Copyright (C) 2015 Lubomir Kucera
  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,os,sys
  23. import json
  24. try:
  25. import util
  26. except:
  27. pp = os.path.dirname(os.path.abspath(__file__))
  28. sys.path.insert(0,os.sep.join(pp.split(os.sep)[:-1]))
  29. import util
  30. import urllib2
  31. import requests
  32. #from aadecode import AADecoder
  33. __author__ = 'Jose Riha/Lubomir Kucera'
  34. __name__ = 'openload3'
  35. def supports(url):
  36. return re.search(r'openload\.\w+/embed/.+', url) is not None
  37. #INFO_URL = API_BASE_URL + '/streaming/info'
  38. def resolve(url):
  39. HTTP_HEADER = {
  40. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0',
  41. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  42. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  43. 'Accept-Encoding': 'none',
  44. 'Accept-Language': 'en-US,en;q=0.8',
  45. 'Referer': url} # 'Connection': 'keep-alive'
  46. stream = util.item()
  47. m = re.search('https*://openload\.\w+/embed/([^/]+)', url)
  48. if not m:
  49. return stream
  50. vid=m.group(1)
  51. url2 = "https://api.openload.co/1/streaming/get?file="+vid
  52. r = requests.get(url2,headers=HTTP_HEADER)
  53. try:
  54. js = json.loads(r.content)
  55. except:
  56. return stream
  57. if js["status"] <>200:
  58. raise Exception(js["msg"])
  59. res = js["result"]
  60. stream["url"] = res["url"]
  61. stream["name"]= res["url"]
  62. ### Retrieve subtitles ####
  63. html = requests.get(url, headers=HTTP_HEADER).content
  64. m = re.search('<track kind="captions" src="([^"]+)" srclang="([^"]+)" label="([^"]+)"', html)
  65. if m:
  66. stream["subs"] = m.group(1)
  67. stream["lang"] = m.group(2)
  68. return [stream]
  69. if __name__ == "__main__":
  70. from subprocess import call
  71. #url = "http://hqq.tv/player/embed_player.php?vid=235238210241210222228241233208212245&autoplay=no"
  72. #url = "http://hqq.tv/player/embed_player.php?vid=243221241234244238208213206212211231&autoplay=no"
  73. url = "http://hqq.tv/player/embed_player.php?vid=208231211231207221227243206206221244&autoplay=no"
  74. #url = "https://openload.co/embed/TMthIdpy4PI/"
  75. #url = "https://www.youtube.com/watch?v=Tx1K51_F99o"
  76. #url = "https://www.youtube.com/watch?v=8BkcX7O1890"
  77. #url = "https://www.youtube.com/watch?v=Se07R8SYsg0"
  78. #url = "https://kinostok.tv/embed/731f3437e3c53104dd56d04039a0b15a"
  79. #url = "http://vk.com/video_ext.php?oid=246066565&id=169244575&hash=d430ab0e76c9f7a1&hd=3"
  80. #url ="https://openload.co/embed/rPMXJYPTkw4/"
  81. #url = "https://openload.co/embed/bE7WfZ-vz_A/"
  82. #url = "https://openload.co/embed/bE7WfZ/"
  83. #url = "https://openload.co/embed/OuskaKyC2GU/"
  84. url = "http://hqq.tv/player/embed_player.php?vid=235238210241210222228241233208212245&autoplay=no"
  85. url = "https://openload.co/embed/rmNcP-0QopE/"
  86. url = "https://openload.co/embed/oQLXcU1ITAY/"
  87. streams = resolve(url)
  88. if not streams:
  89. print "No streams found"
  90. sys.exit()
  91. for s in streams:
  92. print s
  93. print streams[0]["url"]
  94. call([r"c:\Program Files\VideoLAN\VLC\vlc.exe",streams[0]["url"]])
  95. pass