Python module (submodule repositary), which provides content (video streams) from various online stream sources to corresponding Enigma2, Kodi, Plex plugins

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # -*- coding: UTF-8 -*-
  2. # /*
  3. # * Copyright (C) 2016 ivars777
  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. if __name__ <> "__main__":
  39. __name__ = 'hqq'
  40. def supports(url):
  41. m = re.search(r"https?://hdgo\.\w+/(.+?)$", url, re.DOTALL)
  42. if m:
  43. return True
  44. else:
  45. return False
  46. def resolve(url):
  47. HTTP_HEADER = {
  48. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0',
  49. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  50. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  51. 'Accept-Encoding': 'none',
  52. 'Accept-Language': 'en-US,en;q=0.8',
  53. 'Referer': url} # 'Connection': 'keep-alive'
  54. streams = []
  55. m = re.search(r"https?://hdgo\.\w+/(.+?)$", url, re.DOTALL)
  56. vid=m.group(1)
  57. url2 = "http://couber.be/"+vid
  58. r = requests.get(url2,headers=HTTP_HEADER)
  59. if r.status_code <> 200:
  60. return streams
  61. m = re.search('<iframe src="([^"]+)"', r.content, re.DOTALL)
  62. if not m: return streams
  63. url3 = m.group(1)
  64. HTTP_HEADER["Rererer"] = url2
  65. r = requests.get(url3,headers=HTTP_HEADER)
  66. m = re.search(r"else{\s+setFlash\('([^']+)'\);", r.content, re.DOTALL)
  67. if not m: return streams
  68. q = ["1080p","720p","480p","360p"]
  69. for i,ss in enumerate(m.group(1).split(",")):
  70. s = ss.split(" or ")
  71. if not s[0]: continue
  72. stream = util.item()
  73. stream["url"] = s[0]
  74. stream["name"] = s[0]
  75. stream["quality"] = q[i]
  76. streams.append(stream)
  77. return streams
  78. if __name__ == "__main__":
  79. from subprocess import call
  80. url = "http://hdgo.cc/video/t/Qrz0riUvA65GtkTpDvmlD9TBOn56HSm2/127280/"
  81. url = "http://hdgo.cc/video/t/Qrz0riUvA65GtkTpDvmlD9TBOn56HSm2/34879/"
  82. streams = resolve(url)
  83. if not streams:
  84. print "No streams found"
  85. sys.exit()
  86. for s in streams:
  87. print s
  88. util.play_video(streams)
  89. #print streams[0]["url"]
  90. #call([r"gst-launch-1.0.exe",'uri="%s""'%streams[0]["url"]])
  91. pass