def streamRoute_zhiboo(tvmap): # request extend_url if tvmap['sourid'] == ['', '']: return tvmap if tvmap['sourid'][0] == 'iframe': pass else: return tvmap # iframe url url = tvmap['sourid'][1] res = staticResponse(url) shtml = bytes2strings(res.read()) getline = re.search(r'xmlhttp.open(.*?);', shtml).group() routeurl = re.search(r'"https://.*?"', getline).group()[1:-1] res = staticResponse(routeurl) bhtml = res.read() sjson = json.loads(bhtml)['body'] route = sjson['urlInfo']['url'] tvmap['sourid'][1] = route.replace("http://h5live.gslb.cmvideo.cn", "http://mgzb.live.miguvideo.com:8088") return tvmap
def streamRoute_haoqu(tvmap): # request extend_url souridlist = tvmap['sourdid'] if souridlist == []: return [] routelist = [] for i in souridlist: time.sleep(0.5) res = staticResponse(i) shtml = bytes2strings(res.read()) # pidk iframe body signal = re.search(r'signal = \'(.*?)\'', shtml, re.S).group(1) signal = signal.split('$') if signal[2] == 'iframe': signal[1] = exiframe(signal[1]) routelist.append(signal) tvmap['sourdid'] = routelist return tvmap
def gainIframeSrc(url): res = staticResponse(url) shtml = bytes2strings(res.read()) shtml = shtml.replace('\r\n', '').replace('\n\r', '') mode = '' try: iframeline = re.search(r'<p><iframe (.*?)</p>', shtml, re.S).group() iframeSrc = re.search(r'src="(.*?)"', iframeline, re.S).group(1) mode = 'iframe' return (mode, iframeSrc) except Exception as e: logging.error('[%s] gain iframe.error: %s' % (url, e)) try: embedline = re.search(r'<embed(.*?)>', shtml, re.S).group() mode = 'embed' except Exception as e: logging.error('[%s] gain embed.error: %s' % (url, e)) else: try: flashvar = re.search(r'flashvars="(.*?)"', embedline).group(1) except Exception as e: logging.error('[%s] gain embed, flashvar.error: %s' % (url, e)) else: try: stream = re.search(r'a=(.*?)&', flashvar).group(1) stream = stream.replace('%3A', ':').replace('%2F', '/') return (mode, stream) except Exception as e: logging.error('[%s] gain embed, flashvars, a.error: %s' % (url, e)) try: stream = re.search(r'file=(.*?)&', flashvar).group(1) return (mode, stream) except Exception as e: logging.error('[%s] gain embed, flashvars, file.error: %s' % (url, e)) return (mode, '') try: srcbody = re.search(r'src="(.*?)"', embedline).group(1) stream = re.search(r'url=(.*?)&', srcbody).group(1) return (mode, stream) except Exception as e: logging.error('[%s] gain embed, src.error: %s' % (url, e)) try: flashvars = re.search(r'flashvars=(.*?);', shtml, re.S).group() stream = re.search(r'f:\'(.*?)\'', flashvars).group(1) mode = 'flashvars' return (mode, stream) except Exception as e: logging.error('[%s] gain flashvar.error: %s' % (url, e)) return (mode, '')
def exiframe(url): res = staticResponse(url) shtml = bytes2strings(res.read()) try: evalline = re.search(r'eval(.*?)\}\)\)', shtml).group() except Exception as e: logging.error('eval gain failed.error: %s'%e) else: funcline = re.search(r'eval(.*)$', evalline).group(1) param = funcline[1:-1].split('p}')[1] return param return url '''
def gainSourid(url): logging.debug('x url: %s'%url) mode = re.search(r'//(.*?)\.', url).group(1) res = staticResponse(url) bhtml = res.read() shtml = bytes2strings(bhtml) try: tab_syb = re.search(r'<div class="tab-syb"(.*?)</div>', shtml, re.S).group() except Exception as e: logging.error('gain sourdid %s.error: %s'%(mode,e)) return False if mode == 'www': return re.findall(r'data-player="(.*?)"', tab_syb) elif mode == 'm': return re.findall(r'value="(.*?)"', tab_syb)