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