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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # -*- coding: UTF-8 -*-
  2. import re,os,sys
  3. import json
  4. try:
  5. import util
  6. except:
  7. pp = os.path.dirname(os.path.abspath(__file__))
  8. sys.path.insert(0,os.sep.join(pp.split(os.sep)[:-1]))
  9. import util
  10. import urllib2
  11. import requests
  12. try:
  13. from requests.packages.urllib3.exceptions import InsecureRequestWarning
  14. requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
  15. except:
  16. pass
  17. #from aadecode import AADecoder
  18. __author__ = 'ivars777'
  19. __name__ = 'cloudsany' if __name__ <> "__main__" else __name__
  20. def supports(url):
  21. # https://cloudsany.com/i/b4kt66gm2sw4
  22. return re.search(r'cloudsany\.\w+/\w/.+', url) is not None
  23. #INFO_URL = API_BASE_URL + '/streaming/info'
  24. def resolve(url):
  25. headers = {
  26. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0',
  27. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  28. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  29. 'Accept-Encoding': 'none',
  30. 'Accept-Language': 'en-US,en;q=0.8',
  31. 'Referer': url} # 'Connection': 'keep-alive'
  32. # https://cloudsany.com/i/b4kt66gm2sw4
  33. m = re.search('cloudsany\.\w+/i/(\w+)', url)
  34. if not m:
  35. return stream
  36. vid = str(m.group(1))
  37. r = requests.get(url, headers=headers)
  38. if r.status_code <> 200:
  39. raise Exception("Error getting stream")
  40. r = r.content
  41. m = re.search(r"'(https\|.+?jwplayer)'", r)
  42. if not m:
  43. print url
  44. raise Exception("Can not find stream")
  45. p = m.group(1).split("|")
  46. p0 = m.group(1)
  47. # Subtitles #
  48. subs = []
  49. # https://cloudsany.com/subtitles/0w3y7su4c2ko.srt
  50. # Latvian|label|srt|subtitles
  51. #url_sub = "https://cloudsany.com/subtitles/%s.%s" % (vid, "srt")
  52. url_sub = "https://cloudsany.com/subtitles/%s.srt" % vid
  53. r2 = requests.head(url_sub)
  54. m = re.search(r"(\w+)\|label\|(\w+)\|(\w+)\|subtitles", p0)
  55. if r2.status_code == 200 and m:
  56. sub = {}
  57. #url_sub = "https://cloudsany.com/subtitles/%s.%s" % (vid, "srt")
  58. url_title = m.group(1)
  59. print url_title
  60. sub["url"] = url_sub
  61. sub["lang"] = m.group(1)
  62. sub["name"] = m.group(1)
  63. sub["type"] = m.group(2)
  64. subs = [sub]
  65. # Stream URL
  66. # co|sanii|dl1|file
  67. m1 = re.search("\|(co)\|(\w*)\|(\w*)\|(\w*)\|", p0)
  68. # tracks|mp4|video|ut4dluxu56tyll|files
  69. m2 = re.search(r"tracks\|(\w+)\|(\w+)\|(\w+)\|files", p0)
  70. # 0://c.b.a/1t/6/1s/1r.1q
  71. m3 = re.search(r"0://\w+\.\w+\.\w+/\w+/(\d+)/", r)
  72. if not (m1 and m2 and m3):
  73. raise Exception("Can not find stream url")
  74. # https://dl1.sanii.co/files/6/ut4dluxu56tyll/video.mp4
  75. l1 = list(m1.groups())
  76. if "" in l1: l1.remove("")
  77. url = "https://%s.%s.%s/files/%s/%s/%s.%s" % (
  78. l1[2], l1[1], l1[0], m3.group(1), m2.group(3), m2.group(2), m2.group(1))
  79. print url
  80. s = util.item()
  81. s["url"] = url
  82. s["type"] = util.stream_type(s["url"])
  83. s["resolver"] = __name__
  84. #s["lang"] = lang
  85. s["subs"] = subs
  86. s["name"] = url
  87. return [s]
  88. if __name__ == "__main__":
  89. from subprocess import call
  90. url = "https://cloudsany.com/i/b4kt66gm2sw4"
  91. url = "https://cloudsany.com/i/jqfm2sqwar22" # teorija par visu/SUB
  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. from run import player
  99. player(streams[0]["url"])
  100. #print streams[0]["url"]
  101. #call([r"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe",streams[0]["url"]])
  102. pass