mirror of
https://github.com/wbt5/real-url.git
synced 2025-07-30 05:20:31 +08:00
更新虎牙直播
This commit is contained in:
parent
915dc7682e
commit
62b805e15c
39
huya.py
39
huya.py
@ -1,7 +1,5 @@
|
|||||||
# 获取虎牙直播的真实流媒体地址。
|
# 获取虎牙直播的真实流媒体地址。
|
||||||
# 现在虎牙直播链接需要密钥和时间戳了
|
# 虎牙"一起看"频道的直播间可能会卡顿
|
||||||
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
import base64
|
import base64
|
||||||
@ -21,31 +19,35 @@ def live(e):
|
|||||||
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))
|
f = str(int(time.time() * 1e7))
|
||||||
l = n['wsTime']
|
ll = n['wsTime']
|
||||||
t = '0'
|
t = '0'
|
||||||
h = '_'.join([p, t, s, f, l])
|
h = '_'.join([p, t, s, f, ll])
|
||||||
m = hashlib.md5(h.encode('utf-8')).hexdigest()
|
m = hashlib.md5(h.encode('utf-8')).hexdigest()
|
||||||
y = c[-1]
|
y = c[-1]
|
||||||
url = "{}?wsSecret={}&wsTime={}&u={}&seqid={}&{}".format(i, m, l, t, f, y)
|
url = "{}?wsSecret={}&wsTime={}&u={}&seqid={}&{}".format(i, m, ll, t, f, y)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
def get_real_url(room_id):
|
def huya(room_id):
|
||||||
try:
|
try:
|
||||||
room_url = 'https://m.huya.com/' + str(room_id)
|
room_url = 'https://m.huya.com/' + str(room_id)
|
||||||
header = {
|
header = {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) '
|
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 '
|
||||||
'Chrome/75.0.3770.100 Mobile Safari/537.36 '
|
'(KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36 '
|
||||||
}
|
}
|
||||||
response = requests.get(url=room_url, headers=header).text
|
response = requests.get(url=room_url, headers=header).text
|
||||||
liveLineUrl = re.findall(r'liveLineUrl = "([\s\S]*?)";', response)[0]
|
livelineurl = re.findall(r'liveLineUrl = "([\s\S]*?)";', response)[0]
|
||||||
if liveLineUrl:
|
if livelineurl:
|
||||||
if 'replay' in liveLineUrl:
|
if 'replay' in livelineurl:
|
||||||
return '直播录像:https:' + liveLineUrl
|
return '直播录像:https:' + livelineurl
|
||||||
else:
|
else:
|
||||||
liveLineUrl = live(liveLineUrl)
|
s_url = live(livelineurl)
|
||||||
real_url = ["https:" + liveLineUrl, "https:" + re.sub(r'_\d{4}.m3u8', '.m3u8', liveLineUrl)]
|
b_url = live(livelineurl.replace('_2000', ''))
|
||||||
|
real_url = {
|
||||||
|
'2000p': s_url,
|
||||||
|
'BD': b_url
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
real_url = '未开播或直播间不存在'
|
real_url = '未开播或直播间不存在'
|
||||||
except:
|
except:
|
||||||
@ -53,7 +55,6 @@ def get_real_url(room_id):
|
|||||||
return real_url
|
return real_url
|
||||||
|
|
||||||
|
|
||||||
rid = input('请输入虎牙房间号:\n')
|
if __name__ == '__main__':
|
||||||
real_url = get_real_url(rid)
|
rid = input('输入虎牙直播间号:\n')
|
||||||
print('该直播间源地址为:')
|
print(huya(rid))
|
||||||
print(real_url)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user