mirror of
https://github.com/wbt5/real-url.git
synced 2025-08-01 14:48:01 +08:00
更新17直播、虎牙直播
This commit is contained in:
parent
6b290826dc
commit
cb3fc14883
@ -8,11 +8,8 @@ def get_real_url(rid):
|
||||
try:
|
||||
response = requests.get(url='https://api-dsa.17app.co/api/v1/lives/' + rid).json()
|
||||
real_url_default = response.get('rtmpUrls')[0].get('url')
|
||||
userID = response.get('userID', 0)
|
||||
real_url_wansu = ''
|
||||
if userID:
|
||||
real_url_wansu = 'http://wansu-china-pull-rtmp-17.tigafocus.com/vod/' + userID + '.flv'
|
||||
real_url = [real_url_default, real_url_wansu]
|
||||
real_url_modify = real_url_default.replace('global-pull-rtmp.17app.co', 'china-pull-rtmp-17.tigafocus.com')
|
||||
real_url = [real_url_modify, real_url_default]
|
||||
except:
|
||||
real_url = '该直播间不存在或未开播'
|
||||
return real_url
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
## 更新
|
||||
|
||||
### 2020.05.23:更新 17直播
|
||||
### 2020.05.23:更新17直播、虎牙直播
|
||||
|
||||
2020.05.19:更新火猫、快手、酷狗、PPS
|
||||
|
||||
|
40
huya.py
40
huya.py
@ -7,26 +7,28 @@ import re
|
||||
|
||||
|
||||
def get_real_url(room_id):
|
||||
room_url = 'https://m.huya.com/' + str(room_id)
|
||||
header = {
|
||||
'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) '
|
||||
'Chrome/75.0.3770.100 Mobile Safari/537.36 '
|
||||
}
|
||||
response = requests.get(url=room_url, headers=header)
|
||||
pattern = r"src=\"([\s\S]*)\" data-setup"
|
||||
pattern2 = r"replay" # 判断是否是回放
|
||||
result = re.findall(pattern, response.text, re.I)
|
||||
if re.search(pattern2, response.text):
|
||||
return result[0]
|
||||
if result:
|
||||
url = re.sub(r'_[\s\S]*.m3u8', '.m3u8', result[0]) # 修改了正则留下了密钥和时间戳
|
||||
url = re.sub(r'hw.hls', 'al.hls', url) # 华为的源好像比阿里的卡
|
||||
else:
|
||||
url = '未开播或直播间不存在'
|
||||
return "https:" + url
|
||||
try:
|
||||
room_url = 'https://m.huya.com/' + str(room_id)
|
||||
header = {
|
||||
'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) '
|
||||
'Chrome/75.0.3770.100 Mobile Safari/537.36 '
|
||||
}
|
||||
response = requests.get(url=room_url, headers=header).text
|
||||
liveLineUrl = re.findall(r'liveLineUrl = "([\s\S]*?)";', response)[0]
|
||||
if liveLineUrl:
|
||||
if 'replay' in liveLineUrl:
|
||||
return '直播录像:' + liveLineUrl
|
||||
else:
|
||||
real_url = ["https:" + liveLineUrl.replace('_2500', ''), "https:" + liveLineUrl]
|
||||
else:
|
||||
real_url = '未开播或直播间不存在'
|
||||
except:
|
||||
real_url = '未开播或直播间不存在'
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入虎牙房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:\n' + real_url)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
Loading…
x
Reference in New Issue
Block a user