mirror of
https://github.com/wbt5/real-url.git
synced 2025-07-29 21:00:30 +08:00
Compare commits
7 Commits
cd9e41e505
...
4cb2edc05a
Author | SHA1 | Date | |
---|---|---|---|
|
4cb2edc05a | ||
|
8a6766681b | ||
|
5bcf800f6e | ||
|
a3865d88c7 | ||
|
e6bfbb58e2 | ||
|
8ee49c50a0 | ||
|
9a2d70f701 |
75
bilibili.py
75
bilibili.py
@ -9,17 +9,23 @@ import requests
|
|||||||
class BiliBili:
|
class BiliBili:
|
||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
|
"""
|
||||||
|
有些地址无法在PotPlayer播放,建议换个播放器试试
|
||||||
|
Args:
|
||||||
|
rid:
|
||||||
|
"""
|
||||||
rid = rid
|
rid = rid
|
||||||
self.header = {
|
self.header = {
|
||||||
'User-Agent': 'Mozilla/5.0 (iPod; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.163 Mobile/15E148 Safari/604.1',
|
'User-Agent': 'Mozilla/5.0 (iPod; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, '
|
||||||
|
'like Gecko) CriOS/87.0.4280.163 Mobile/15E148 Safari/604.1',
|
||||||
}
|
}
|
||||||
# 先获取直播状态和真实房间号
|
# 先获取直播状态和真实房间号
|
||||||
r_url = 'https://api.live.bilibili.com/room/v1/Room/room_init'
|
r_url = 'https://api.live.bilibili.com/room/v1/Room/room_init'
|
||||||
param = {
|
param = {
|
||||||
'id': rid
|
'id': rid
|
||||||
}
|
}
|
||||||
with requests.Session() as s:
|
with requests.Session() as self.s:
|
||||||
res = s.get(r_url, headers=self.header, params=param).json()
|
res = self.s.get(r_url, headers=self.header, params=param).json()
|
||||||
if res['msg'] == '直播间不存在':
|
if res['msg'] == '直播间不存在':
|
||||||
raise Exception(f'bilibili {rid} {res["msg"]}')
|
raise Exception(f'bilibili {rid} {res["msg"]}')
|
||||||
live_status = res['data']['live_status']
|
live_status = res['data']['live_status']
|
||||||
@ -27,46 +33,43 @@ class BiliBili:
|
|||||||
raise Exception(f'bilibili {rid} 未开播')
|
raise Exception(f'bilibili {rid} 未开播')
|
||||||
self.real_room_id = res['data']['room_id']
|
self.real_room_id = res['data']['room_id']
|
||||||
|
|
||||||
def get_real_url(self, current_qn: int = 10000) -> list:
|
def get_real_url(self, current_qn: int = 10000) -> dict:
|
||||||
url = 'https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo'
|
url = 'https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo'
|
||||||
param = {
|
param = {
|
||||||
'device': 'pc',
|
'room_id': self.real_room_id,
|
||||||
'platform': 'h5',
|
|
||||||
'scale': 0,
|
|
||||||
'build': '10000',
|
|
||||||
'protocol': '0,1',
|
'protocol': '0,1',
|
||||||
'format': '0,1,2',
|
'format': '0,1,2',
|
||||||
'codec': '0,1',
|
'codec': '0,1',
|
||||||
'room_id': self.real_room_id,
|
'qn': current_qn,
|
||||||
'qn': current_qn
|
'platform': 'h5',
|
||||||
|
'ptype': 8,
|
||||||
}
|
}
|
||||||
with requests.Session() as session:
|
res = self.s.get(url, headers=self.header, params=param).json()
|
||||||
res = session.get(url, headers=self.header, params=param)
|
stream_info = res['data']['playurl_info']['playurl']['stream']
|
||||||
res = res.json()
|
qn_max = 0
|
||||||
|
|
||||||
|
for data in stream_info:
|
||||||
|
accept_qn = data['format'][0]['codec'][0]['accept_qn']
|
||||||
|
for qn in accept_qn:
|
||||||
|
qn_max = qn if qn > qn_max else qn_max
|
||||||
|
if qn_max != current_qn:
|
||||||
|
param['qn'] = qn_max
|
||||||
|
res = self.s.get(url, headers=self.header, params=param).json()
|
||||||
stream_info = res['data']['playurl_info']['playurl']['stream']
|
stream_info = res['data']['playurl_info']['playurl']['stream']
|
||||||
qn_max = 0
|
|
||||||
for data in stream_info:
|
stream_urls = {}
|
||||||
accept_qn = data['format'][0]['codec'][0]['accept_qn']
|
# flv流无法播放,暂修改成获取hls格式的流,
|
||||||
for qn in accept_qn:
|
for data in stream_info:
|
||||||
qn_max = qn if qn > qn_max else qn_max
|
format_name = data['format'][0]['format_name']
|
||||||
if qn_max != current_qn:
|
if format_name == 'ts':
|
||||||
param['qn'] = qn_max
|
base_url = data['format'][-1]['codec'][0]['base_url']
|
||||||
res = session.get(url, headers=self.header, params=param)
|
url_info = data['format'][-1]['codec'][0]['url_info']
|
||||||
res = res.json()
|
for i, info in enumerate(url_info):
|
||||||
stream_info = res['data']['playurl_info']['playurl']['stream']
|
host = info['host']
|
||||||
stream_url_list = []
|
extra = info['extra']
|
||||||
for data in stream_info:
|
stream_urls[f'线路{i + 1}'] = f'{host}{base_url}{extra}'
|
||||||
format_name = data['format'][0]['format_name']
|
break
|
||||||
if format_name == 'flv':
|
return stream_urls
|
||||||
base_url = data['format'][0]['codec'][0]['base_url']
|
|
||||||
url_info = data['format'][0]['codec'][0]['url_info']
|
|
||||||
for info in url_info:
|
|
||||||
host = info['host']
|
|
||||||
extra = info['extra']
|
|
||||||
# print(host + base_url + extra)
|
|
||||||
stream_url_list.append(host + base_url + extra)
|
|
||||||
break
|
|
||||||
return stream_url_list
|
|
||||||
|
|
||||||
|
|
||||||
def get_real_url(rid):
|
def get_real_url(rid):
|
||||||
|
@ -15,7 +15,8 @@ class FengBo:
|
|||||||
|
|
||||||
def get_real_url(self):
|
def get_real_url(self):
|
||||||
with requests.Session() as s:
|
with requests.Session() as s:
|
||||||
res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(self.rid)).json()
|
res = s.get(f'https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid={self.rid}')
|
||||||
|
res = res.json()
|
||||||
if res['ret'] == 1:
|
if res['ret'] == 1:
|
||||||
info = res['info']
|
info = res['info']
|
||||||
info = unquote(info, 'utf-8')
|
info = unquote(info, 'utf-8')
|
||||||
|
@ -21,7 +21,7 @@ class HongLe:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
tt = int(time.time() * 1000)
|
tt = int(time.time() * 1000)
|
||||||
url = 'https://service.hongle.tv/v2/userw/login?_st1={}'.format(tt)
|
url = f'https://service.hongle.tv/v2/userw/login?_st1={tt}'
|
||||||
data = {
|
data = {
|
||||||
'_st1': tt,
|
'_st1': tt,
|
||||||
'geetest_challenge': '7f4f6fd6257799c0bcac1f38c21c042dl0',
|
'geetest_challenge': '7f4f6fd6257799c0bcac1f38c21c042dl0',
|
||||||
|
1
huya.py
1
huya.py
@ -7,6 +7,7 @@ import urllib.parse
|
|||||||
import hashlib
|
import hashlib
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
def live(e):
|
def live(e):
|
||||||
i, b = e.split('?')
|
i, b = e.split('?')
|
||||||
r = i.split('/')
|
r = i.split('/')
|
||||||
|
41
kuwo.py
41
kuwo.py
@ -1,26 +1,44 @@
|
|||||||
# 酷我聚星直播:http://jx.kuwo.cn/
|
# 酷我聚星直播:http://jx.kuwo.cn/
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class KuWo:
|
class KuWo:
|
||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
self.rid = rid
|
self.rid = rid
|
||||||
|
self.BASE_URL = 'https://jxm0.kuwo.cn/video/mo/live/pull/h5/v3/streamaddr'
|
||||||
|
self.s = requests.Session()
|
||||||
|
|
||||||
def get_real_url(self):
|
def get_real_url(self):
|
||||||
with requests.Session() as s:
|
res = self.s.get(f'https://jx.kuwo.cn/{self.rid}').text
|
||||||
res = s.get('https://zhiboserver.kuwo.cn/proxy.p?src=h5&cmd=enterroom&rid={}&videotype=1&auto=1'.format(self.rid))
|
roomid = re.search(r"roomId: '(\d*)'", res)
|
||||||
res = res.json()
|
if roomid:
|
||||||
try:
|
self.rid = roomid.group(1)
|
||||||
livestatus = res['room']['livestatus']
|
|
||||||
except KeyError:
|
|
||||||
raise Exception('房间号错误')
|
|
||||||
if livestatus == 2:
|
|
||||||
real_url = res['live']['url']
|
|
||||||
return real_url
|
|
||||||
else:
|
else:
|
||||||
raise Exception('未开播')
|
raise Exception('未开播或房间号错误')
|
||||||
|
params = {
|
||||||
|
'std_bid': 1,
|
||||||
|
'roomId': self.rid,
|
||||||
|
'platform': 405,
|
||||||
|
'version': 1000,
|
||||||
|
'streamType': '3-6',
|
||||||
|
'liveType': 1,
|
||||||
|
'ch': 'fx',
|
||||||
|
'ua': 'fx-mobile-h5',
|
||||||
|
'kugouId': 0,
|
||||||
|
'layout': 1,
|
||||||
|
'videoAppId': 10011,
|
||||||
|
}
|
||||||
|
res = self.s.get(self.BASE_URL, params=params).json()
|
||||||
|
if res['data']['sid'] == -1:
|
||||||
|
raise Exception('未开播或房间号错误')
|
||||||
|
try:
|
||||||
|
url = res['data']['horizontal'][0]['httpshls'][0]
|
||||||
|
except (KeyError, IndexError):
|
||||||
|
url = res['data']['vertical'][0]['httpshls'][0]
|
||||||
|
return url
|
||||||
|
|
||||||
|
|
||||||
def get_real_url(rid):
|
def get_real_url(rid):
|
||||||
@ -35,4 +53,3 @@ def get_real_url(rid):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
r = input('输入酷我聚星直播房间号:\n')
|
r = input('输入酷我聚星直播房间号:\n')
|
||||||
print(get_real_url(r))
|
print(get_real_url(r))
|
||||||
|
|
||||||
|
7
lehai.py
7
lehai.py
@ -13,7 +13,7 @@ class LeHai:
|
|||||||
self.rid = rid
|
self.rid = rid
|
||||||
|
|
||||||
def get_real_url(self):
|
def get_real_url(self):
|
||||||
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(self.rid)
|
url = f'https://service.lehaitv.com/v2/room/{self.rid}/media/advanceInfoRoom'
|
||||||
params = {
|
params = {
|
||||||
'_st1': int(time.time() * 1e3),
|
'_st1': int(time.time() * 1e3),
|
||||||
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
|
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
|
||||||
@ -29,9 +29,8 @@ class LeHai:
|
|||||||
res = res.json()
|
res = res.json()
|
||||||
statuscode = res['status']['statuscode']
|
statuscode = res['status']['statuscode']
|
||||||
if statuscode == '0':
|
if statuscode == '0':
|
||||||
if res['data']['live_status'] == '1':
|
if res['data']['live_status'] == 1:
|
||||||
anchor, = res['data']['anchor']
|
real_url = res['data']['medial_url_app_for_h264']
|
||||||
real_url = anchor['media_url']
|
|
||||||
return real_url
|
return real_url
|
||||||
else:
|
else:
|
||||||
raise Exception('未开播')
|
raise Exception('未开播')
|
||||||
|
36
pps.py
36
pps.py
@ -9,20 +9,36 @@ class PPS:
|
|||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
self.rid = rid
|
self.rid = rid
|
||||||
|
self.BASE_URL = 'https://m-x.pps.tv/api/stream/getH5'
|
||||||
|
self.s = requests.Session()
|
||||||
|
|
||||||
def get_real_url(self):
|
def get_real_url(self):
|
||||||
|
headers = {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, '
|
||||||
|
'like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
|
||||||
|
'Referer': 'https://m-x.pps.tv/'
|
||||||
|
}
|
||||||
|
tt = int(time.time() * 1000)
|
||||||
try:
|
try:
|
||||||
response = requests.get('http://m-x.pps.tv/room/' + str(self.rid)).text
|
res = self.s.get(f'https://m-x.pps.tv/room/{self.rid}', headers=headers).text
|
||||||
anchor_id = re.findall(r'anchor_id":(\d*),"online_uid', response)[0]
|
anchor_id = re.findall(r'anchor_id":"(\d*)', res)[0]
|
||||||
tt = int(time.time() * 1000)
|
params = {
|
||||||
url = 'http://m-x.pps.tv/api/stream/getH5?qd_tm={}&typeId=1&platform=7&vid=0&qd_vip=0&qd_uid={}&qd_ip=114.114.114.114&qd_vipres=0&qd_src=h5_xiu&qd_tvid=0&callback='.format(tt, anchor_id)
|
'qd_tm': tt,
|
||||||
headers = {
|
'typeId': 1,
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'platform': 7,
|
||||||
'Referer': 'http://m-x.pps.tv/'
|
'vid': 0,
|
||||||
|
'qd_vip': 0,
|
||||||
|
'qd_uid': anchor_id,
|
||||||
|
'qd_ip': '114.114.114.114',
|
||||||
|
'qd_vipres': 0,
|
||||||
|
'qd_src': 'h5_xiu',
|
||||||
|
'qd_tvid': 0,
|
||||||
|
'callback': '',
|
||||||
}
|
}
|
||||||
response = requests.get(url=url, headers=headers).text
|
res = self.s.get(self.BASE_URL, headers=headers, params=params).text
|
||||||
real_url = re.findall(r'"hls":"(.*)","rate_list', response)[0]
|
real_url = re.findall(r'"hls":"(.*)","rate_list', res)[0]
|
||||||
except:
|
except Exception:
|
||||||
raise Exception('直播间不存在或未开播')
|
raise Exception('直播间不存在或未开播')
|
||||||
return real_url
|
return real_url
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user