def getFinalLink(link): # trying to decode link downloading it again if ".m3u8" in link: logger.debug("old link: " + link) oldLink = link m3u8Text = ZonaAppCom.getContentFromUrl(link) logger.debug("m3u8 content is: "+m3u8Text) if "http" in m3u8Text: m3u8Text = m3u8Text[m3u8Text.find("http"):] if "\n" not in m3u8Text: link = m3u8Text logger.debug("1) updated link to: " + link) if ".php" in link: # trying second time m3u8Text = ZonaAppCom.getContentFromUrl(link) if "http" in m3u8Text: oldLink = link link = m3u8Text[m3u8Text.find("http"):] logger.debug("2) updated link to: " + link) link += "|" + Downloader.getHeaders(oldLink) else: link += "|" + Downloader.getHeaders(oldLink) else: logger.debug("0) Complex link, not changed!" + link) else: logger.debug("nothing done! "+link) return link
def parse_relayer(params): url = "NonE" try: if params.has_key("url"): url = params["url"] logger.debug("mobdro.directURL: " + url) elif params.has_key("relayer"): params2 = json.loads(params["relayer"]) logger.debug("RELAYED: "+repr(params2)) protocol = "http"#params2["protocol"] app = params2["app"] server = params2["server"] playpath = params2["playpath"] password = params2["password"] dire = params2["dir"] expiration_time = params2["expiration_time"] millis = int(round(time.time() * 1000)) l = millis / 1000L + expiration_time arr = [password, l, dire, playpath] url = "%s%d/%s/%s" url = url % tuple(arr) url_md5 = md5.new(url).digest() url_base64 = base64.b64encode(url_md5) url_base64 = url_base64.replace("+", "-").replace("/", "_").replace("=", "") #arr = [server, url_base64, l, playpath] arr = [protocol,server,app,playpath,url_base64,l] url = "%s://%s/%s/%s?st=%s&e=%d" #"http://%s/live/%s/%d/%s" url = url % tuple(arr) url += "|"+Downloader.getHeaders(Mobdro.MAIN_URL) else: logger.debug("REJECTED: " + repr(params)) except KeyError: url = "exception" pass return url
def extractTargetVideo(page): logger.debug("extracting from page: "+page) html = Streamgaroo.getContentFromUrl(url=page,referer=Streamgaroo.MAIN_URL) logger.debug("html is: "+html) apiKey = Decoder.extract('data-sh="','"',html) bruteJSON = Streamgaroo.getContentFromUrl(Streamgaroo.CHANNEL_API, "h="+apiKey, Streamgaroo.cookie, Streamgaroo.MAIN_URL) jsonList = json.loads(bruteJSON) url2 = jsonList["link"] logger.debug("using url: "+url2) html2 = Streamgaroo.getContentFromUrl(url2, "", Streamgaroo.cookie, page) logger.debug("html2 is: "+html2) if 'playJS("' in html2: finalUrl = Decoder.extract('playJS("','"',html2) logger.debug("found final url: "+finalUrl) finalUrl = finalUrl.replace("http://www.streamgaroo.com/fetch/r/","") #clean proxies if 'playlist.m3u8' in finalUrl and '==' in finalUrl: finalUrl = finalUrl.replace('playlist.m3u8?','chunks.m3u8?') finalUrl = finalUrl + "|" + urllib.unquote(Downloader.getHeaders()) elif "playStream('iframe','" in html2: iframeUrl = finalUrl = Decoder.extract("playStream('iframe','","'",html2) logger.debug("found iframe link: " + iframeUrl) try: iframeHtml = Downloader.getContentFromUrl(url=iframeUrl, data=" ", referer=page) except: logger.debug("trying second way, easy!!") import urllib2 req = urllib2.Request(iframeUrl) req.add_header('Referer', page) req.add_header('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0') resp = urllib2.urlopen(req) iframeHtml = resp.read() logger.debug("done!") pass logger.debug("html iframe is: "+iframeHtml) if 'adca.st/broadcast/player' in iframeHtml: finalUrl = Decoder.decodeBroadcastst(iframeUrl,page) elif 'vaughnlive.tv/embed/video/' in iframeUrl: finalUrl = Decoder.decodeVaughnlivetv(iframeUrl,page) logger.debug("done!") return finalUrl
def getChannels(page): x = [] logger.debug("page is: "+page) if str(page) == '0': page=Zonasportsme.MAIN_URL else: logger.debug("decoding page: "+page) page = base64.b64decode(page) logger.debug("decoded page: "+page) logger.debug("launching web petition to page: "+page) html = Zonasportsme.getContentFromUrl(page,"",Zonasportsme.cookie,Zonasportsme.MAIN_URL) if page==Zonasportsme.MAIN_URL: logger.debug("browsing main menu...") menu = Decoder.extract('<ul class="nav" id="main-menu">',"</li></ul></li></ul>",html) x = Zonasportsme.extractElements(menu) else: url = "" #decoder part if 'http://www.ustream.tv/' in html: uStreamUrl = Decoder.extractWithRegex('http://www.ustream.','"',html) url = Decoder.getUstreamLink(uStreamUrl,page) elif 'castamp.com/embed.js' in html: channel = Decoder.extract('channel="','"',html) url = Decoder.getCastcampLink(channel,page) elif 'adca.st/broadcast/player.js' in html: if "<script type='text/javascript'>id='" in html: id2 = Decoder.extract("<script type='text/javascript'>id='", "';", html) logger.debug("using id = " + id2) url4 = "http://bro.adca.st/stream.php?id=" + id2 + "&width=700&height=450&stretching=uniform" html4 = Zonasportsme.getContentFromUrl(url4, "", Zonasportsme.cookie, page) logger.debug("html4: " + html4) curl = Decoder.rExtract('= "', '=";', html4)+'=' fn = Decoder.rExtract('"','.php";',html4) token = Zonasportsme.getContentFromUrl('http://bro.adca.st/'+fn+'.php', "",Zonasportsme.cookie, url4, True) logger.debug("token: " + token) token = Decoder.extract('":"', '"', token) file = base64.decodestring(curl) + token + "|" + Downloader.getHeaders('http://cdn.allofme.site/jw/jwplayer.flash.swf') logger.debug("final url is: " + file) url = file elif 'zony.tv/static/scripts/zony.js' in html: channel = Decoder.extract("channel='","'",html) url = 'http://www.zony.tv/embedplayer/'+channel+'/1/700/400/' html2 = Zonasportsme.getContentFromUrl(url=url,referer=page) logger.debug("html2 is: "+html2) #newParam = Decoder.extract("so.addParam('FlashVars', '", "'", html2) # brute params, needs a sort newParam = Decoder.extractParams(html2) rtmp = "rtmp://146.185.16.62/stream playPath="+newParam+" swfVfy=1 timeout=10 conn=S:OK live=true swfUrl=http://www.zony.tv/static/scripts/fplayer.swf flashver=WIN/2019,0,0,226 pageUrl="+page url = rtmp elif 'http://www.embeducaster.com/static/' in html: channel = Decoder.extract("channel='", "'", html) url = 'http://www.embeducaster.com/embedplayer/' + channel + '/1/700/400/' html2 = Zonasportsme.getContentFromUrl(url=url, referer=page) logger.debug("html2 is: " + html2) url = Decoder.decodeUcaster(html2,url) elif '247bay.tv/static/' in html: channel = Decoder.extract("channel='", "'", html) url = 'http://www.247bay.tv/embedplayer/'+channel+'/2/750/420' url = Decoder.decode247bay(url,page) element = {} element["title"] = "Stream" element["link"] = url element["permaLink"] = True x.append(element) return x
def getChannels(page): x = [] start = False if str(page) == '0': html = ShowsportTvCom.getContentFromUrl(ShowsportTvCom.MAIN_URL) element = {} element["link"] = '1' element["title"] = 'Display by event' x.append(element) if html.find('<div id="cssmenu">')>-1: #build channels menu from provider cssMenu = Decoder.extract('<div id="cssmenu">','</ul>',html) for htmlElement in cssMenu.split('<li class="has-sub">'): if htmlElement.find('<a href="')>-1: element = {} link = Decoder.extract('<a href="','"',htmlElement) if htmlElement.find(' title="')>-1: title = Decoder.extract(' title="','"',htmlElement) img = Decoder.extract('img src="/','"',htmlElement) element["title"] = title element["link"] = ShowsportTvCom.MAIN_URL+link element["thumbnail"] = ShowsportTvCom.MAIN_URL+img logger.debug("found element: "+title+", url: "+element["link"]) if title != '': x.append(element) elif str(page) == '1': #show by events html = ShowsportTvCom.getContentFromUrl(ShowsportTvCom.MAIN_URL) html = Decoder.extract('<div class="listmatch">','<div id="right_content">',html) for htmlElement in html.split('<div class="leaguelogo column">'): if htmlElement.find(' href="')>-1: href = Decoder.extract(' href="','">',htmlElement) timeHtml = Decoder.extract('<div class="date_time column"><span class="','</span></div>',htmlElement) time = "" if timeHtml.find('</span><span')>-1: time = Decoder.extract('>','</span><span',timeHtml) time+= " - "+timeHtml[timeHtml.rfind(">")+1:] name = Decoder.extract('png"><span>','</span></div>',htmlElement) logger.debug("first name is: "+name) if htmlElement.find('px;">')>-1 and htmlElement.find('</span><img')>-1: name += " vs "+Decoder.extract('px;">','</span><img',htmlElement) logger.debug("final name is: "+name) element = {} if time=='': element["title"] = name else: element["title"] = time+" - "+name element["link"] = ShowsportTvCom.MAIN_URL+href logger.debug("appending event: "+element["title"]) if element["title"].find(" vs ")>-1: x.append(element) else: #open link html = ShowsportTvCom.getContentFromUrl(page) iframeUrl = ShowsportTvCom.MAIN_URL+Decoder.extract('<iframe frameborder="0" marginheight="0" marginwidth="0" height="450" src="/','"',html) logger.debug("iframeUrl is: "+iframeUrl) html2 = ShowsportTvCom.getContentFromUrl(iframeUrl,"",ShowsportTvCom.cookie,page) if html2.find("http://www.caston.tv/player.php?")>-1: id = Decoder.extract("var id = "," ;",html2) url2 = "http://www.caston.tv/player.php?id="+id html3 = ShowsportTvCom.getContentFromUrl(url2,"id="+id,ShowsportTvCom.cookie,iframeUrl) script = Decoder.extract('<script type="text/javascript">\n','</script>',html3) if script.find("document.write(unescape('")>-1: #patch scriptContent = Decoder.extract("document.write(unescape('","'));",script) scriptContent = urllib.unquote(scriptContent) script=re.compile('eval\(function\(w,i,s,e\).*}\((.*?)\)').findall(scriptContent)[0] finalScriptContent = Decoder.preWise(script) logger.debug(finalScriptContent) token = Decoder.extract("token:\"","\"",finalScriptContent) logger.debug("pre-token is: "+token) ajaxContent = dict(token=token, is_ajax=1) #logger.debug(html3) tokenResponse = ShowsportTvCom.getContentFromUrl("http://www.caston.tv/sssss.php",urllib.urlencode(ajaxContent),ShowsportTvCom.cookie,url2,True) logger.debug("token response: "+tokenResponse) file = Decoder.extract("file:\"","\"",finalScriptContent)+Decoder.extract('","','",',tokenResponse)+"&e="+Decoder.rExtract(',',']',tokenResponse)+"|Referer=http://p.jwpcdn.com/6/12/jwplayer.flash.swf" elif html2.find("http://www.sostart.pw/js/embed.js")>-1: fid = Decoder.extract('<script type="text/javascript"> fid="','"',html2) url3 = "http://www.sostart.pw/jwplayer6.php?channel="+fid html3 = ShowsportTvCom.getContentFromUrl(url3,"",ShowsportTvCom.cookie,iframeUrl) if html3.find("http://static.bro.adca.st/broadcast/player.js")>-1: id2 = Decoder.extract("<script type='text/javascript'>id='","';",html3) logger.debug("using id = "+id2) url4 = "http://bro.adcast.site/stream.php?id="+id2+"&width=700&height=450&stretching=uniform" html4 = ShowsportTvCom.getContentFromUrl(url4,"",ShowsportTvCom.cookie,url3) logger.debug("html4: "+html4) curl = Decoder.extract('curl = "','"',html4) token = ShowsportTvCom.getContentFromUrl('http://bro.adcast.site/getToken.php',"",ShowsportTvCom.cookie,url4,True) logger.debug("token: "+token) token = Decoder.extract('":"','"',token) file = base64.decodestring(curl)+token+"|"+Downloader.getHeaders('http://cdn.bro.adcast.site/jwplayer.flash.swf') logger.debug("final url is: "+file) elif html2.find("http://www.iguide.to/embed")>-1: nextIframeUrl = Decoder.extractWithRegex('http://www.iguide.to/embed','"',html2).replace('"',"") file = Decoder.decodeIguide(nextIframeUrl,iframeUrl) elif "/embedplayer.php" in html2: nextIframeUrl = ShowsportTvCom.MAIN_URL+Decoder.extractWithRegex('/embedplayer.php', "'", html2).replace("'", "") logger.debug("next loop will use: "+nextIframeUrl) file = ShowsportTvCom.getChannels(nextIframeUrl) elif html2.find("adca.st/stream.php")>-1: token = False if "http://bro.adca.st/stream.php" not in html2: token = True id2 = Decoder.extract("<script type='text/javascript'>id='","';",html2) logger.debug("using id = "+id2) url4 = "http://bro.adcast.site/stream.php?id="+id2+"&width=700&height=450&stretching=uniform" else: #it's built, not needed extract id url4 = Decoder.extractWithRegex("http://bro.adca.st/stream.php",'"',html2) html4 = ShowsportTvCom.getContentFromUrl(url4,"",ShowsportTvCom.cookie,iframeUrl) logger.debug("html4: "+html4) curl = Decoder.extract('curl = "','"',html4) tokenUrl = "http://bro.adca.st/getToken.php" swfUrl = "http://cdn.allofme.site/jw/jwplayer.flash.swf" if token: tokenUrl = 'http://bro.adcast.site/getToken.php' swfUrl = 'http://cdn.bro.adcast.site/jwplayer.flash.swf' token = ShowsportTvCom.getContentFromUrl(tokenUrl,"",ShowsportTvCom.cookie,url4,True) logger.debug("token: "+token) token = Decoder.extract('":"','"',token) file = base64.decodestring(curl)+token+"|"+Downloader.getHeaders(swfUrl) logger.debug("final url is: "+file) else: logger.debug("trying crickfreetv way...: "+html2) file = Cricfreetv.seekIframeScript(html2, page, page) logger.debug("final remote url: "+file) element = {} element["link"] = file element["permaLink"] = True element["title"] = "Watch streaming" x.append(element) return x