mirror of
https://github.com/wbt5/real-url.git
synced 2025-08-05 18:31:33 +08:00
Compare commits
2 Commits
0e647a7bb0
...
61e84a9eca
Author | SHA1 | Date | |
---|---|---|---|
|
61e84a9eca | ||
|
f842ae68bc |
57
iqiyi.py
57
iqiyi.py
@ -1,48 +1,75 @@
|
|||||||
# 获取爱奇艺直播的真实流媒体地址。
|
# 获取爱奇艺直播的真实流媒体地址。
|
||||||
# iqiyi.js是cmd5x加密函数
|
# iqiyi.js是cmd5x加密函数
|
||||||
|
|
||||||
import execjs
|
|
||||||
import json
|
import json
|
||||||
import requests
|
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
|
import execjs
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class IQiYi:
|
class IQiYi:
|
||||||
|
"""获取爱奇艺 m3u8 格式直播源
|
||||||
|
|
||||||
|
输入房间号,通常是数字,比如链接 https://gamelive.iqiyi.com/w/74429 中的 74429。
|
||||||
|
注意:
|
||||||
|
爱奇艺有部分直播是来自pps的,要打开房间看链接是否有跳转,有则用pps.py
|
||||||
|
爱奇艺直播依赖js环境,建议安装node.js。
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
rid: 房间号
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
self.rid = rid
|
self.rid = rid
|
||||||
|
self.s = requests.Session()
|
||||||
|
|
||||||
def get_real_url(self):
|
def get_real_url(self):
|
||||||
try:
|
"""
|
||||||
response = requests.get('https://m-gamelive.iqiyi.com/w/' + self.rid).text
|
里面iqiyi.js是个加盐的md5,execjs执行后获取cmd5x的返回值
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
m3u8格式播放地址
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
incorrect rid: 请确实是爱奇艺直播房间号:爱奇艺有部分直播是来自pps的,要打开房间看链接是否有跳转,有则用pps.py
|
||||||
|
Could not find an available JavaScript runtime: 是否安装了js环境
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
res = self.s.get('https://m-gamelive.iqiyi.com/w/' + self.rid).text
|
||||||
# 获取直播间的qipuId
|
# 获取直播间的qipuId
|
||||||
qipuId = re.findall(r'"qipuId":(\d*?),"roomId', response)[0]
|
try:
|
||||||
|
qipuid, = re.findall(r'"qipuId":(\d*?),"roomId', res)
|
||||||
|
except ValueError:
|
||||||
|
raise Exception('Incorrect rid.')
|
||||||
|
|
||||||
callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000'
|
callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000'
|
||||||
params = {
|
params = {
|
||||||
'lp': qipuId,
|
'lp': qipuid,
|
||||||
'src': '01010031010000000000',
|
'src': '01010031010000000000',
|
||||||
'rateVers': 'H5_QIYI',
|
'rateVers': 'H5_QIYI',
|
||||||
'qd_v': 1,
|
'qd_v': 1,
|
||||||
'callback': callback
|
'callback': callback
|
||||||
}
|
}
|
||||||
|
# ba传参iqiyi.js,返回vf
|
||||||
# ba传参iqiyi.js
|
|
||||||
ba = '/jp/live?' + urllib.parse.urlencode(params)
|
ba = '/jp/live?' + urllib.parse.urlencode(params)
|
||||||
with open('iqiyi.js', 'r') as f:
|
with open('iqiyi.js', 'r') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
try:
|
||||||
cmd5x = execjs.compile(content)
|
cmd5x = execjs.compile(content)
|
||||||
vf = cmd5x.call('cmd5x', ba)
|
vf = cmd5x.call('cmd5x', ba)
|
||||||
|
except RuntimeError:
|
||||||
|
raise Exception('Could not find an available JavaScript runtime.')
|
||||||
# 请求
|
# 请求
|
||||||
response = requests.get('https://live.video.iqiyi.com' + ba, params={'vf': vf}).text
|
response = self.s.get('https://live.video.iqiyi.com' + ba, params={'vf': vf}).text
|
||||||
url_json = json.loads(re.findall(r'try{.*?\((.*)\);}catch\(e\){};', response)[0])
|
url_json = json.loads(re.findall(r'try{.*?\((.*)\);}catch\(e\){};', response)[0])
|
||||||
real_url = (url_json.get('data').get('streams'))[0].get('url')
|
url = (url_json.get('data').get('streams'))[0].get('url')
|
||||||
real_url = real_url.replace('hlslive.video.iqiyi.com', 'm3u8live.video.iqiyi.com')
|
url = url.replace('hlslive.video.iqiyi.com', 'm3u8live.video.iqiyi.com')
|
||||||
except:
|
|
||||||
raise Exception('直播间不存在或未开播')
|
return url
|
||||||
return real_url
|
|
||||||
|
|
||||||
|
|
||||||
def get_real_url(rid):
|
def get_real_url(rid):
|
||||||
|
45
zhanqi.py
45
zhanqi.py
@ -1,5 +1,8 @@
|
|||||||
# 获取战旗直播(战旗TV)的真实流媒体地址。https://www.zhanqi.tv/lives
|
# 获取战旗直播(战旗TV)的真实流媒体地址。https://www.zhanqi.tv/lives
|
||||||
# 默认最高画质
|
# 默认最高画质
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
@ -7,22 +10,48 @@ class ZhanQi:
|
|||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
self.rid = rid
|
self.rid = rid
|
||||||
|
self.s = requests.Session()
|
||||||
|
|
||||||
def get_real_url(self):
|
def get_real_url(self):
|
||||||
with requests.Session() as s:
|
|
||||||
res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
|
res = self.s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
|
||||||
try:
|
try:
|
||||||
res = res.json()
|
res = res.json()
|
||||||
videoid = res['data']['videoId']
|
videoid = res['data']['videoId']
|
||||||
status = res['data']['status']
|
status = res['data']['status']
|
||||||
|
except (KeyError, json.decoder.JSONDecodeError):
|
||||||
|
raise Exception('Incorrect rid')
|
||||||
|
|
||||||
if status == '4':
|
if status == '4':
|
||||||
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
|
# 获取gid
|
||||||
real_url = s.get(url).text
|
res = self.s.get('https://www.zhanqi.tv/api/public/room.viewer')
|
||||||
|
try:
|
||||||
|
res = res.json()
|
||||||
|
gid = res['data']['gid']
|
||||||
|
except KeyError:
|
||||||
|
raise Exception('Getting gid incorrectly')
|
||||||
|
|
||||||
|
# 获取cdn_host
|
||||||
|
res = self.s.get('https://umc.danuoyi.alicdn.com/dns_resolve_https?app=zqlive&host_key=alhdl-cdn.zhanqi.tv')
|
||||||
|
cdn_host, = res.json().get('redirect_domain')
|
||||||
|
|
||||||
|
# 获取chain_key
|
||||||
|
data = {
|
||||||
|
'stream': f'{videoid}.flv',
|
||||||
|
'cdnKey': 202,
|
||||||
|
'platform': 128,
|
||||||
|
}
|
||||||
|
headers = {
|
||||||
|
'cookie': f'gid={gid}',
|
||||||
|
}
|
||||||
|
res = self.s.post('https://www.zhanqi.tv/api/public/burglar/chain', data=data, headers=headers).json()
|
||||||
|
chain_key = res['data']['key']
|
||||||
|
url = f'https://{cdn_host}/alhdl-cdn.zhanqi.tv/zqlive/{videoid}.flv?{chain_key}&playNum=68072487067' \
|
||||||
|
f'&gId={gid}&ipFrom=1&clientIp=&fhost=h5&platform=128 '
|
||||||
|
|
||||||
|
return url
|
||||||
else:
|
else:
|
||||||
raise Exception('未开播')
|
raise Exception('No streaming')
|
||||||
except:
|
|
||||||
raise Exception('直播间不存在')
|
|
||||||
return real_url
|
|
||||||
|
|
||||||
|
|
||||||
def get_real_url(rid):
|
def get_real_url(rid):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user