mirror of
https://github.com/wbt5/real-url.git
synced 2025-07-28 20:35:55 +08:00
基于dingzhengjie提供的方法来提供虎牙直播地址。
This commit is contained in:
parent
b6042b88d8
commit
1380bf2312
39
huya.py
39
huya.py
@ -31,13 +31,13 @@ class HuYa:
|
|||||||
'replay': "https:" + livelineurl,
|
'replay': "https:" + livelineurl,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
s_url = self.live(livelineurl)
|
stream_name = self.get_stream_name(livelineurl)
|
||||||
b_url = self.live(livelineurl.replace('_2000', ''))
|
base_url = 'http://121.12.115.15/tx.hls.huya.com/src/' + stream_name
|
||||||
real_url = {
|
real_url = {
|
||||||
'2000p': "https:" + s_url,
|
'hls': base_url + '.m3u8',
|
||||||
'tx': "https:" + b_url,
|
'flv': base_url + '.flv',
|
||||||
'bd': "https:" + b_url.replace('tx.hls.huya.com', 'bd.hls.huya.com'),
|
'hls_2m': base_url + '.m3u8?ratio=2000',
|
||||||
'migu-bd': "https:" + b_url.replace('tx.hls.huya.com', 'migu-bd.hls.huya.com'),
|
'flv_2m': base_url + '.flv?ratio=2000'
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
raise Exception('未开播或直播间不存在')
|
raise Exception('未开播或直播间不存在')
|
||||||
@ -45,24 +45,39 @@ class HuYa:
|
|||||||
raise Exception('未开播或直播间不存在')
|
raise Exception('未开播或直播间不存在')
|
||||||
return real_url
|
return real_url
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_stream_name(e):
|
||||||
|
i, b = e.split('?')
|
||||||
|
r = i.split('/')
|
||||||
|
s = re.sub(r'.(flv|m3u8)', '', r[-1])
|
||||||
|
return s
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def live(e):
|
def live(e):
|
||||||
i, b = e.split('?')
|
i, b = e.split('?')
|
||||||
r = i.split('/')
|
r = i.split('/')
|
||||||
s = re.sub(r'.(flv|m3u8)', '', r[-1])
|
s = re.sub(r'.(flv|m3u8)', '', r[-1])
|
||||||
c = b.split('&', 3)
|
c = b.split('&')
|
||||||
c = [i for i in c if i != '']
|
c = [i for i in c if i != '']
|
||||||
n = {i.split('=')[0]: i.split('=')[1] for i in c}
|
n = {i.split('=')[0]: i.split('=')[1] for i in c}
|
||||||
fm = urllib.parse.unquote(n['fm'])
|
fm = urllib.parse.unquote(n['fm'])
|
||||||
u = base64.b64decode(fm).decode('utf-8')
|
u = base64.b64decode(fm).decode('utf-8')
|
||||||
p = u.split('_')[0]
|
p = u.split('_')[0]
|
||||||
f = str(int(time.time() * 1e7))
|
seqid = str(int(time.time() * 1e7))
|
||||||
|
ctype = n['ctype']
|
||||||
|
t = n['t']
|
||||||
|
mf = hashlib.md5((seqid + '|' + ctype + '|' + t).encode('utf-8')).hexdigest()
|
||||||
ll = n['wsTime']
|
ll = n['wsTime']
|
||||||
t = '0'
|
ratio = n.get('ratio')
|
||||||
h = '_'.join([p, t, s, f, ll])
|
if ratio is None:
|
||||||
|
ratio = ''
|
||||||
|
uid = '1279523789849'
|
||||||
|
h = '_'.join([p, uid, s, mf, ll])
|
||||||
m = hashlib.md5(h.encode('utf-8')).hexdigest()
|
m = hashlib.md5(h.encode('utf-8')).hexdigest()
|
||||||
y = c[-1]
|
txyp = n['txyp']
|
||||||
url = "{}?wsSecret={}&wsTime={}&u={}&seqid={}&{}".format(i, m, ll, t, f, y)
|
fs = n['fs']
|
||||||
|
url = "{}?wsSecret={}&wsTime={}&uuid=&uid={}&seqid={}&ratio={}&txyp={}&fs={}&ctype={}&ver=1&t={}".format(
|
||||||
|
i, m, ll, uid, seqid, ratio, txyp, fs, ctype, t)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user