# -*- coding: UTF-8 -*- import re,os,sys import json try: import util except: pp = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0,os.sep.join(pp.split(os.sep)[:-1])) import util import urllib2 import requests try: from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) except: pass #from aadecode import AADecoder __author__ = 'ivars777' __name__ = 'cloudsany' if __name__ <> "__main__" else __name__ def supports(url): # https://cloudsany.com/i/b4kt66gm2sw4 return re.search(r'cloudsany\.\w+/\w/.+', url) is not None #INFO_URL = API_BASE_URL + '/streaming/info' def resolve(url): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'Accept-Encoding': 'none', 'Accept-Language': 'en-US,en;q=0.8', 'Referer': url} # 'Connection': 'keep-alive' # https://cloudsany.com/i/b4kt66gm2sw4 m = re.search('cloudsany\.\w+/i/(\w+)', url) if not m: return stream vid=m.group(1) r = requests.get(url, headers=headers) if r.status_code <> 200: raise Exception("Error getting stream") r = r.content m = re.search(r"'(https\|.+?jwplayer)'", r) if not m: print url raise Exception("Can not find stream") p = m.group(1).split("|") p0 = m.group(1) # Subtitles # sub = {} m = re.search(r"(\w+)\|label\|(\w+)\|(\w+)\|subtitles", p0) if m: url_sub = "https://cloudsany.com/subtitles/%s.%s" % (m.group(3), m.group(2)) url_title = m.group(1) print url_title sub["url"] = url_sub sub["lang"] = m.group(1) sub["name"] = m.group(1) sub["type"] = "srt" # Stream URL m = re.search(r"tracks\|(\w+)\|(\w+)\|(\w+)\|files\|(\w+)\|(\w+)\|(\w+)", p0) if not m: raise Exception("Can not find stream url") #https://dl4.sanii.co/files/8/80mbh8zjyuh61n/video.mp4 # 0://1v.1u.1t/1s/2/1r/1q.1p num = re.search(r"0://1\w\.1\w\.1\w/1\w/(\d+)", r).group(1) url = "https://%s.%s.%s/files/%s/%s/%s.%s" % ( m.group(6), m.group(5), m.group(4), num, m.group(3), m.group(2), m.group(1)) print url s = util.item() s["url"] = url s["type"] = util.stream_type(s["url"]) s["resolver"] = __name__ #s["lang"] = lang s["subs"] = [sub] s["name"] = url return [s] if __name__ == "__main__": from subprocess import call url = "https://cloudsany.com/i/b4kt66gm2sw4" url = "https://cloudsany.com/i/jqfm2sqwar22" # teorija par visu/SUB streams = resolve(url) if not streams: print "No streams found" sys.exit() for s in streams: print s from run import player player(streams[0]["url"]) #print streams[0]["url"] #call([r"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe",streams[0]["url"]]) pass