1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-07-29 21:00:30 +08:00

Compare commits

...

4 Commits

Author SHA1 Message Date
wbt5
af57d695e4
🐛 Fix 爱奇艺体育直播 (#265)
-优化返回数据的正则匹配方法
-增加未开播和错误直播间地址的判断
2021-11-07 22:17:19 +08:00
wbt5
009574e918
优化代码 2021-11-07 20:46:06 +08:00
wbt5
e3b91d4c88
优化代码 2021-11-07 20:43:43 +08:00
wbt5
f26b0f4c03
优化代码 2021-11-07 20:38:55 +08:00
4 changed files with 22 additions and 14 deletions

3
2cq.py
View File

@ -10,7 +10,7 @@ class MHT:
def get_real_url(self):
with requests.Session() as s:
res = s.get('https://www.2cq.com/proxy/room/room/info?roomId={}&appId=1004'.format(self.rid))
res = s.get(f'https://www.2cq.com/proxy/room/room/info?roomId={self.rid}&appId=1004')
res = res.json()
if res['status'] == 1:
result = res['result']
@ -35,4 +35,3 @@ def get_real_url(rid):
if __name__ == '__main__':
r = input('输入棉花糖直播房间号:\n')
print(get_real_url(r))

View File

@ -11,14 +11,14 @@ class JWXiu:
def get_real_url(self):
with requests.Session() as s:
res = s.get('http://www.95.cn/{}.html'.format(self.rid)).text
res = s.get(f'https://www.95.cn/{self.rid}.html').text
try:
uid = re.search(r'"uid":(\d+),', res).group(1)
status = re.search(r'"is_offline":"(\d)"', res).group(1)
except AttributeError:
raise Exception('没有找到直播间')
if status == '0':
real_url = 'http://play.95xiu.com/app/{}.flv'.format(uid)
real_url = f'https://play1.95xiu.com/app/{uid}.flv'
return real_url
else:
raise Exception('未开播')
@ -36,4 +36,3 @@ def get_real_url(rid):
if __name__ == '__main__':
r = input('输入95秀房间号\n')
print(get_real_url(r))

View File

@ -10,7 +10,7 @@ class JXiu:
def get_real_url(self):
with requests.Session() as s:
url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str( self.rid)
url = f'https://h5.9xiu.com/room/live/enterRoom?rid={self.rid}'
headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) '
'AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'

View File

@ -19,6 +19,11 @@ import requests
class sIQiYi:
def __init__(self, rid):
"""
收费直播间未开播直播间已结束直播间获取到的地址均无法播放
Args:
rid: 这里传入完整的直播间地址
"""
url = rid
self.rid = url.split('/')[-1]
self.s = requests.Session()
@ -50,8 +55,8 @@ class sIQiYi:
i = n[:y - x]
n = n[y - x:]
for r in range(0, len(a)):
if a[r] == n[r]:
for rs, ele in enumerate(a):
if ele == n[rs]:
i += '0'
else:
i += '1'
@ -108,12 +113,17 @@ class sIQiYi:
# 请求url
url = f'https://live.video.iqiyi.com{k}&vf={vf}'
res = self.s.get(url).text
try:
res, = re.findall(r'try{[\s\S]{33}\((.*)\);}catch\(e\){};', res)
url = json.loads(res)['data']['streams'][-1]['url']
except ValueError:
raise Exception('Incorrect rid.')
data = re.search(r'try{\w{33}\(([\w\W]+)\s\);}catch\(e\){};', res).group(1)
data = json.loads(data)
if data['code'] == 'A00004':
raise Exception('直播间地址错误!')
elif data['code'] == 'A00000':
try:
url = data['data']['streams'][-1]['url']
except IndexError:
raise Exception('可能直播未开始直播或为付费直播!')
else:
raise Exception('无法定位错误原因可提交issue')
return url