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

cloudsany.py 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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=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. sub = {}
  49. m = re.search(r"(\w+)\|label\|(\w+)\|(\w+)\|subtitles", p0)
  50. if m:
  51. url_sub = "https://cloudsany.com/subtitles/%s.%s" % (m.group(3), m.group(2))
  52. url_title = m.group(1)
  53. print url_title
  54. sub["url"] = url_sub
  55. sub["lang"] = m.group(1)
  56. sub["name"] = m.group(1)
  57. sub["type"] = "srt"
  58. # Stream URL
  59. m = re.search(r"tracks\|(\w+)\|(\w+)\|(\w+)\|files\|(\w+)\|(\w+)\|(\w+)", p0)
  60. if not m:
  61. raise Exception("Can not find stream url")
  62. #https://dl4.sanii.co/files/8/80mbh8zjyuh61n/video.mp4
  63. # 0://1v.1u.1t/1s/2/1r/1q.1p
  64. num = re.search(r"0://1\w\.1\w\.1\w/1\w/(\d+)", r).group(1)
  65. url = "https://%s.%s.%s/files/%s/%s/%s.%s" % (
  66. m.group(6), m.group(5), m.group(4), num, m.group(3), m.group(2), m.group(1))
  67. print url
  68. s = util.item()
  69. s["url"] = url
  70. s["type"] = util.stream_type(s["url"])
  71. s["resolver"] = __name__
  72. #s["lang"] = lang
  73. s["subs"] = [sub]
  74. s["name"] = url
  75. return [s]
  76. if __name__ == "__main__":
  77. from subprocess import call
  78. url = "https://cloudsany.com/i/b4kt66gm2sw4"
  79. url = "https://cloudsany.com/i/jqfm2sqwar22" # teorija par visu/SUB
  80. streams = resolve(url)
  81. if not streams:
  82. print "No streams found"
  83. sys.exit()
  84. for s in streams:
  85. print s
  86. from run import player
  87. player(streams[0]["url"])
  88. #print streams[0]["url"]
  89. #call([r"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe",streams[0]["url"]])
  90. pass