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

openload3.py 3.9KB

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