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

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