def run(domain,id,ref,width="700",height="480"): type="rtmp" #provides: http://www.hdmyt.info, http://www.playerhd(n).pw r_pageurl="http://%s/channel.php?file=%s&width=%s&height=%s&autostart=true"%(domain,id,width,height) #loop through endless domains and player/channel pages until you find embed code while True: page=bt.get_page(r_pageurl,encoding,referer=ref) pageurl=re.findall('iframe src="(.*?)"',page) if len(pageurl)>0: r_pageurl=pageurl[0] else: r_pageurl=re.findall('<script type="text/javascript" src="(.*?channel\.php.*?)"',page)[0] if "embed.php?" in r_pageurl: break page=bt.get_page(r_pageurl,encoding,referer=ref) #script=urllib.unquote(re.findall("unescape\('(.*?)'\)",page)[0]) sx1=re.findall('id="ssx1" value="(.*?)"',page)[0].decode("base64") sx4=re.findall('id="ssx4" value="(.*?)"',page)[0].decode("base64") r_swfurl="http://www.businessapp1.pw/jwplayer5/addplayer/jwplayer.flash.swf" r_tcurl=sx4 r_playpath=sx1 up=urlparse.urlparse(r_tcurl) values={} values["app"]=up.path[1:]+"?"+up.query values["tcUrl"]=r_tcurl values["playpath"]=r_playpath values["pageUrl"]=r_pageurl values["swfUrl"]=r_swfurl values["flashver"]="WIN 19,0,0,185" values["live"]="true" return type,values
def run(ch,referer): # provides janjua.tv, p3gtv and friends type="rtmpe" r_pageurl="http://www.hdcast.info/embed.php?live=%s"%ch page=bt.get_page(r_pageurl,encoding,referer=referer) funcs=re.findall(" return\((.*?)\)\;",page) ops=funcs[0].split(" + ") r_tcurl="".join(eval(ops[0].split(".join")[0])) r_tcurl=r_tcurl+"".join(eval(re.findall(ops[1].split(".join")[0]+" \= (\[.*?\])",page)[0])) r_tcurl=r_tcurl+re.findall(re.findall("getElementById\(\"(.*?)\"\)",ops[2])[0]+"\>(.*?)<",page)[0] r_app=r_tcurl.split("/")[-1]+"/" r_tcurl=r_tcurl.replace("\\","")+"/" r_flashver="WIN 20,0,0,267" r_swfurl="http://www.hdcast.info/myplayer/jwplayer.flash.swf" r_playpath=ch r_token=re.findall("securetoken: (.*?)\n",page)[0] values={} values["app"]=r_app values["tcUrl"]=r_tcurl values["playpath"]="".join(eval(funcs[1].split(".join")[0])) values["pageUrl"]=r_pageurl values["swfUrl"]=r_swfurl values["live"]="false" values["flashver"]=r_flashver #values["token"]=r_token return type,values
def scrape_streaming_channels(): # scrapes the channel list which is listed on site as currently streaming. These info are not very reliable some of the times. Used to retrive channel name and event timing # arguments: None # returns {n:channel,}:dict ; {1:{"link":"/channel1","name":"Lig TV...","status":"",},2:{...}..] online_chans={} page=bt.get_page(defs.domain+"/home",defs.encoding) events=re.findall('<div class="top-event">(.*?)</div>',page,re.DOTALL) for event in events: title=re.findall('<h2 class="pix-post-title">(.*?)<br>',event,re.DOTALL) title=re.sub('<[^<]+?>', '', title[0]) title=re.sub(' I ',' ',title) title=re.sub('\s\s',' ',title) cnums=re.findall('<a target="webspor" href="/kanal([0-9]*?)">',event,re.DOTALL) etime=title.split()[0] opps=" ".join(title.split()[1:]) if ":" in etime: hour,minute=etime.split(":") event_time=datetime.datetime.now() event_time=event_time.replace(hour=int(hour),minute=int(minute)) event_time=bt.localtime_from_timezone(event_time,"Turkey") event_time=event_time.strftime("%H:%M") else: event_time=etime ctitle="%s | %s "%(event_time,opps) for cnum in cnums: online_chans[int(cnum)]={"link":"/kanal%s"%cnum,"name":ctitle,"status":"","number":int(cnum),"last_check":None} return online_chans
def scrape_channel_page(channel,tout=None): # scrapes the given channel and return a playable url # arguments: channel:dict ; {"link":"/channel1","name":"Channel1","status":"state","number":int(1)} # returns type:str,stream:str page=bt.get_page("%s/HD/TV/%s"%(domain,channel["link"]),encoding) aliez=re.findall('src="(.*?aliez.biz/player/live.php.*?)"',page) mips=re.findall("channel='(.*?)', .='(.*?)';</script><script type='text/javascript' src='(.*?)'></script>",page) hdmyt=re.findall("hdmyt.info/channel.php\?file=([0-9]*?)&",page) playerhd1=re.findall("playerhd1.pw/channel.php\?file=([0-9]*?)&",page) ll.timeout=tout if len(aliez)>0: id=urlparse.parse_qs(urlparse.urlparse(aliez[0]).query)["id"][0] type,stream=ll.scrape_url("aliez",id,domain) elif len(mips)>0: channel=mips[0][0] e=mips[0][1] script=mips[0][2] type,stream=ll.scrape_url("mips",channel,e,script,domain) elif len(hdmyt)>0: type,stream=ll.scrape_url("playerhd1",hdmyt[0]) elif len(playerhd1)>0: type,stream=ll.scrape_url("playerhd1",playerhd1[0]) else: type="ERROR: WEBSPOR | Can't detect streaming service type" stream = "" return type,stream
def scrape_streaming_channels(): # scrapes the channel list which is listed on site as currently streaming. These info is not very reliable some of the times. Used to retrive channel name and event timing # arguments: None # returns {n:channel,}:dict ; {1:{"link":"/channel1","name":"Lig TV...","status":"",},2:{...}..] online_chans={} page=bt.get_page(domain+"/HD/TV/info/home",encoding) articles=re.findall("<article>(.*?)</article>",page,re.DOTALL) for article in articles: etime=re.findall('<time datetime="([0-9]*?)">([0-9]*?)\:([0-9]*?)</time>',article) if not len(etime)>0: etime=re.findall('<time datetime=".*?">(.*?)</time>',article) if len(etime)>0: event_time=etime[0] else: continue else: event_time=datetime.datetime.now() event_time=event_time.replace(year=int(etime[0][0]),hour=int(etime[0][1]),minute=int(etime[0][2])) event_time=bt.localtime_from_timezone(event_time,"Turkey") channel=re.findall('href="channel([0-9]*?)" class="pix-hover">(.*?)</a>',article) if not len(channel)>0: continue else: if type(event_time) is datetime.datetime: event_time=event_time.strftime("%H:%M") cnum,cname=channel[0] ctitle="%s : %s "%(event_time,cname) online_chans[int(cnum)]={"link":"info/channel%s"%cnum,"name":ctitle,"status":"","number":int(cnum),"last_check":None} return online_chans
def run(purl,referer): type="rtmp" r_pageurl=purl page=bt.get_page(r_pageurl,encoding,referer=referer) r_flashver="WIN 18,0,0,232" values={} values["live"]="true" try: r_swfurl=re.findall("swf : '(.*?)'",page)[0] r_tcurl=re.findall("streamer : '(.*?)'",page)[0] r_playpath=re.findall("video : '(.*?)'",page)[0] values["tcUrl"]=r_tcurl values["playpath"]=r_playpath values["pageUrl"]=r_pageurl values["swfUrl"]=r_swfurl values["flashver"]=r_flashver except IndexError: import urllib r_swfurl=re.findall('embedSWF\("(.*?)",',page)[0] farg=urllib.unquote(re.findall('"file":[\s]*?"(.*?)"',page)[0]) farg=farg.split("/live/") values["tcUrl"]=farg[0]+"/live" values["playpath"]=farg[1] values["pageUrl"]=r_pageurl values["flashver"]=r_flashver return type,values
def run(id,referer,width="480",height="270"): print id wurl="http://weplayer.pw/stream.php?id=%s"%id page=bt.get_page(wurl,encoding,referer=referer) id=re.findall("<script type='text/javascript'>id='(.*?)'.*?src='http://deltatv.*?/player.js'",page) import deltatv return deltatv.run(id[0],wurl)
def run(channel,e,script,referer,lb=None,width="480",height="270"): # provides janjua.tv, p3gtv and friends type="rtmp" page=bt.get_page(script,encoding) vidserver=re.findall("src=(.*?)/'\+embedded",page)[0] r_pageurl="%s/embedplayer/%s/%s/%s/%s"%(vidserver,channel,e,width,height) page=bt.get_page(r_pageurl,encoding,referer=referer) flashvars=re.findall("'FlashVars', '(.*?)'",page) flashvars=urlparse.parse_qs(flashvars[0]) vidid=flashvars["id"][0] s=flashvars["s"][0] pk=flashvars["pk"][0] r_flashver="WIN 19,0,0,232" r_swfurl="%s%s"%(vidserver,re.findall('SWFObject\("(.*?)"',page)[0]) if lb: r_server="%s/loadbalancer?%s"%(lb,vidid) else: r_server='%s:1935/loadbalancer?%s'%(vidserver,vidid) r_server=bt.get_page(r_server,encoding).split("=")[1] r_tcurl="rtmp://%s/live"%r_server r_playpath="%s?id=%s&pk=%s"%(s,vidid,pk) values={} values["tcUrl"]=r_tcurl values["playpath"]=r_playpath values["pageUrl"]=r_pageurl values["swfUrl"]=r_swfurl values["live"]="true" values["flashver"]=r_flashver values["live"]="true" values["conn"]={0:"S:OK"} return type,values #RTMP Proxy Server v2.4 GIT-2015-01-15 (Compiled by KSV) #(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL #Streaming on rtmp://0.0.0.0:1935 #WARNING: Trying different position for client digest! #Processing connect # app : live # flashVer : WIN 19,0,0,185 # swfUrl : http://www.janjuaplayer.com/resources/scripts/eplayer.swf # tcUrl : rtmp://80.82.65.164/live # pageUrl : http://www.janjuaplayer.com/embedplayer/xxwebsporxx/1/700/480 # live : yes # Playpath : xxwebsporxx?id=47863&pk=3cabac77723cbd6b4fb101871b5fb0202a57b726d6623162114bc27cf541ac62
def run(id,referer,width="480",height="270"): wurl="http://worldsport.me/%s"%id page=bt.get_page(wurl,encoding,referer=referer) soid=re.findall("<script type='text/javascript'>id='(.*?)'.*?http://sostart\.org/playerk\.js",page) if len(soid)>0: import sostart return sostart.run(soid[0],wurl) else: raise
def run(id,ref): type="rtmp" #provides: http://www.hdmyt.info, http://www.playerhd(n).pw r_pageurl="http://content.jwplatform.com/players/%s.html"%id jsurl="http://content.jwplatform.com/players/%s.js"%id #loop through endless domains and player/channel pages until you find embed code page=bt.get_page(r_pageurl,encoding,referer=ref) r_playpath=re.findall('<h1 id="title">(.*?)</h1>',page)[0] js=bt.get_page(jsurl,encoding,referer=ref) r_swfurl=re.findall('flashplayer\: "(.*?)"',js)[0] if r_swfurl.startswith("//"): r_swfurl="http:"+r_swfurl values={} values["app"]="ARYNEWS//" values["tcUrl"]="rtmp://5.254.116.206/ARYNEWS//" values["playpath"]=r_playpath values["pageUrl"]=r_pageurl values["swfUrl"]=r_swfurl values["flashver"]="WIN 19,0,0,185" values["live"]="true" return type,values
def scrape_all_channels(): # scrapes all available the channel list on site # arguments: None # returns {n:channel,}:dict ; {1:{"link":"/channel1","name":"Channel1","status":"",},2:{...}..] all_chans={} page=bt.get_page(domain,encoding) chans=re.findall('<li><a target="orta" href="(.*?)"><span>Channel([0-9]*?)</span></a></li>',page) for chan in chans: clink,cnum=chan ctitle="%s %s"%(c,cnum) all_chans[int(cnum)]={"link":clink,"name":"","status":"","number":int(cnum),"last_check":None} return all_chans
def run(id,referer,width="480",height="270"): wurl="http://sostart.org/streamk.php?id=%s"%id page=bt.get_page(wurl,encoding,referer=referer) r_tcurl=re.findall("file:'(.*?)'",page)[0] values={} values["app"]="live/" values["tcUrl"]=r_tcurl values["playpath"]=id values["pageUrl"]=wurl values["swfUrl"]="http://sostart.org/jw/jwplayer.flash.swf" values["flashver"]="WIN 19,0,0,185" values["live"]="true" return "rtmpe",values
def run(id,referer): type="rtmp" r_pageurl="http://www.zony.tv/embedplayer/%s/1/680/470"%id page=bt.get_page(r_pageurl,encoding,referer=referer) r_flashver="WIN 20,0,0,306" flashvars=re.findall("'FlashVars', '(.*?)'",page) flashvars=urlparse.parse_qs(flashvars[0]) vidid=flashvars["id"][0] s=flashvars["s"][0] pk=flashvars["pk"][0] r_swfurl="http://www.zony.tv%s"%re.findall('SWFObject\("(.*?)"',page)[0] values={} values["live"]="true" r_server='http://cdn.pubzony.com:1935/loadbalancer?%s'%vidid r_server=bt.get_page(r_server,encoding).split("=")[1] r_tcurl="rtmp://%s/stream"%r_server r_playpath="%s?id=%s&pk=%s"%(s,vidid,pk) values["tcUrl"]=r_tcurl values["playpath"]=r_playpath values["pageUrl"]=r_pageurl values["swfUrl"]=r_swfurl values["flashver"]=r_flashver values["conn"]={0:"S:OK"} return type,values
def run(id,referer): token=bt.deobfus(u'\u0114\u018f\xe1\u015f\u018c\xd2\u01a7\xff\u0141\xcc\u0198\u0105\xe4\u0186\xdb\xc9\xe7\xd2\u01a7\xde\xe7\u016b\u017a') purl="http://deltatv.pw/stream.php?id=%s"%id page=bt.get_page(purl,encoding,referer=referer) streamer=re.findall("streamer=(.*?)\&",page) splayer=re.findall('src="(.*?\.swf)"',page) values={} values["tcUrl"]=streamer[0] values["playpath"]=id values["pageUrl"]=purl values["swfUrl"]=splayer[0] values["flashver"]="WIN 19,0,0,185" values["live"]="true" values["token"]=token return "rtmp",values
def run(id,referer): type="rtmp" r_pageurl="http://www.castamp.com/embed.php?c=%s"%id page=bt.get_page(r_pageurl,encoding,referer=referer) r_flashver="WIN 20,0,0,306" r_swfurl="http://p.castamp.com/cplayer.swf" r_tcurl=re.findall("'streamer': '(.*?)'",page)[1] r_playpath=re.findall("'file': '(.*?)'",page)[1] values={} values["live"]="true" values["tcUrl"]=r_tcurl values["playpath"]=r_playpath values["pageUrl"]=r_pageurl values["swfUrl"]=r_swfurl values["flashver"]=r_flashver return type,values
def run(url,ref): page=bt.get_page(url,encoding,referer=ref) type="rtmp" r_tcurl=re.findall("('rtmp://.*?');",page) r_tcurl=eval(r_tcurl[0]) r_playpath=r_tcurl.split("/")[-1] r_app=r_tcurl.split("/")[-2]+"/" r_tcurl="/".join(r_tcurl.split("/")[:-1])+"/" values={} values["app"]=r_app values["tcUrl"]=r_tcurl values["playpath"]=r_playpath values["pageUrl"]=url values["swfUrl"]="http://www.micast.tv/jwplayer/jwplayer.flash.swf" values["flashver"]="WIN 19,0,0,185" values["live"]="true" return type,values
def run(ch,referer): # provides janjua.tv, p3gtv and friends type="rtmp" r_pageurl="http://www.cast4u.tv/embed.php?live=%s"%ch page=bt.get_page(r_pageurl,encoding,referer=referer) r_flashver="WIN 19,0,0,232" r_swfurl="http://cast4u.tv/jwplayer/jwplayer.flash.swf" r_tcurl=re.findall('file1 = "(.*?)"',page)[0] r_playpath=ch values={} values["tcUrl"]=r_tcurl values["playpath"]=r_playpath values["pageUrl"]=r_pageurl values["swfUrl"]=r_swfurl values["live"]="true" values["flashver"]=r_flashver values["live"]="true" return type,values
def scrape_events(): return json.loads(bt.get_page("%s/list/GetLeftMenuShort?lng=%s"%(domain,lang),encoding))["Value"]
def scrape_channel_page(li,tout=None): # scrapes the given channel and return a playable url # arguments: channel:dict ; {"link":"/channel1","name":"Channel1","status":"state","number":int(1)} # returns stream:str link=bt.getliprop(li,"link") purl="%s%s"%(defs.domain,link) page=bt.get_page(purl,defs.encoding) fidscript=re.findall('fid="(.*?)".*?script.*?src="(.*?)"',page) aliez=re.findall('src="(.*?aliez\..*?/player/live\.php.*?)"',page) mips=re.findall("channel='(.*?)', .='(.*?)';</script><script type='text/javascript' src='(.*?)'></script>",page) playerhd=re.findall("http://(.*?)/.*php\?file=([0-9]*?)&",page) weplayer=re.findall("id='(.*?)'; width='([0-9]*?)'; height='([0-9]*?)';</script><script type='text/javascript' src='/player.js'>",page) weplayer2=re.findall("id='(.*?)'; width='([0-9]*?)'; height='([0-9]*?)';</script><script type='text/javascript' src='http\://weplayer.pw/player.js'>",page) jw=re.findall('content.jwplatform.com/players/(.*?)\.html"',page) worldspor=re.findall('fid="(.*?)"',page) micast=re.findall('src="(.*?/iframe.php\?ch=.*?)"',page) sostart=re.findall("id='(.*?)';.*?</script><script type='text/javascript' src='http://sostart.org/player.js'></script>",page) zony=re.findall("channel='(.*?)'.*?src='.*?/static/scripts/zony\.js'",page) castamp=re.findall('channel="(.*?)".*?src=".*?castamp.com/embed\.js"',page) zenex=re.findall("channel='(.*?)'.*?src='.*?data/scripts/ZenexEmbed\.js'",page) janjua=re.findall("channel='(.*?)'.*?src='.*?/scripts/janjua.js'",page) ll.timeout=tout if len(janjua): type,stream=ll.scrape_url("janjua",janjua[0],purl) elif len(zenex): type,stream=ll.scrape_url("zenex",zenex[0],purl) elif len(castamp): type,stream=ll.scrape_url("castamp",castamp[0],purl) elif len(zony): type,stream=ll.scrape_url("zony",zony[0],purl) elif len(fidscript) and "cast4u" in fidscript[0][1]: key,u=fidscript[0] type,stream=ll.scrape_url("cast4u",key,defs.domain) elif len(fidscript) and "hdcast" in fidscript[0][1]: key,u=fidscript[0] type,stream=ll.scrape_url("hdcast",key,defs.domain) elif len(aliez)>0: #id=urlparse.parse_qs(urlparse.urlparse(aliez[0]).query)["id"][0] type,stream=ll.scrape_url("aliez",aliez[0],defs.domain) elif len(jw)>0: type,stream=ll.scrape_url("jw",jw[0],defs.domain) elif len(worldspor)>0: type,stream=ll.scrape_url("worldspor",worldspor[0],defs.domain) elif len(micast): type,stream=ll.scrape_url("micast",micast[0],purl) elif len(mips)>0: channel=mips[0][0] e=mips[0][1] script=mips[0][2] type,stream=ll.scrape_url("mips",channel,e,script,defs.domain) elif len(weplayer)>0: id,w,h=weplayer[0] type,stream=ll.scrape_url("weplayer",id,defs.domain,w,h) elif len(weplayer2)>0: id,w,h=weplayer2[0] type,stream=ll.scrape_url("weplayer",id,defs.domain,w,h) elif len(playerhd)>0: domain,id=playerhd[0] type,stream=ll.scrape_url("playerhd",domain,id,purl) elif len(sostart)>0: type,stream=ll.scrape_url("sostart",sostart[0],purl) else: type="ERROR: WEBSPOR | Can't detect streaming service type" stream = "" if "ERROR:" in type: bt.notify(bt.getliprop(li,"name"),type) bt.setliprop(li,"status",defs.notifications["orange"]%type) bt.setliprop(li,"last_check",time.time()) return None else: return stream