mirror of
https://github.com/wbt5/real-url.git
synced 2025-06-16 15:59:57 +08:00
所有链接获取方式改为面向对象; 无链接时以返回异常的形式,统一接口进行处理;代码格式化;
This commit is contained in:
parent
c4ab4dfb71
commit
c489e88590
42
173.py
42
173.py
@ -1,22 +1,38 @@
|
||||
# 艺气山直播:http://www.173.com/room/category?categoryId=11
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def _173(rid):
|
||||
params = 'roomId={}&format=m3u8'.format(rid)
|
||||
with requests.Session() as s:
|
||||
res = s.post('http://www.173.com/room/getVieoUrl', params=params).json()
|
||||
data = res['data']
|
||||
if data:
|
||||
status = data['status']
|
||||
if status == 2:
|
||||
return data['url']
|
||||
class YQS:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
params = 'roomId={}&format=m3u8'.format(self.rid)
|
||||
with requests.Session() as s:
|
||||
res = s.post('http://www.173.com/room/getVieoUrl', params=params).json()
|
||||
data = res['data']
|
||||
if data:
|
||||
status = data['status']
|
||||
if status == 2:
|
||||
return data['url']
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
yqs = YQS(rid)
|
||||
return yqs.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入艺气山直播房间号:\n')
|
||||
print(_173(r))
|
||||
print(get_real_url(r))
|
||||
|
||||
|
35
17live.py
35
17live.py
@ -4,18 +4,31 @@
|
||||
import requests
|
||||
|
||||
|
||||
class Live17:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.get(url='https://api-dsa.17app.co/api/v1/lives/' + self.rid).json()
|
||||
real_url_default = response.get('rtmpUrls')[0].get('url')
|
||||
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:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
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')
|
||||
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
|
||||
live17 = Live17(rid)
|
||||
return live17.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入17直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入17直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
42
2cq.py
42
2cq.py
@ -1,22 +1,38 @@
|
||||
# 棉花糖直播:https://www.2cq.com/rank
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def mht(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://www.2cq.com/proxy/room/room/info?roomId={}&appId=1004'.format(rid))
|
||||
res = res.json()
|
||||
if res['status'] == 1:
|
||||
result = res['result']
|
||||
if result['liveState'] == 1:
|
||||
real_url = result['pullUrl']
|
||||
return real_url
|
||||
class MHT:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
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 = res.json()
|
||||
if res['status'] == 1:
|
||||
result = res['result']
|
||||
if result['liveState'] == 1:
|
||||
real_url = result['pullUrl']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间可能不存在')
|
||||
raise Exception('直播间可能不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
mht = MHT(rid)
|
||||
return mht.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入棉花糖直播房间号:\n')
|
||||
print(mht(r))
|
||||
print(get_real_url(r))
|
||||
|
||||
|
75
51lm.py
75
51lm.py
@ -1,43 +1,58 @@
|
||||
# 羚萌直播:https://live.51lm.tv/programs/Hot
|
||||
|
||||
from urllib.parse import urlencode
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
|
||||
|
||||
def lm(rid):
|
||||
roominfo = {'programId': rid}
|
||||
class LM:
|
||||
|
||||
def g(d):
|
||||
return hashlib.md5((d + '#' + urlencode(roominfo) + '#Ogvbm2ZiKE').encode('utf-8')).hexdigest()
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
lminfo = {
|
||||
'h': int(time.time()) * 1000,
|
||||
'i': -246397986,
|
||||
'o': 'iphone',
|
||||
's': 'G_c17a64eff3f144a1a48d9f02e8d981c2',
|
||||
't': 'H',
|
||||
'v': '4.20.43',
|
||||
'w': 'a710244508d3cc14f50d24e9fecc496a'
|
||||
}
|
||||
u = g(urlencode(lminfo))
|
||||
lminfo = 'G=' + u + '&' + urlencode(lminfo)
|
||||
with requests.Session() as s:
|
||||
res = s.post('https://www.51lm.tv/live/room/info/basic', json=roominfo, headers={'lminfo': lminfo}).json()
|
||||
code = res['code']
|
||||
if code == 200:
|
||||
status = res['data']['isLiving']
|
||||
if status == 'True':
|
||||
real_url = res['data']['playUrl']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
elif code == -1:
|
||||
raise Exception('输入错误')
|
||||
elif code == 1201:
|
||||
raise Exception('直播间不存在')
|
||||
def get_real_url(self):
|
||||
roominfo = {'programId': self.rid}
|
||||
|
||||
def g(d):
|
||||
return hashlib.md5((d + '#' + urlencode(roominfo) + '#Ogvbm2ZiKE').encode('utf-8')).hexdigest()
|
||||
|
||||
lminfo = {
|
||||
'h': int(time.time()) * 1000,
|
||||
'i': -246397986,
|
||||
'o': 'iphone',
|
||||
's': 'G_c17a64eff3f144a1a48d9f02e8d981c2',
|
||||
't': 'H',
|
||||
'v': '4.20.43',
|
||||
'w': 'a710244508d3cc14f50d24e9fecc496a'
|
||||
}
|
||||
u = g(urlencode(lminfo))
|
||||
lminfo = 'G=' + u + '&' + urlencode(lminfo)
|
||||
with requests.Session() as s:
|
||||
res = s.post('https://www.51lm.tv/live/room/info/basic', json=roominfo, headers={'lminfo': lminfo}).json()
|
||||
code = res['code']
|
||||
if code == 200:
|
||||
status = res['data']['isLiving']
|
||||
if status == 'True':
|
||||
real_url = res['data']['playUrl']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
elif code == -1:
|
||||
raise Exception('输入错误')
|
||||
elif code == 1201:
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
lm = LM(rid)
|
||||
return lm.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入羚萌直播房间号:\n')
|
||||
print(lm(r))
|
||||
print(get_real_url(r))
|
||||
|
42
95xiu.py
42
95xiu.py
@ -1,23 +1,39 @@
|
||||
# 95秀:http://www.95.cn/
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def jwxiu(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('http://www.95.cn/{}.html'.format(rid)).text
|
||||
class JWXiu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('http://www.95.cn/{}.html'.format(self.rid)).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)
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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)
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
jwx = JWXiu(rid)
|
||||
return jwx.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入95秀房间号:\n')
|
||||
print(jwxiu(r))
|
||||
print(get_real_url(r))
|
||||
|
||||
|
51
9xiu.py
51
9xiu.py
@ -1,26 +1,41 @@
|
||||
# 九秀直播:https://www.9xiu.com/other/classify?tag=all&index=all
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def j_xiu(rid):
|
||||
with requests.Session() as s:
|
||||
url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str(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'
|
||||
}
|
||||
res = s.get(url, headers=headers).json()
|
||||
if res['code'] == 200:
|
||||
status = res['data']['status']
|
||||
if status == 0:
|
||||
raise Exception('未开播')
|
||||
elif status == 1:
|
||||
live_url = res['data']['live_url']
|
||||
return live_url
|
||||
else:
|
||||
raise Exception('直播间可能不存在')
|
||||
class JXiu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str( 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'
|
||||
}
|
||||
res = s.get(url, headers=headers).json()
|
||||
if res['code'] == 200:
|
||||
status = res['data']['status']
|
||||
if status == 0:
|
||||
raise Exception('未开播')
|
||||
elif status == 1:
|
||||
live_url = res['data']['live_url']
|
||||
return live_url
|
||||
else:
|
||||
raise Exception('直播间可能不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
jx = JXiu(rid)
|
||||
return jx.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入九秀直播房间号:\n')
|
||||
print(j_xiu(r))
|
||||
print(get_real_url(r))
|
||||
|
86
acfun.py
86
acfun.py
@ -1,45 +1,61 @@
|
||||
# AcFun直播:https://live.acfun.cn/
|
||||
# 默认最高画质
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def acfun(rid):
|
||||
headers = {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'cookie': '_did=H5_',
|
||||
'referer': 'https://m.acfun.cn/'
|
||||
}
|
||||
url = 'https://id.app.acfun.cn/rest/app/visitor/login'
|
||||
data = 'sid=acfun.api.visitor'
|
||||
with requests.Session() as s:
|
||||
res = s.post(url, data=data, headers=headers).json()
|
||||
userid = res['userId']
|
||||
visitor_st = res['acfun.api.visitor_st']
|
||||
class AcFun:
|
||||
|
||||
url = 'https://api.kuaishouzt.com/rest/zt/live/web/startPlay'
|
||||
params = {
|
||||
'subBiz': 'mainApp',
|
||||
'kpn': 'ACFUN_APP',
|
||||
'kpf': 'PC_WEB',
|
||||
'userId': userid,
|
||||
'did': 'H5_',
|
||||
'acfun.api.visitor_st': visitor_st
|
||||
}
|
||||
data = 'authorId={}&pullStreamType=FLV'.format(rid)
|
||||
res = s.post(url, params=params, data=data, headers=headers).json()
|
||||
if res['result'] == 1:
|
||||
data = res['data']
|
||||
videoplayres = json.loads(data['videoPlayRes'])
|
||||
liveadaptivemanifest, = videoplayres['liveAdaptiveManifest']
|
||||
adaptationset = liveadaptivemanifest['adaptationSet']
|
||||
representation = adaptationset['representation'][-1]
|
||||
real_url = representation['url']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('直播已关闭')
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
headers = {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'cookie': '_did=H5_',
|
||||
'referer': 'https://m.acfun.cn/'
|
||||
}
|
||||
url = 'https://id.app.acfun.cn/rest/app/visitor/login'
|
||||
data = 'sid=acfun.api.visitor'
|
||||
with requests.Session() as s:
|
||||
res = s.post(url, data=data, headers=headers).json()
|
||||
userid = res['userId']
|
||||
visitor_st = res['acfun.api.visitor_st']
|
||||
|
||||
url = 'https://api.kuaishouzt.com/rest/zt/live/web/startPlay'
|
||||
params = {
|
||||
'subBiz': 'mainApp',
|
||||
'kpn': 'ACFUN_APP',
|
||||
'kpf': 'PC_WEB',
|
||||
'userId': userid,
|
||||
'did': 'H5_',
|
||||
'acfun.api.visitor_st': visitor_st
|
||||
}
|
||||
data = 'authorId={}&pullStreamType=FLV'.format(self.rid)
|
||||
res = s.post(url, params=params, data=data, headers=headers).json()
|
||||
if res['result'] == 1:
|
||||
data = res['data']
|
||||
videoplayres = json.loads(data['videoPlayRes'])
|
||||
liveadaptivemanifest, = videoplayres['liveAdaptiveManifest']
|
||||
adaptationset = liveadaptivemanifest['adaptationSet']
|
||||
representation = adaptationset['representation'][-1]
|
||||
real_url = representation['url']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('直播已关闭')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
acfun = AcFun(rid)
|
||||
return acfun.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入AcFun直播间号:\n')
|
||||
print(acfun(r))
|
||||
r = input('请输入AcFun直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
84
bilibili.py
84
bilibili.py
@ -6,45 +6,59 @@
|
||||
import requests
|
||||
|
||||
|
||||
def bilibili(rid):
|
||||
# 先获取直播状态和真实房间号
|
||||
r_url = 'https://api.live.bilibili.com/room/v1/Room/room_init?id={}'.format(rid)
|
||||
with requests.Session() as s:
|
||||
res = s.get(r_url).json()
|
||||
code = res['code']
|
||||
if code == 0:
|
||||
live_status = res['data']['live_status']
|
||||
if live_status == 1:
|
||||
room_id = res['data']['room_id']
|
||||
class BiliBili:
|
||||
|
||||
def u(pf):
|
||||
f_url = 'https://api.live.bilibili.com/xlive/web-room/v1/playUrl/playUrl'
|
||||
params = {
|
||||
'cid': room_id,
|
||||
'qn': 10000,
|
||||
'platform': pf,
|
||||
'https_url_req': 1,
|
||||
'ptype': 16
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
# 先获取直播状态和真实房间号
|
||||
r_url = 'https://api.live.bilibili.com/room/v1/Room/room_init?id={}'.format(self.rid)
|
||||
with requests.Session() as s:
|
||||
res = s.get(r_url).json()
|
||||
code = res['code']
|
||||
if code == 0:
|
||||
live_status = res['data']['live_status']
|
||||
if live_status == 1:
|
||||
room_id = res['data']['room_id']
|
||||
|
||||
def u(pf):
|
||||
f_url = 'https://api.live.bilibili.com/xlive/web-room/v1/playUrl/playUrl'
|
||||
params = {
|
||||
'cid': room_id,
|
||||
'qn': 10000,
|
||||
'platform': pf,
|
||||
'https_url_req': 1,
|
||||
'ptype': 16
|
||||
}
|
||||
resp = s.get(f_url, params=params).json()
|
||||
try:
|
||||
durl = resp['data']['durl']
|
||||
real_url = durl[-1]['url']
|
||||
return real_url
|
||||
except KeyError or IndexError:
|
||||
raise Exception('获取失败')
|
||||
|
||||
return {
|
||||
'flv_url': u('web'),
|
||||
'hls_url': u('h5')
|
||||
}
|
||||
resp = s.get(f_url, params=params).json()
|
||||
try:
|
||||
durl = resp['data']['durl']
|
||||
real_url = durl[-1]['url']
|
||||
return real_url
|
||||
except KeyError or IndexError:
|
||||
raise Exception('获取失败')
|
||||
|
||||
return {
|
||||
'flv_url': u('web'),
|
||||
'hls_url': u('h5')
|
||||
}
|
||||
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('房间不存在')
|
||||
raise Exception('房间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
bilibili = BiliBili(rid)
|
||||
return bilibili.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入bilibili直播间号:\n')
|
||||
print(bilibili(r))
|
||||
r = input('请输入bilibili直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
48
cc.py
48
cc.py
@ -1,26 +1,40 @@
|
||||
# 获取网易CC的真实流媒体地址。
|
||||
# 默认为最高画质
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
room_url = 'https://api.cc.163.com/v1/activitylives/anchor/lives?anchor_ccid=' + str(rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
data = response.get('data', 0)
|
||||
if data:
|
||||
channel_id = data.get('{}'.format(rid)).get('channel_id', 0)
|
||||
if channel_id:
|
||||
response = requests.get('https://cc.163.com/live/channel/?channelids=' + str(channel_id)).json()
|
||||
real_url = response.get('data')[0].get('sharefile')
|
||||
class CC:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
room_url = 'https://api.cc.163.com/v1/activitylives/anchor/lives?anchor_ccid=' + str(self.rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
data = response.get('data', 0)
|
||||
if data:
|
||||
channel_id = data.get('{}'.format(self.rid)).get('channel_id', 0)
|
||||
if channel_id:
|
||||
response = requests.get('https://cc.163.com/live/channel/?channelids=' + str(channel_id)).json()
|
||||
real_url = response.get('data')[0].get('sharefile')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
else:
|
||||
real_url = '直播间不存在'
|
||||
else:
|
||||
real_url = '输入错误'
|
||||
return real_url
|
||||
raise Exception('输入错误')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入网易CC直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:\n' + real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
cc = CC(rid)
|
||||
return cc.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入网易CC直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
45
chushou.py
45
chushou.py
@ -1,25 +1,38 @@
|
||||
# 获取触手直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
class ChuShou:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
room_url = 'https://chushou.tv/h5player/video/get-play-url.htm?roomId={}&protocols=2&callback='.format(self.rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
data = response.get('data')[0]
|
||||
real_url = {
|
||||
'sdPlayUrl': data.get('sdPlayUrl', 0),
|
||||
'hdPlayUrl': data.get('hdPlayUrl', 0),
|
||||
'shdPlayUrl': data.get('shdPlayUrl', 0)
|
||||
}
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
room_url = 'https://chushou.tv/h5player/video/get-play-url.htm?roomId={}&protocols=2&callback='.format(rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
data = response.get('data')[0]
|
||||
real_url = {
|
||||
'sdPlayUrl': data.get('sdPlayUrl', 0),
|
||||
'hdPlayUrl': data.get('hdPlayUrl', 0),
|
||||
'shdPlayUrl': data.get('shdPlayUrl', 0)
|
||||
}
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
return real_url
|
||||
cs = ChuShou(rid)
|
||||
return cs.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入触手直播间数字ID:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入触手直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
46
douyin.py
46
douyin.py
@ -2,28 +2,40 @@
|
||||
# 如果知道该直播间如“6779127643792280332”形式的room_id,则直接传入room_id。
|
||||
# 如果不知道room_id,可以使用手机上打开直播间后,选择“分享--复制链接”,传入如“https://v.douyin.com/qyRqMp/”形式的分享链接。
|
||||
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
class DouYin:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
if 'v.douyin.com' in self.rid:
|
||||
room_id = re.findall(r'(\d{19})', requests.get(url=self.rid).url)[0]
|
||||
else:
|
||||
room_id = self.rid
|
||||
room_url = 'https://webcast-hl.amemv.com/webcast/room/reflow/info/?room_id={}&live_id=1'.format(room_id)
|
||||
response = requests.get(url=room_url).json()
|
||||
hls_pull_url = response.get('data').get('room').get('stream_url').get('hls_pull_url')
|
||||
rtmp_pull_url = response.get('data').get('room').get('stream_url').get('rtmp_pull_url')
|
||||
real_url = [rtmp_pull_url, hls_pull_url]
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播或参数错误')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
if 'v.douyin.com' in rid:
|
||||
room_id = re.findall(r'(\d{19})', requests.get(url=rid).url)[0]
|
||||
else:
|
||||
room_id = rid
|
||||
room_url = 'https://webcast-hl.amemv.com/webcast/room/reflow/info/?room_id={}&live_id=1'.format(room_id)
|
||||
response = requests.get(url=room_url).json()
|
||||
hls_pull_url = response.get('data').get('room').get('stream_url').get('hls_pull_url')
|
||||
rtmp_pull_url = response.get('data').get('room').get('stream_url').get('rtmp_pull_url')
|
||||
real_url = [rtmp_pull_url, hls_pull_url]
|
||||
except:
|
||||
real_url = '直播间不存在或未开播或参数错误'
|
||||
return real_url
|
||||
dy = DouYin(rid)
|
||||
return dy.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入抖音直播间room_id或分享链接:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入抖音直播间room_id或分享链接:\n')
|
||||
print(get_real_url(r))
|
||||
|
15
douyu.py
15
douyu.py
@ -1,4 +1,5 @@
|
||||
# 获取斗鱼直播间的真实流媒体地址,默认最高画质。
|
||||
|
||||
import requests
|
||||
import re
|
||||
import execjs
|
||||
@ -74,7 +75,7 @@ class DouYu:
|
||||
def get_real_url(self):
|
||||
error, key = self.get_pre()
|
||||
if error == 0:
|
||||
pass
|
||||
raise Exception('未知错误')
|
||||
elif error == 102:
|
||||
raise Exception('房间不存在')
|
||||
elif error == 104:
|
||||
@ -85,7 +86,15 @@ class DouYu:
|
||||
return "http://tx2play1.douyucdn.cn/live/{}.flv?uuid=".format(key)
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
dy = DouYu(rid)
|
||||
return dy.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入斗鱼直播间号:\n')
|
||||
s = DouYu(r)
|
||||
print(s.get_real_url())
|
||||
print(get_real_url(r))
|
||||
|
75
egame.py
75
egame.py
@ -1,42 +1,55 @@
|
||||
# 获取企鹅电竞的真实流媒体地址。
|
||||
# 默认画质为超清
|
||||
|
||||
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
room_url = 'https://share.egame.qq.com/cgi-bin/pgg_async_fcgi'
|
||||
post_data = {
|
||||
'param': '''{"0":{"module":"pgg_live_read_svr","method":"get_live_and_profile_info","param":{"anchor_id":''' + str(rid) + ''',"layout_id":"hot","index":1,"other_uid":0}}}'''
|
||||
}
|
||||
try:
|
||||
response = requests.post(url=room_url, data=post_data).json()
|
||||
data = response.get('data', 0)
|
||||
if data:
|
||||
video_info = data.get('0').get(
|
||||
'retBody').get('data').get('video_info')
|
||||
pid = video_info.get('pid', 0)
|
||||
if pid:
|
||||
is_live = data.get('0').get(
|
||||
'retBody').get('data').get('profile_info').get('is_live', 0)
|
||||
if is_live:
|
||||
play_url = video_info.get('stream_infos')[
|
||||
0].get('play_url')
|
||||
real_url = re.findall(r'([\w\W]+?)&uid=', play_url)[0]
|
||||
class EGame:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
room_url = 'https://share.egame.qq.com/cgi-bin/pgg_async_fcgi'
|
||||
post_data = {
|
||||
'param': '''{"0":{"module":"pgg_live_read_svr","method":"get_live_and_profile_info","param":{"anchor_id":'''
|
||||
+ str(self.rid) + ''',"layout_id":"hot","index":1,"other_uid":0}}}'''
|
||||
}
|
||||
try:
|
||||
response = requests.post(url=room_url, data=post_data).json()
|
||||
data = response.get('data', 0)
|
||||
if data:
|
||||
video_info = data.get('0').get(
|
||||
'retBody').get('data').get('video_info')
|
||||
pid = video_info.get('pid', 0)
|
||||
if pid:
|
||||
is_live = data.get('0').get(
|
||||
'retBody').get('data').get('profile_info').get('is_live', 0)
|
||||
if is_live:
|
||||
play_url = video_info.get('stream_infos')[
|
||||
0].get('play_url')
|
||||
real_url = re.findall(r'([\w\W]+?)&uid=', play_url)[0]
|
||||
else:
|
||||
raise Exception('直播间未开播')
|
||||
else:
|
||||
real_url = '直播间未开播'
|
||||
raise Exception('直播间未启用')
|
||||
else:
|
||||
real_url = '直播间未启用'
|
||||
else:
|
||||
real_url = '直播间不存在'
|
||||
except:
|
||||
real_url = '数据请求错误'
|
||||
return real_url
|
||||
raise Exception('直播间不存在')
|
||||
except:
|
||||
raise Exception('数据请求错误')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入企鹅电竞房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:\n' + real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
eg = EGame(rid)
|
||||
return eg.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入企鹅电竞房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
@ -1,5 +1,6 @@
|
||||
# 新浪疯播直播:http://www.fengbolive.com/list?type=hot
|
||||
# 链接样式:http://www.fengbolive.com/live/88057518
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
from urllib.parse import unquote
|
||||
import base64
|
||||
@ -7,32 +8,46 @@ import json
|
||||
import requests
|
||||
|
||||
|
||||
def fengbo(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(rid)).json()
|
||||
if res['ret'] == 1:
|
||||
info = res['info']
|
||||
info = unquote(info, 'utf-8')
|
||||
class FengBo:
|
||||
|
||||
# 开始AES解密
|
||||
def pad(t):
|
||||
return t + (16 - len(t) % 16) * b'\x00'
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
key = iv = 'abcdefghqwertyui'.encode('utf8')
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
info = info.encode('utf8')
|
||||
info = pad(info)
|
||||
result = cipher.decrypt(base64.decodebytes(info)).rstrip(b'\0')
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(self.rid)).json()
|
||||
if res['ret'] == 1:
|
||||
info = res['info']
|
||||
info = unquote(info, 'utf-8')
|
||||
|
||||
result = json.loads(result.decode('utf-8'))
|
||||
url = result['url']
|
||||
url = url.replace('hdl', 'hls')
|
||||
url = url.replace('.flv', '/playlist.m3u8')
|
||||
return url
|
||||
else:
|
||||
raise Exception('房间号错误')
|
||||
# 开始AES解密
|
||||
def pad(t):
|
||||
return t + (16 - len(t) % 16) * b'\x00'
|
||||
|
||||
key = iv = 'abcdefghqwertyui'.encode('utf8')
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
info = info.encode('utf8')
|
||||
info = pad(info)
|
||||
result = cipher.decrypt(base64.decodebytes(info)).rstrip(b'\0')
|
||||
|
||||
result = json.loads(result.decode('utf-8'))
|
||||
url = result['url']
|
||||
url = url.replace('hdl', 'hls')
|
||||
url = url.replace('.flv', '/playlist.m3u8')
|
||||
return url
|
||||
else:
|
||||
raise Exception('房间号错误')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
fb = FengBo(rid)
|
||||
return fb.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入疯播直播房间号:\n')
|
||||
print(fengbo(r))
|
||||
print(get_real_url(r))
|
||||
|
123
hongle.py
123
hongle.py
@ -1,6 +1,7 @@
|
||||
# 红人直播:https://www.hongle.tv/
|
||||
# 该平台需登陆,下面代码中已集成一个账号的登陆方式;
|
||||
# 如登陆信息过期,可用自己的账号登陆后,查找浏览器Local Storage中的hrtk字段,替换代码中的accesstoken
|
||||
|
||||
from urllib.parse import urlencode
|
||||
from urllib.parse import unquote
|
||||
import requests
|
||||
@ -9,66 +10,80 @@ import hashlib
|
||||
import json
|
||||
|
||||
|
||||
def hongle(rid):
|
||||
# 模拟登陆
|
||||
with requests.Session() as s:
|
||||
pass
|
||||
class HongLe:
|
||||
|
||||
tt = int(time.time() * 1000)
|
||||
url = 'https://service.hongle.tv/v2/userw/login?_st1={}'.format(tt)
|
||||
data = {
|
||||
'_st1': tt,
|
||||
'geetest_challenge': '7f4f6fd6257799c0bcac1f38c21c042dl0',
|
||||
'geetest_seccode': 'd1163915f4cfd6c998014c4ca8899c9d|jordan',
|
||||
'geetest_validate': 'd1163915f4cfd6c998014c4ca8899c9d',
|
||||
'name': '16530801176',
|
||||
'password': 'QTXz9/Sp40BbMHwVtcb7AQ==',
|
||||
}
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
data1 = urlencode(data) + 'yuj1ah5o'
|
||||
_ajaxdata1 = hashlib.md5(data1.encode('utf-8')).hexdigest()
|
||||
data['_ajaxData1'] = _ajaxdata1
|
||||
del data['_st1']
|
||||
data = json.dumps(data, separators=(',', ':'))
|
||||
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
||||
res = s.post(url, data=data, headers=headers).json()
|
||||
if res['status']['statuscode'] == '0':
|
||||
sessionid = res['data']['sessionid']
|
||||
else:
|
||||
raise Exception('登陆信息过期')
|
||||
def get_real_url(self):
|
||||
# 模拟登陆
|
||||
with requests.Session() as s:
|
||||
pass
|
||||
|
||||
url = 'https://service.hongle.tv/v2/roomw/media'
|
||||
accesstoken = sessionid
|
||||
params = {
|
||||
'_st1': tt,
|
||||
'accessToken': accesstoken,
|
||||
'of': 1,
|
||||
'showid': rid,
|
||||
'tku': 43112608,
|
||||
}
|
||||
data = urlencode(params) + 'yuj1ah5o'
|
||||
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
|
||||
params['_ajaxData1'] = _ajaxData1
|
||||
params['accessToken'] = unquote(accesstoken)
|
||||
tt = int(time.time() * 1000)
|
||||
url = 'https://service.hongle.tv/v2/userw/login?_st1={}'.format(tt)
|
||||
data = {
|
||||
'_st1': tt,
|
||||
'geetest_challenge': '7f4f6fd6257799c0bcac1f38c21c042dl0',
|
||||
'geetest_seccode': 'd1163915f4cfd6c998014c4ca8899c9d|jordan',
|
||||
'geetest_validate': 'd1163915f4cfd6c998014c4ca8899c9d',
|
||||
'name': '16530801176',
|
||||
'password': 'QTXz9/Sp40BbMHwVtcb7AQ==',
|
||||
}
|
||||
|
||||
res = s.get(url, params=params)
|
||||
if res.status_code == 200:
|
||||
res = res.json()
|
||||
statuscode = res['status']['statuscode']
|
||||
if statuscode == '0':
|
||||
if res['data']['live_status'] == '1':
|
||||
real_url = res['data']['media_url_web']
|
||||
real_url = real_url.replace('http', 'https')
|
||||
real_url = real_url.replace('__', '&')
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
data1 = urlencode(data) + 'yuj1ah5o'
|
||||
_ajaxdata1 = hashlib.md5(data1.encode('utf-8')).hexdigest()
|
||||
data['_ajaxData1'] = _ajaxdata1
|
||||
del data['_st1']
|
||||
data = json.dumps(data, separators=(',', ':'))
|
||||
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
||||
res = s.post(url, data=data, headers=headers).json()
|
||||
if res['status']['statuscode'] == '0':
|
||||
sessionid = res['data']['sessionid']
|
||||
else:
|
||||
raise Exception('房间不存在')
|
||||
else:
|
||||
raise Exception('参数错误')
|
||||
raise Exception('登陆信息过期')
|
||||
|
||||
url = 'https://service.hongle.tv/v2/roomw/media'
|
||||
accesstoken = sessionid
|
||||
params = {
|
||||
'_st1': tt,
|
||||
'accessToken': accesstoken,
|
||||
'of': 1,
|
||||
'showid': self.rid,
|
||||
'tku': 43112608,
|
||||
}
|
||||
data = urlencode(params) + 'yuj1ah5o'
|
||||
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
|
||||
params['_ajaxData1'] = _ajaxData1
|
||||
params['accessToken'] = unquote(accesstoken)
|
||||
|
||||
res = s.get(url, params=params)
|
||||
if res.status_code == 200:
|
||||
res = res.json()
|
||||
statuscode = res['status']['statuscode']
|
||||
if statuscode == '0':
|
||||
if res['data']['live_status'] == '1':
|
||||
real_url = res['data']['media_url_web']
|
||||
real_url = real_url.replace('http', 'https')
|
||||
real_url = real_url.replace('__', '&')
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('房间不存在')
|
||||
else:
|
||||
raise Exception('参数错误')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
hl = HongLe(rid)
|
||||
return hl.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入红人直播房间号:\n')
|
||||
print(hongle(r))
|
||||
print(get_real_url(r))
|
||||
|
35
huajiao.py
35
huajiao.py
@ -1,21 +1,34 @@
|
||||
# 获取花椒直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
import time
|
||||
|
||||
|
||||
class HuaJiao:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
tt = str(time.time())
|
||||
try:
|
||||
room_url = 'https://h.huajiao.com/api/getFeedInfo?sid={tt}&liveid={rid}'.format(tt=tt, rid=self.rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
real_url = response.get('data').get('live').get('main')
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
tt = str(time.time())
|
||||
try:
|
||||
room_url = 'https://h.huajiao.com/api/getFeedInfo?sid={tt}&liveid={rid}'.format(tt=tt, rid=rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
real_url = response.get('data').get('live').get('main')
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
return real_url
|
||||
hj = HuaJiao(rid)
|
||||
return hj.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入花椒直播间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:\n' + real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入花椒直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
100
huomao.py
100
huomao.py
@ -3,62 +3,74 @@
|
||||
# 实际上使用http://live-lx-hdl.huomaotv.cn/live/qvCESZ?token=44a7f115f0af496e268bcbb7cdbb63b1,即可播放
|
||||
# 链接中lx可替换cdn(lx,tx,ws,js,jd2等),媒体类型可为.flv或.m3u8,码率可为BL8M,BL4M,TD,BD,HD,SD
|
||||
|
||||
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
import re
|
||||
|
||||
|
||||
def get_time():
|
||||
tt = str(int((time.time() * 1000)))
|
||||
return tt
|
||||
class HuoMao:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_videoids(rid):
|
||||
room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid)
|
||||
response = requests.get(url=room_url).text
|
||||
try:
|
||||
videoids = re.findall(r'var stream = "([\w\W]+?)";', response)[0]
|
||||
except:
|
||||
videoids = 0
|
||||
return videoids
|
||||
@staticmethod
|
||||
def get_time():
|
||||
tt = str(int((time.time() * 1000)))
|
||||
return tt
|
||||
|
||||
@staticmethod
|
||||
def get_videoids(rid):
|
||||
room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid)
|
||||
response = requests.get(url=room_url).text
|
||||
try:
|
||||
videoids = re.findall(r'var stream = "([\w\W]+?)";', response)[0]
|
||||
except:
|
||||
videoids = 0
|
||||
return videoids
|
||||
|
||||
def get_token(videoids, time):
|
||||
token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) +
|
||||
'6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest()
|
||||
return token
|
||||
@staticmethod
|
||||
def get_token(videoids, time):
|
||||
token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) +
|
||||
'6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest()
|
||||
return token
|
||||
|
||||
def get_real_url(self):
|
||||
videoids = self.get_videoids(self.rid)
|
||||
if videoids:
|
||||
time = self.get_time()
|
||||
token = self.get_token(videoids, time)
|
||||
room_url = 'https://www.huomao.com/swf/live_data'
|
||||
post_data = {
|
||||
'cdns': 1,
|
||||
'streamtype': 'live',
|
||||
'VideoIDS': videoids,
|
||||
'from': 'huomaoh5room',
|
||||
'time': time,
|
||||
'token': token
|
||||
}
|
||||
response = requests.post(url=room_url, data=post_data).json()
|
||||
roomStatus = response.get('roomStatus', 0)
|
||||
if roomStatus == '1':
|
||||
real_url_flv = response.get('streamList')[-1].get('list')[0].get('url')
|
||||
real_url_m3u8 = response.get('streamList')[-1].get('list_hls')[0].get('url')
|
||||
real_url = [real_url_flv, real_url_m3u8.replace('_480', '')]
|
||||
else:
|
||||
raise Exception('直播间未开播')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
videoids = get_videoids(rid)
|
||||
if videoids:
|
||||
time = get_time()
|
||||
token = get_token(videoids, time)
|
||||
room_url = 'https://www.huomao.com/swf/live_data'
|
||||
post_data = {
|
||||
'cdns': 1,
|
||||
'streamtype': 'live',
|
||||
'VideoIDS': videoids,
|
||||
'from': 'huomaoh5room',
|
||||
'time': time,
|
||||
'token': token
|
||||
}
|
||||
response = requests.post(url=room_url, data=post_data).json()
|
||||
roomStatus = response.get('roomStatus', 0)
|
||||
if roomStatus == '1':
|
||||
real_url_flv = response.get('streamList')[-1].get('list')[0].get('url')
|
||||
real_url_m3u8 = response.get('streamList')[-1].get('list_hls')[0].get('url')
|
||||
real_url = [real_url_flv, real_url_m3u8.replace('_480', '')]
|
||||
else:
|
||||
real_url = '直播间未开播'
|
||||
else:
|
||||
real_url = '直播间不存在'
|
||||
return real_url
|
||||
try:
|
||||
hm = HuoMao(rid)
|
||||
return hm.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入火猫直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入火猫直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
105
huya.py
105
huya.py
@ -1,5 +1,6 @@
|
||||
# 获取虎牙直播的真实流媒体地址。
|
||||
# 虎牙"一起看"频道的直播间可能会卡顿
|
||||
|
||||
import requests
|
||||
import re
|
||||
import base64
|
||||
@ -8,53 +9,69 @@ import hashlib
|
||||
import time
|
||||
|
||||
|
||||
def live(e):
|
||||
i, b = e.split('?')
|
||||
r = i.split('/')
|
||||
s = re.sub(r'.(flv|m3u8)', '', r[-1])
|
||||
c = b.split('&', 3)
|
||||
c = [i for i in c if i != '']
|
||||
n = {i.split('=')[0]: i.split('=')[1] for i in c}
|
||||
fm = urllib.parse.unquote(n['fm'])
|
||||
u = base64.b64decode(fm).decode('utf-8')
|
||||
p = u.split('_')[0]
|
||||
f = str(int(time.time() * 1e7))
|
||||
ll = n['wsTime']
|
||||
t = '0'
|
||||
h = '_'.join([p, t, s, f, ll])
|
||||
m = hashlib.md5(h.encode('utf-8')).hexdigest()
|
||||
y = c[-1]
|
||||
url = "{}?wsSecret={}&wsTime={}&u={}&seqid={}&{}".format(i, m, ll, t, f, y)
|
||||
return url
|
||||
class HuYa:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def huya(room_id):
|
||||
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 '直播录像:https:' + livelineurl
|
||||
def get_real_url(self):
|
||||
try:
|
||||
room_url = 'https://m.huya.com/' + str(self.rid)
|
||||
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:
|
||||
real_url = {
|
||||
'replay': "https:" + livelineurl,
|
||||
}
|
||||
else:
|
||||
s_url = self.live(livelineurl)
|
||||
b_url = self.live(livelineurl.replace('_2000', ''))
|
||||
real_url = {
|
||||
'2000p': "https:" + s_url,
|
||||
'BD': "https:" + b_url
|
||||
}
|
||||
else:
|
||||
s_url = live(livelineurl)
|
||||
b_url = live(livelineurl.replace('_2000', ''))
|
||||
real_url = {
|
||||
'2000p': "https:" + s_url,
|
||||
'BD': "https:" + b_url
|
||||
}
|
||||
else:
|
||||
real_url = '未开播或直播间不存在'
|
||||
except:
|
||||
real_url = '未开播或直播间不存在'
|
||||
return real_url
|
||||
raise Exception('未开播或直播间不存在')
|
||||
except Exception as e:
|
||||
raise Exception('未开播或直播间不存在')
|
||||
return real_url
|
||||
|
||||
@staticmethod
|
||||
def live(e):
|
||||
i, b = e.split('?')
|
||||
r = i.split('/')
|
||||
s = re.sub(r'.(flv|m3u8)', '', r[-1])
|
||||
c = b.split('&', 3)
|
||||
c = [i for i in c if i != '']
|
||||
n = {i.split('=')[0]: i.split('=')[1] for i in c}
|
||||
fm = urllib.parse.unquote(n['fm'])
|
||||
u = base64.b64decode(fm).decode('utf-8')
|
||||
p = u.split('_')[0]
|
||||
f = str(int(time.time() * 1e7))
|
||||
ll = n['wsTime']
|
||||
t = '0'
|
||||
h = '_'.join([p, t, s, f, ll])
|
||||
m = hashlib.md5(h.encode('utf-8')).hexdigest()
|
||||
y = c[-1]
|
||||
url = "{}?wsSecret={}&wsTime={}&u={}&seqid={}&{}".format(i, m, ll, t, f, y)
|
||||
return url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
hy = HuYa(rid)
|
||||
return hy.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
rid = input('输入虎牙直播间号:\n')
|
||||
print(huya(rid))
|
||||
rid = input('输入虎牙直播房间号:\n')
|
||||
print(get_real_url(rid))
|
||||
|
41
imifun.py
41
imifun.py
@ -1,23 +1,38 @@
|
||||
# 艾米直播:https://www.imifun.com/
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def imifun(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://www.imifun.com/' + str(rid)).text
|
||||
roomid = re.search(r"roomId:\s'([\w-]+)'", res)
|
||||
if roomid:
|
||||
status = re.search(r"isLive:(\d),", res).group(1)
|
||||
if status == '1':
|
||||
real_url = 'https://wsmd.happyia.com/ivp/{}.flv'.format(roomid.group(1))
|
||||
return real_url
|
||||
class IMFun:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://www.imifun.com/' + str(self.rid)).text
|
||||
roomid = re.search(r"roomId:\s'([\w-]+)'", res)
|
||||
if roomid:
|
||||
status = re.search(r"isLive:(\d),", res).group(1)
|
||||
if status == '1':
|
||||
real_url = 'https://wsmd.happyia.com/ivp/{}.flv'.format(roomid.group(1))
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
imf = IMFun(rid)
|
||||
return imf.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入艾米直播房间号:\n')
|
||||
print(imifun(r))
|
||||
print(get_real_url(r))
|
||||
|
54
immomo.py
54
immomo.py
@ -1,31 +1,43 @@
|
||||
import requests
|
||||
|
||||
|
||||
def immomo(rid):
|
||||
url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos'
|
||||
data = {
|
||||
'stid': rid,
|
||||
'src': 'url'
|
||||
}
|
||||
class ImMoMo:
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
with requests.Session() as s:
|
||||
s.get('https://web.immomo.com')
|
||||
res = s.post(url, data=data).json()
|
||||
def get_real_url(self):
|
||||
url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos'
|
||||
data = {
|
||||
'stid': self.rid,
|
||||
'src': 'url'
|
||||
}
|
||||
|
||||
ec = res.get('ec', 0)
|
||||
if ec != 200:
|
||||
raise Exception('请求参数错误')
|
||||
else:
|
||||
live = res['data']['live']
|
||||
if live:
|
||||
real_url = res['data']['url']
|
||||
return real_url
|
||||
with requests.Session() as s:
|
||||
s.get('https://web.immomo.com')
|
||||
res = s.post(url, data=data).json()
|
||||
|
||||
ec = res.get('ec', 0)
|
||||
if ec != 200:
|
||||
raise Exception('请求参数错误')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
live = res['data']['live']
|
||||
if live:
|
||||
real_url = res['data']['url']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
mm = ImMoMo(rid)
|
||||
return mm.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入陌陌直播房间号:\n')
|
||||
print(immomo(r))
|
||||
r = input('请输入陌陌直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
# https://web.immomo.com/live/337033339
|
||||
|
44
inke.py
44
inke.py
@ -1,25 +1,37 @@
|
||||
# 获取映客直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
class InKe:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
room_url = 'https://webapi.busi.inke.cn/web/live_share_pc?uid=' + str(self.rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
record_url = response.get('data').get('file').get('record_url')
|
||||
stream_addr = response.get('data').get('live_addr')
|
||||
real_url = {
|
||||
'record_url': record_url,
|
||||
'stream_addr': stream_addr
|
||||
}
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
room_url = 'https://webapi.busi.inke.cn/web/live_share_pc?uid=' + str(rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
record_url = response.get('data').get('file').get('record_url')
|
||||
stream_addr = response.get('data').get('live_addr')
|
||||
real_url = {
|
||||
'record_url': record_url,
|
||||
'stream_addr': stream_addr
|
||||
}
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
return real_url
|
||||
inke = InKe(rid)
|
||||
return inke.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入映客直播间uid:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入映客直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
76
iqiyi.py
76
iqiyi.py
@ -9,39 +9,51 @@ import time
|
||||
import urllib.parse
|
||||
|
||||
|
||||
class IQiYi:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.get('https://m-gamelive.iqiyi.com/w/' + self.rid).text
|
||||
# 获取直播间的qipuId
|
||||
qipuId = re.findall(r'"qipuId":(\d*?),"roomId', response)[0]
|
||||
callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000'
|
||||
params = {
|
||||
'lp': qipuId,
|
||||
'src': '01010031010000000000',
|
||||
'rateVers': 'H5_QIYI',
|
||||
'qd_v': 1,
|
||||
'callback': callback
|
||||
}
|
||||
|
||||
# ba传参iqiyi.js
|
||||
ba = '/jp/live?' + urllib.parse.urlencode(params)
|
||||
with open('iqiyi.js', 'r') as f:
|
||||
content = f.read()
|
||||
cmd5x = execjs.compile(content)
|
||||
vf = cmd5x.call('cmd5x', ba)
|
||||
|
||||
# 请求
|
||||
response = requests.get('https://live.video.iqiyi.com' + ba, params={'vf': vf}).text
|
||||
url_json = json.loads(re.findall(r'try{.*?\((.*)\);}catch\(e\){};', response)[0])
|
||||
real_url = (url_json.get('data').get('streams'))[0].get('url')
|
||||
real_url = real_url.replace('hlslive.video.iqiyi.com', 'm3u8live.video.iqiyi.com')
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
response = requests.get('https://m-gamelive.iqiyi.com/w/' + rid).text
|
||||
# 获取直播间的qipuId
|
||||
qipuId = re.findall(r'"qipuId":(\d*?),"roomId', response)[0]
|
||||
callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000'
|
||||
params = {
|
||||
'lp': qipuId,
|
||||
'src': '01010031010000000000',
|
||||
'rateVers': 'H5_QIYI',
|
||||
'qd_v': 1,
|
||||
'callback': callback
|
||||
}
|
||||
|
||||
# ba传参iqiyi.js
|
||||
ba = '/jp/live?' + urllib.parse.urlencode(params)
|
||||
with open('iqiyi.js', 'r') as f:
|
||||
content = f.read()
|
||||
cmd5x = execjs.compile(content)
|
||||
vf = cmd5x.call('cmd5x', ba)
|
||||
|
||||
# 请求
|
||||
response = requests.get('https://live.video.iqiyi.com' + ba, params={'vf': vf}).text
|
||||
url_json = json.loads(re.findall(r'try{.*?\((.*)\);}catch\(e\){};', response)[0])
|
||||
real_url = (url_json.get('data').get('streams'))[0].get('url')
|
||||
real_url = real_url.replace('hlslive.video.iqiyi.com', 'm3u8live.video.iqiyi.com')
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
return real_url
|
||||
iqiyi = IQiYi(rid)
|
||||
return iqiyi.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
rid = input('请输入爱奇艺直播间id:\n') # 如:19732
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入爱奇艺直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
38
ixigua.py
38
ixigua.py
@ -1,22 +1,34 @@
|
||||
# 获取西瓜直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
import re
|
||||
import json
|
||||
|
||||
|
||||
class IXiGua:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
room_url = self.rid
|
||||
response = requests.get(url=room_url).text
|
||||
real_url = re.findall(r'playInfo":([\s\S]*?),"authStatus', response)[0]
|
||||
real_url = re.sub(r'\\u002F', '/', real_url)
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
room_url = rid
|
||||
response = requests.get(url=room_url).text
|
||||
real_url = re.findall(r'playInfo":([\s\S]*?),"authStatus', response)[0]
|
||||
real_url = re.sub(r'\\u002F', '/', real_url)
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
return real_url
|
||||
xg = IXiGua(rid)
|
||||
return xg.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入西瓜直播URL:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入西瓜直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
59
jd.py
59
jd.py
@ -1,31 +1,46 @@
|
||||
# 京东直播:https://h5.m.jd.com/dev/3pbY8ZuCx4ML99uttZKLHC2QcAMn/live.html?id=1807004&position=0
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def jd(rid):
|
||||
url = 'https://api.m.jd.com/client.action'
|
||||
params = {
|
||||
'functionId': 'liveDetail',
|
||||
'body': json.dumps({'id': rid, 'videoType': 1}, separators=(',', ':')),
|
||||
'client': 'wh5'
|
||||
}
|
||||
with requests.Session() as s:
|
||||
res = s.get(url, params=params).json()
|
||||
data = res.get('data', 0)
|
||||
if data:
|
||||
status = data['status']
|
||||
if status == 1:
|
||||
real_url = data['h5Pull']
|
||||
return real_url
|
||||
class JD:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://api.m.jd.com/client.action'
|
||||
params = {
|
||||
'functionId': 'liveDetail',
|
||||
'body': json.dumps({'id': self.rid, 'videoType': 1}, separators=(',', ':')),
|
||||
'client': 'wh5'
|
||||
}
|
||||
with requests.Session() as s:
|
||||
res = s.get(url, params=params).json()
|
||||
data = res.get('data', 0)
|
||||
if data:
|
||||
status = data['status']
|
||||
if status == 1:
|
||||
real_url = data['h5Pull']
|
||||
return real_url
|
||||
else:
|
||||
print('未开播')
|
||||
real_url = '回放:' + data.get('playBack').get('videoUrl', 0)
|
||||
return real_url
|
||||
else:
|
||||
print('未开播')
|
||||
real_url = '回放:' + data.get('playBack').get('videoUrl', 0)
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
jd = JD(rid)
|
||||
return jd.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入京东直播间id:\n')
|
||||
print(jd(r))
|
||||
r = input('请输入京东直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
50
kk.py
50
kk.py
@ -2,26 +2,40 @@
|
||||
import requests
|
||||
|
||||
|
||||
def kk(rid):
|
||||
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
|
||||
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(rid), 'platform': 1, 'a': 1, 'c': 100101}
|
||||
with requests.Session() as s:
|
||||
res = s.get(url.format(parameter)).json()
|
||||
tagcode = res['TagCode']
|
||||
if tagcode == '00000000':
|
||||
if res.get('liveType', 0) == 1:
|
||||
roomid = res['roomId']
|
||||
parameter = {'FuncTag': 60001002, 'roomId': roomid, 'platform': 1, 'a': 1, 'c': 100101}
|
||||
with requests.Session() as s:
|
||||
res = s.get(url.format(parameter)).json()
|
||||
real_url = res['liveStream']
|
||||
return real_url
|
||||
class KK:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
|
||||
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(self.rid), 'platform': 1, 'a': 1, 'c': 100101}
|
||||
with requests.Session() as s:
|
||||
res = s.get(url.format(parameter)).json()
|
||||
tagcode = res['TagCode']
|
||||
if tagcode == '00000000':
|
||||
if res.get('liveType', 0) == 1:
|
||||
roomid = res['roomId']
|
||||
parameter = {'FuncTag': 60001002, 'roomId': roomid, 'platform': 1, 'a': 1, 'c': 100101}
|
||||
with requests.Session() as s:
|
||||
res = s.get(url.format(parameter)).json()
|
||||
real_url = res['liveStream']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
kk = KK(rid)
|
||||
return kk.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入KK直播房间号:\n')
|
||||
print(kk(r))
|
||||
print(get_real_url(r))
|
||||
|
51
kuaishou.py
51
kuaishou.py
@ -2,28 +2,41 @@
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def kuaishou(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',
|
||||
'cookie': 'did=web_'}
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://m.gifshow.com/fw/live/{}'.format(rid), headers=headers)
|
||||
livestream = re.search(r'liveStream":(.*),"obfuseData', res.text)
|
||||
if livestream:
|
||||
livestream = json.loads(livestream.group(1))
|
||||
*_, hlsplayurls = livestream['multiResolutionHlsPlayUrls']
|
||||
urls, = hlsplayurls['urls']
|
||||
url = urls['url']
|
||||
return url
|
||||
else:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
class KuaiShou:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
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',
|
||||
'cookie': 'did=web_'}
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://m.gifshow.com/fw/live/{}'.format(self.rid), headers=headers)
|
||||
livestream = re.search(r'liveStream":(.*),"obfuseData', res.text)
|
||||
if livestream:
|
||||
livestream = json.loads(livestream.group(1))
|
||||
*_, hlsplayurls = livestream['multiResolutionHlsPlayUrls']
|
||||
urls, = hlsplayurls['urls']
|
||||
url = urls['url']
|
||||
return url
|
||||
else:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
ks = KuaiShou(rid)
|
||||
return ks.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入快手直播房间号:\n') # 例:jjworld126
|
||||
print(kuaishou(r))
|
||||
r = input('请输入快手直播房间地址:\n')
|
||||
print(get_real_url(r))
|
||||
|
35
kugou.py
35
kugou.py
@ -3,18 +3,31 @@
|
||||
import requests
|
||||
|
||||
|
||||
class KuGou:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response1 = requests.get('https://fx1.service.kugou.com/video/pc/live/pull/v3/streamaddr?roomId={}&ch=fx&version=1.0&streamType=1-2-5&platform=7&ua=fx-flash&kugouId=0&layout=1'.format(self.rid)).json()
|
||||
response2 = requests.get('https://fx1.service.kugou.com/video/mo/live/pull/h5/v3/streamaddr?roomId={}&platform=18&version=1000&streamType=3-6&liveType=1&ch=fx&ua=fx-mobile-h5&kugouId=0&layout=1'.format(self.rid)).json()
|
||||
real_url_flv = response1.get('data').get('horizontal')[0].get('httpflv')[0]
|
||||
real_url_hls = response2.get('data').get('horizontal')[0].get('httpshls')[0]
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return {"flv": real_url_flv, "hls": real_url_hls}
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
response1 = requests.get('https://fx1.service.kugou.com/video/pc/live/pull/v3/streamaddr?roomId={}&ch=fx&version=1.0&streamType=1-2-5&platform=7&ua=fx-flash&kugouId=0&layout=1'.format(rid)).json()
|
||||
response2 = requests.get('https://fx1.service.kugou.com/video/mo/live/pull/h5/v3/streamaddr?roomId={}&platform=18&version=1000&streamType=3-6&liveType=1&ch=fx&ua=fx-mobile-h5&kugouId=0&layout=1'.format(rid)).json()
|
||||
real_url_flv = response1.get('data').get('horizontal')[0].get('httpflv')[0]
|
||||
real_url_hls = response2.get('data').get('horizontal')[0].get('httpshls')[0]
|
||||
except:
|
||||
real_url_flv = real_url_hls = '直播间不存在或未开播'
|
||||
return real_url_flv, real_url_hls
|
||||
kg = KuGou(rid)
|
||||
return kg.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入酷狗直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入酷狗直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
42
kuwo.py
42
kuwo.py
@ -1,22 +1,38 @@
|
||||
# 酷我聚星直播:http://jx.kuwo.cn/
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def kuwo(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://zhiboserver.kuwo.cn/proxy.p?src=h5&cmd=enterroom&rid={}&videotype=1&auto=1'.format(rid))
|
||||
res = res.json()
|
||||
class KuWo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://zhiboserver.kuwo.cn/proxy.p?src=h5&cmd=enterroom&rid={}&videotype=1&auto=1'.format(self.rid))
|
||||
res = res.json()
|
||||
try:
|
||||
livestatus = res['room']['livestatus']
|
||||
except KeyError:
|
||||
raise Exception('房间号错误')
|
||||
if livestatus == 2:
|
||||
real_url = res['live']['url']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
livestatus = res['room']['livestatus']
|
||||
except KeyError:
|
||||
raise Exception('房间号错误')
|
||||
if livestatus == 2:
|
||||
real_url = res['live']['url']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
kw = KuWo(rid)
|
||||
return kw.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入酷我聚星直播房间号:\n')
|
||||
print(kuwo(r))
|
||||
print(get_real_url(r))
|
||||
|
||||
|
41
laifeng.py
41
laifeng.py
@ -6,21 +6,34 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
class LaiFeng:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response_main = requests.get(url='http://v.laifeng.com/{}/m'.format(self.rid)).text
|
||||
stream_name = re.findall(r"initAlias:'(.*)?'", response_main)[0]
|
||||
real_url = {}
|
||||
for stream_format in ['HttpFlv', 'Hls']:
|
||||
request_url = 'https://lapi.lcloud.laifeng.com/Play?AppId=101&StreamName={}&Action=Schedule&Version=2.0&Format={}'.format(stream_name, stream_format)
|
||||
response = requests.get(url=request_url).json()
|
||||
real_url[stream_format] = response.get(stream_format)[0].get('Url')
|
||||
except:
|
||||
raise Exception('该直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
response_main = requests.get(url='http://v.laifeng.com/{}/m'.format(rid)).text
|
||||
stream_name = re.findall(r"initAlias:'(.*)?'", response_main)[0]
|
||||
real_url = {}
|
||||
for stream_format in ['HttpFlv', 'Hls']:
|
||||
request_url = 'https://lapi.lcloud.laifeng.com/Play?AppId=101&StreamName={}&Action=Schedule&Version=2.0&Format={}'.format(stream_name, stream_format)
|
||||
response = requests.get(url=request_url).json()
|
||||
real_url[stream_format] = response.get(stream_format)[0].get('Url')
|
||||
except:
|
||||
real_url = '该直播间不存在或未开播'
|
||||
return real_url
|
||||
lf = LaiFeng(rid)
|
||||
return lf.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入来疯直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入来疯直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
67
lehai.py
67
lehai.py
@ -1,4 +1,5 @@
|
||||
# 乐嗨直播:https://www.lehaitv.com/
|
||||
|
||||
from urllib.parse import urlencode
|
||||
from urllib.parse import unquote
|
||||
import requests
|
||||
@ -6,35 +7,49 @@ import time
|
||||
import hashlib
|
||||
|
||||
|
||||
def lehai(rid):
|
||||
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(rid)
|
||||
params = {
|
||||
'_st1': int(time.time() * 1e3),
|
||||
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
|
||||
'tku': 3000006,
|
||||
}
|
||||
data = urlencode(params) + '1eha12h5'
|
||||
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
|
||||
params['_ajaxData1'] = _ajaxData1
|
||||
params['accessToken'] = unquote(params['accessToken'])
|
||||
with requests.Session() as s:
|
||||
res = s.get(url, params=params)
|
||||
if res.status_code == 200:
|
||||
res = res.json()
|
||||
statuscode = res['status']['statuscode']
|
||||
if statuscode == '0':
|
||||
if res['data']['live_status'] == '1':
|
||||
anchor, = res['data']['anchor']
|
||||
real_url = anchor['media_url']
|
||||
return real_url
|
||||
class LeHai:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(self.rid)
|
||||
params = {
|
||||
'_st1': int(time.time() * 1e3),
|
||||
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
|
||||
'tku': 3000006,
|
||||
}
|
||||
data = urlencode(params) + '1eha12h5'
|
||||
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
|
||||
params['_ajaxData1'] = _ajaxData1
|
||||
params['accessToken'] = unquote(params['accessToken'])
|
||||
with requests.Session() as s:
|
||||
res = s.get(url, params=params)
|
||||
if res.status_code == 200:
|
||||
res = res.json()
|
||||
statuscode = res['status']['statuscode']
|
||||
if statuscode == '0':
|
||||
if res['data']['live_status'] == '1':
|
||||
anchor, = res['data']['anchor']
|
||||
real_url = anchor['media_url']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
raise Exception('房间不存在 或 权限检查错误')
|
||||
else:
|
||||
raise Exception('房间不存在 或 权限检查错误')
|
||||
else:
|
||||
raise Exception('请求错误')
|
||||
raise Exception('请求错误')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
lh = LeHai(rid)
|
||||
return lh.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入乐嗨直播房间号:\n')
|
||||
print(lehai(r))
|
||||
print(get_real_url(r))
|
||||
|
35
longzhu.py
35
longzhu.py
@ -4,18 +4,31 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
class LongZhu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.get('http://m.longzhu.com/' + str(self.rid)).text
|
||||
roomId = re.findall(r'roomId = (\d*);', response)[0]
|
||||
response = requests.get('http://livestream.longzhu.com/live/getlivePlayurl?roomId={}&hostPullType=2&isAdvanced=true&playUrlsType=1'.format(roomId)).json()
|
||||
real_url = response.get('playLines')[0].get('urls')[-1].get('securityUrl')
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
response = requests.get('http://m.longzhu.com/' + str(rid)).text
|
||||
roomId = re.findall(r'roomId = (\d*);', response)[0]
|
||||
response = requests.get('http://livestream.longzhu.com/live/getlivePlayurl?roomId={}&hostPullType=2&isAdvanced=true&playUrlsType=1'.format(roomId)).json()
|
||||
real_url = response.get('playLines')[0].get('urls')[-1].get('securityUrl')
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
return real_url
|
||||
lz = LongZhu(rid)
|
||||
return lz.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入龙珠直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入龙珠直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
33
look.py
33
look.py
@ -1,21 +1,34 @@
|
||||
# 获取网易云音乐旗下look直播的真实流媒体地址。
|
||||
# look直播间链接形式:https://look.163.com/live?id=73694082
|
||||
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
class Look:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.post(url='https://look.163.com/live?id=' + self.rid).text
|
||||
real_url = re.findall(r'"liveUrl":([\s\S]*),"liveType"', response)[0]
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
response = requests.post(url='https://look.163.com/live?id=' + rid).text
|
||||
real_url = re.findall(r'"liveUrl":([\s\S]*),"liveType"', response)[0]
|
||||
except:
|
||||
real_url = '该直播间不存在或未开播'
|
||||
return real_url
|
||||
look = Look(rid)
|
||||
return look.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入look直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入Look直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
44
now.py
44
now.py
@ -1,25 +1,37 @@
|
||||
# 获取NOW直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
class Now:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
room_url = 'https://now.qq.com/cgi-bin/now/web/room/get_live_room_url?room_id={}&platform=8'.format(self.rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
result = response.get('result')
|
||||
real_url = {
|
||||
'raw_hls_url': result.get('raw_hls_url', 0),
|
||||
'raw_rtmp_url': result.get('raw_rtmp_url', 0),
|
||||
'raw_flv_url': result.get('raw_flv_url', 0)
|
||||
}
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
room_url = 'https://now.qq.com/cgi-bin/now/web/room/get_live_room_url?room_id={}&platform=8'.format(rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
result = response.get('result')
|
||||
real_url = {
|
||||
'raw_hls_url': result.get('raw_hls_url', 0),
|
||||
'raw_rtmp_url': result.get('raw_rtmp_url', 0),
|
||||
'raw_flv_url': result.get('raw_flv_url', 0)
|
||||
}
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
return real_url
|
||||
now = Now(rid)
|
||||
return now.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入NOW直播间数字ID:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入NOW直播间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
47
pps.py
47
pps.py
@ -5,24 +5,37 @@ import re
|
||||
import time
|
||||
|
||||
|
||||
class PPS:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.get('http://m-x.pps.tv/room/' + str(self.rid)).text
|
||||
anchor_id = re.findall(r'anchor_id":(\d*),"online_uid', response)[0]
|
||||
tt = int(time.time() * 1000)
|
||||
url = 'http://api-live.iqiyi.com/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)
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Referer': 'http://m-x.pps.tv/'
|
||||
}
|
||||
response = requests.get(url=url, headers=headers).text
|
||||
real_url = re.findall(r'"hls":"(.*)","rate_list', response)[0]
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
response = requests.get('http://m-x.pps.tv/room/' + str(rid)).text
|
||||
anchor_id = re.findall(r'anchor_id":(\d*),"online_uid', response)[0]
|
||||
tt = int(time.time() * 1000)
|
||||
url = 'http://api-live.iqiyi.com/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)
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Referer': 'http://m-x.pps.tv/'
|
||||
}
|
||||
response = requests.get(url=url, headers=headers).text
|
||||
real_url = re.findall(r'"hls":"(.*)","rate_list', response)[0]
|
||||
except:
|
||||
real_url = '直播间未开播或不存在'
|
||||
return real_url
|
||||
pps = PPS(rid)
|
||||
return pps.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入奇秀直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入奇秀直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
33
qf.py
33
qf.py
@ -5,17 +5,30 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
class QF:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.post(url='https://qf.56.com/' + self.rid).text
|
||||
real_url = re.findall(r"flvUrl:'(.*)\?wsSecret", response)
|
||||
real_url = real_url[0]
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
response = requests.post(url='https://qf.56.com/' + rid).text
|
||||
real_url = re.findall(r"flvUrl:'(.*)\?wsSecret", response)
|
||||
real_url = real_url[0]
|
||||
except:
|
||||
real_url = '该直播间不存在或未开播'
|
||||
return real_url
|
||||
qf = QF(rid)
|
||||
return qf.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入千帆直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入千帆直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
41
qie.py
41
qie.py
@ -1,22 +1,37 @@
|
||||
# 企鹅体育:https://live.qq.com/directory/all
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def qie(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://m.live.qq.com/' + str(rid))
|
||||
show_status = re.search(r'"show_status":"(\d)"', res.text)
|
||||
if show_status:
|
||||
if show_status.group(1) == '1':
|
||||
hls_url = re.search(r'"hls_url":"(.*)","use_p2p"', res.text).group(1)
|
||||
return hls_url
|
||||
class ESport:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://m.live.qq.com/' + str(self.rid))
|
||||
show_status = re.search(r'"show_status":"(\d)"', res.text)
|
||||
if show_status:
|
||||
if show_status.group(1) == '1':
|
||||
hls_url = re.search(r'"hls_url":"(.*)","use_p2p"', res.text).group(1)
|
||||
return hls_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
es = ESport(rid)
|
||||
return es.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入企鹅体育直播间号:\n')
|
||||
print(qie(r))
|
||||
r = input('请输入企鹅体育直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
63
renren.py
63
renren.py
@ -1,33 +1,48 @@
|
||||
# 人人直播:http://zhibo.renren.com/
|
||||
|
||||
import requests
|
||||
import re
|
||||
import hashlib
|
||||
|
||||
|
||||
def renren(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('http://activity.renren.com/liveroom/' + str(rid))
|
||||
livestate = re.search(r'"liveState":(\d)', res.text)
|
||||
if livestate:
|
||||
try:
|
||||
s = re.search(r'"playUrl":"([\s\S]*?)"', res.text).group(1)
|
||||
if livestate.group(1) == '0':
|
||||
accesskey = re.search(r'accesskey=(\w+)', s).group(1)
|
||||
expire = re.search(r'expire=(\d+)', s).group(1)
|
||||
live = re.search(r'(/live/\d+)', s).group(1)
|
||||
c = accesskey + expire + live
|
||||
key = hashlib.md5(c.encode('utf-8')).hexdigest()
|
||||
e = s.split('?')[0].split('/')[4]
|
||||
t = 'http://ksy-hls.renren.com/live/' + e + '/index.m3u8?key=' + key
|
||||
return t
|
||||
elif livestate.group(1) == '1':
|
||||
return '回放:' + s
|
||||
except IndexError:
|
||||
raise Exception('解析错误')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
class RenRen:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('http://activity.renren.com/liveroom/' + str(self.rid))
|
||||
livestate = re.search(r'"liveState":(\d)', res.text)
|
||||
if livestate:
|
||||
try:
|
||||
s = re.search(r'"playUrl":"([\s\S]*?)"', res.text).group(1)
|
||||
if livestate.group(1) == '0':
|
||||
accesskey = re.search(r'accesskey=(\w+)', s).group(1)
|
||||
expire = re.search(r'expire=(\d+)', s).group(1)
|
||||
live = re.search(r'(/live/\d+)', s).group(1)
|
||||
c = accesskey + expire + live
|
||||
key = hashlib.md5(c.encode('utf-8')).hexdigest()
|
||||
e = s.split('?')[0].split('/')[4]
|
||||
t = 'http://ksy-hls.renren.com/live/' + e + '/index.m3u8?key=' + key
|
||||
return t
|
||||
elif livestate.group(1) == '1':
|
||||
return '回放:' + s
|
||||
except IndexError:
|
||||
raise Exception('解析错误')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
rr = RenRen(rid)
|
||||
return rr.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入人人直播房间号:\n')
|
||||
print(renren(r))
|
||||
r = input('请输入人人直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
89
showself.py
89
showself.py
@ -1,49 +1,64 @@
|
||||
# 秀色直播:https://www.showself.com/
|
||||
|
||||
from urllib.parse import urlencode
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
|
||||
|
||||
def showself(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://service.showself.com/v2/custuser/visitor').json()
|
||||
uid = res['data']['uid']
|
||||
accesstoken = sessionid = res['data']['sessionid']
|
||||
params = {
|
||||
'accessToken': accesstoken,
|
||||
'tku': uid,
|
||||
'_st1': int(time.time() * 1000)
|
||||
}
|
||||
payload = {
|
||||
'groupid': '999',
|
||||
'roomid': rid,
|
||||
'sessionid': sessionid,
|
||||
'sessionId': sessionid
|
||||
}
|
||||
data = dict(params, **payload)
|
||||
data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5'
|
||||
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
|
||||
payload['_ajaxData1'] = _ajaxData1
|
||||
url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(rid, urlencode(params))
|
||||
with requests.Session() as s:
|
||||
res = s.post(url, json=payload)
|
||||
if res.status_code == 200:
|
||||
res = res.json()
|
||||
statuscode = res['status']['statuscode']
|
||||
if statuscode == '0':
|
||||
if res['data']['roomInfo']['live_status'] == '1':
|
||||
anchor, = res['data']['roomInfo']['anchor']
|
||||
real_url = anchor['media_url']
|
||||
return real_url
|
||||
class ShowSelf:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://service.showself.com/v2/custuser/visitor').json()
|
||||
uid = res['data']['uid']
|
||||
accesstoken = sessionid = res['data']['sessionid']
|
||||
params = {
|
||||
'accessToken': accesstoken,
|
||||
'tku': uid,
|
||||
'_st1': int(time.time() * 1000)
|
||||
}
|
||||
payload = {
|
||||
'groupid': '999',
|
||||
'roomid': self.rid,
|
||||
'sessionid': sessionid,
|
||||
'sessionId': sessionid
|
||||
}
|
||||
data = dict(params, **payload)
|
||||
data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5'
|
||||
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
|
||||
payload['_ajaxData1'] = _ajaxData1
|
||||
url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(self.rid, urlencode(params))
|
||||
with requests.Session() as s:
|
||||
res = s.post(url, json=payload)
|
||||
if res.status_code == 200:
|
||||
res = res.json()
|
||||
statuscode = res['status']['statuscode']
|
||||
if statuscode == '0':
|
||||
if res['data']['roomInfo']['live_status'] == '1':
|
||||
anchor, = res['data']['roomInfo']['anchor']
|
||||
real_url = anchor['media_url']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
raise Exception('房间不存在')
|
||||
else:
|
||||
raise Exception('房间不存在')
|
||||
else:
|
||||
raise Exception('参数错误')
|
||||
raise Exception('参数错误')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
ss = ShowSelf(rid)
|
||||
return ss.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入秀色直播房间号:\n')
|
||||
print(showself(r))
|
||||
rid = input('输入秀色直播房间号:\n')
|
||||
print(get_real_url(rid))
|
||||
|
41
tuho.py
41
tuho.py
@ -1,23 +1,38 @@
|
||||
# 星光直播:https://www.tuho.tv/28545037
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def tuho(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://www.tuho.tv/' + str(rid)).text
|
||||
flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res)
|
||||
if flv:
|
||||
status = re.search(r'isPlaying\s:\s(\w+),', res).group(1)
|
||||
if status == 'true':
|
||||
real_url = flv.group(1).replace('\\', '')
|
||||
return real_url
|
||||
class TuHo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://www.tuho.tv/' + str(self.rid)).text
|
||||
flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res)
|
||||
if flv:
|
||||
status = re.search(r'isPlaying\s:\s(\w+),', res).group(1)
|
||||
if status == 'true':
|
||||
real_url = flv.group(1).replace('\\', '')
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
th = TuHo(rid)
|
||||
return th.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入星光直播房间号:\n')
|
||||
print(tuho(r))
|
||||
print(get_real_url(r))
|
||||
|
42
v6cn.py
42
v6cn.py
@ -4,21 +4,35 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
class V6CN:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.get('https://v.6.cn/' + str(self.rid)).text
|
||||
result = re.findall(r'"flvtitle":"v(\d*?)-(\d*?)"', response)[0]
|
||||
uid = result[0]
|
||||
flvtitle = 'v{}-{}'.format(*result)
|
||||
response = requests.get('https://rio.6rooms.com/live/?s=' + str(uid)).text
|
||||
hip = 'https://' + re.findall(r'<watchip>(.*\.xiu123\.cn).*</watchip>', response)[0]
|
||||
real_url = [hip + '/' + flvtitle + '/playlist.m3u8', hip + '/httpflv/' + flvtitle]
|
||||
except:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
response = requests.get('https://v.6.cn/' + str(rid)).text
|
||||
result = re.findall(r'"flvtitle":"v(\d*?)-(\d*?)"', response)[0]
|
||||
uid = result[0]
|
||||
flvtitle = 'v{}-{}'.format(*result)
|
||||
response = requests.get('https://rio.6rooms.com/live/?s=' + str(uid)).text
|
||||
hip = 'https://' + re.findall(r'<watchip>(.*\.xiu123\.cn).*</watchip>', response)[0]
|
||||
real_url = [hip + '/' + flvtitle + '/playlist.m3u8', hip + '/httpflv/' + flvtitle]
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
return real_url
|
||||
v6cn = V6CN(rid)
|
||||
return v6cn.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
rid = input('请输入六间房直播ID:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入六间房直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
39
wali.py
39
wali.py
@ -1,19 +1,34 @@
|
||||
# 小米直播:https://live.wali.com/fe
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def wali(rid):
|
||||
zuid = rid.split('_')[0]
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://s.zb.mi.com/get_liveinfo?lid={}&zuid={}'.format(rid, zuid)).json()
|
||||
status = res['data']['status']
|
||||
if status == 1:
|
||||
flv = res['data']['video']['flv']
|
||||
return flv.replace('http', 'https')
|
||||
else:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
class WaLi:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
zuid = self.rid.split('_')[0]
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://s.zb.mi.com/get_liveinfo?lid={}&zuid={}'.format(self.rid, zuid)).json()
|
||||
status = res['data']['status']
|
||||
if status == 1:
|
||||
flv = res['data']['video']['flv']
|
||||
return flv.replace('http', 'https')
|
||||
else:
|
||||
raise Exception('直播间不存在或未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
wali = WaLi(rid)
|
||||
return wali.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入小米直播房间号:\n')
|
||||
print(wali(r))
|
||||
r = input('请输入小米直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
53
woxiu.py
53
woxiu.py
@ -1,27 +1,42 @@
|
||||
# 我秀直播:https://www.woxiu.com/
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def woxiu(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'
|
||||
}
|
||||
url = 'https://m.woxiu.com/index.php?action=M/Live&do=LiveInfo&room_id={}'.format(rid)
|
||||
with requests.Session() as s:
|
||||
res = s.get(url, headers=headers)
|
||||
class WoXiu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
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'
|
||||
}
|
||||
url = 'https://m.woxiu.com/index.php?action=M/Live&do=LiveInfo&room_id={}'.format(self.rid)
|
||||
with requests.Session() as s:
|
||||
res = s.get(url, headers=headers)
|
||||
try:
|
||||
res = res.json()
|
||||
except:
|
||||
raise Exception('直播间不存在')
|
||||
status = res['online']
|
||||
if status:
|
||||
live_stream = res['live_stream']
|
||||
return live_stream
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
res = res.json()
|
||||
except:
|
||||
raise Exception('直播间不存在')
|
||||
status = res['online']
|
||||
if status:
|
||||
live_stream = res['live_stream']
|
||||
return live_stream
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
wx = WoXiu(rid)
|
||||
return wx.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入我秀直播房间号:\n')
|
||||
print(woxiu(r))
|
||||
r = input('请输入我秀直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
76
xunlei.py
76
xunlei.py
@ -1,41 +1,57 @@
|
||||
# 迅雷直播:https://live.xunlei.com/global/index.html?id=0
|
||||
|
||||
import requests
|
||||
import hashlib
|
||||
import time
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
def xunlei(rid):
|
||||
url = 'https://biz-live-ssl.xunlei.com//caller'
|
||||
headers = {
|
||||
'cookie': 'appid=1002'
|
||||
}
|
||||
_t = int(time.time() * 1000)
|
||||
u = '1002'
|
||||
f = '&*%$7987321GKwq'
|
||||
params = {
|
||||
'_t': _t,
|
||||
'a': 'play',
|
||||
'c': 'room',
|
||||
'hid': 'h5-e70560ea31cc17099395c15595bdcaa1',
|
||||
'uuid': rid,
|
||||
}
|
||||
data = urlencode(params)
|
||||
p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest()
|
||||
params['sign'] = p
|
||||
with requests.Session() as s:
|
||||
res = s.get(url, params=params, headers=headers).json()
|
||||
if res['result'] == 0:
|
||||
play_status = res['data']['play_status']
|
||||
if play_status == 1:
|
||||
real_url = res['data']['data']['stream_pull_https']
|
||||
return real_url
|
||||
class XunLei:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://biz-live-ssl.xunlei.com//caller'
|
||||
headers = {
|
||||
'cookie': 'appid=1002'
|
||||
}
|
||||
_t = int(time.time() * 1000)
|
||||
u = '1002'
|
||||
f = '&*%$7987321GKwq'
|
||||
params = {
|
||||
'_t': _t,
|
||||
'a': 'play',
|
||||
'c': 'room',
|
||||
'hid': 'h5-e70560ea31cc17099395c15595bdcaa1',
|
||||
'uuid': self.rid,
|
||||
}
|
||||
data = urlencode(params)
|
||||
p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest()
|
||||
params['sign'] = p
|
||||
with requests.Session() as s:
|
||||
res = s.get(url, params=params, headers=headers).json()
|
||||
if res['result'] == 0:
|
||||
play_status = res['data']['play_status']
|
||||
if play_status == 1:
|
||||
real_url = res['data']['data']['stream_pull_https']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间可能不存在')
|
||||
raise Exception('直播间可能不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
xl = XunLei(rid)
|
||||
return xl.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入迅雷直播房间号:\n')
|
||||
print(xunlei(r))
|
||||
r = input('请输入迅雷直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
73
yizhibo.py
73
yizhibo.py
@ -1,41 +1,50 @@
|
||||
# 获取一直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(room_url):
|
||||
class YiZhiBo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
scid = re.findall(r'/l/(\S*).html', self.rid)[0]
|
||||
flvurl = 'http://alcdn.f01.xiaoka.tv/live/{}.flv'.format(scid)
|
||||
m3u8url = 'http://al01.alcdn.hls.xiaoka.tv/live/{}.m3u8'.format(scid)
|
||||
rtmpurl = 'rtmp://alcdn.r01.xiaoka.tv/live/live/{}'.format(scid)
|
||||
real_url = {
|
||||
'flvurl': flvurl,
|
||||
'm3u8url': m3u8url,
|
||||
'rtmpurl': rtmpurl
|
||||
}
|
||||
except:
|
||||
raise Exception('链接错误')
|
||||
return real_url
|
||||
|
||||
def get_status(self):
|
||||
try:
|
||||
scid = re.findall(r'/l/(\S*).html', self.rid)[0]
|
||||
response = requests.get(
|
||||
url='https://m.yizhibo.com/www/live/get_live_video?scid=' + str(scid)).json()
|
||||
status_code = response.get('data').get('info').get('status')
|
||||
status = '直播中' if status_code == 10 else '未开播'
|
||||
except:
|
||||
raise Exception('链接错误')
|
||||
return status
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
scid = re.findall(r'/l/(\S*).html', room_url)[0]
|
||||
flvurl = 'http://alcdn.f01.xiaoka.tv/live/{}.flv'.format(scid)
|
||||
m3u8url = 'http://al01.alcdn.hls.xiaoka.tv/live/{}.m3u8'.format(scid)
|
||||
rtmpurl = 'rtmp://alcdn.r01.xiaoka.tv/live/live/{}'.format(scid)
|
||||
real_url = {
|
||||
'flvurl': flvurl,
|
||||
'm3u8url': m3u8url,
|
||||
'rtmpurl': rtmpurl
|
||||
}
|
||||
except:
|
||||
real_url = '链接错误'
|
||||
return real_url
|
||||
yzb = YiZhiBo(rid)
|
||||
return yzb.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
def get_status(room_url):
|
||||
try:
|
||||
scid = re.findall(r'/l/(\S*).html', room_url)[0]
|
||||
response = requests.get(
|
||||
url='https://m.yizhibo.com/www/live/get_live_video?scid=' + str(scid)).json()
|
||||
status_code = response.get('data').get('info').get('status')
|
||||
status = '直播中' if status_code == 10 else '未开播'
|
||||
except:
|
||||
status = '链接错误'
|
||||
return status
|
||||
|
||||
|
||||
rid = input('请输入一直播房间地址:\n')
|
||||
status = get_status(rid)
|
||||
print('当前直播状态', status)
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入一直播房间地址:\n')
|
||||
print(get_real_url(r))
|
||||
|
61
youku.py
61
youku.py
@ -3,36 +3,51 @@
|
||||
# 而且没有平台水印和主播自己贴的乱七八糟的字幕遮挡。
|
||||
# liveId 是如下形式直播间链接:
|
||||
# “https://vku.youku.com/live/ilproom?spm=a2hcb.20025885.m_16249_c_59932.d_11&id=8019610&scm=20140670.rcmd.16249.live_8019610”中的8019610字段。
|
||||
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
|
||||
def youku(liveid):
|
||||
class YouKu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
tt = str(int(time.time() * 1000))
|
||||
data = json.dumps({'liveId': self.rid, 'app': 'Pc'}, separators=(',', ':'))
|
||||
url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788'
|
||||
s = requests.Session()
|
||||
cookies = s.get(url).cookies
|
||||
token = requests.utils.dict_from_cookiejar(cookies).get('_m_h5_tk')[0:32]
|
||||
sign = hashlib.md5((token + '&' + tt + '&' + '24679788' + '&' + data).encode('utf-8')).hexdigest()
|
||||
params = {
|
||||
't': tt,
|
||||
'sign': sign,
|
||||
'data': data
|
||||
}
|
||||
response = s.get(url, params=params).json()
|
||||
# name = response.get('data').get('data').get('name')
|
||||
streamname = response.get('data').get('data').get('stream')[0].get('streamName')
|
||||
real_url = 'http://lvo-live.youku.com/vod2live/{}_mp4hd2v3.m3u8?&expire=21600&psid=1&ups_ts={}&vkey='.format(
|
||||
streamname, int(time.time()))
|
||||
except:
|
||||
raise Exception('请求错误')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
tt = str(int(time.time() * 1000))
|
||||
data = json.dumps({'liveId': liveid, 'app': 'Pc'}, separators=(',', ':'))
|
||||
url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788'
|
||||
s = requests.Session()
|
||||
cookies = s.get(url).cookies
|
||||
token = requests.utils.dict_from_cookiejar(cookies).get('_m_h5_tk')[0:32]
|
||||
sign = hashlib.md5((token + '&' + tt + '&' + '24679788' + '&' + data).encode('utf-8')).hexdigest()
|
||||
params = {
|
||||
't': tt,
|
||||
'sign': sign,
|
||||
'data': data
|
||||
}
|
||||
response = s.get(url, params=params).json()
|
||||
# name = response.get('data').get('data').get('name')
|
||||
streamname = response.get('data').get('data').get('stream')[0].get('streamName')
|
||||
real_url = 'http://lvo-live.youku.com/vod2live/{}_mp4hd2v3.m3u8?&expire=21600&psid=1&ups_ts={}&vkey='.format(
|
||||
streamname, int(time.time()))
|
||||
except:
|
||||
real_url = '请求错误'
|
||||
return real_url
|
||||
yk = YouKu(rid)
|
||||
return yk.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入优酷轮播台liveId:\n')
|
||||
print(youku(r))
|
||||
r = input('请输入优酷轮播台房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
40
yuanbobo.py
40
yuanbobo.py
@ -3,21 +3,35 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
def yuanbobo(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://zhibo.yuanbobo.com/' + str(rid)).text
|
||||
stream_id = re.search(r"stream_id:\s+'(\d+)'", res)
|
||||
if stream_id:
|
||||
status = re.search(r"status:\s+'(\d)'", res).group(1)
|
||||
if status == '1':
|
||||
real_url = 'http://ks-hlslive.yuanbobo.com/live/{}/index.m3u8'.format(stream_id.group(1))
|
||||
return real_url
|
||||
class YuanBoBo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://zhibo.yuanbobo.com/' + str(self.rid)).text
|
||||
stream_id = re.search(r"stream_id:\s+'(\d+)'", res)
|
||||
if stream_id:
|
||||
status = re.search(r"status:\s+'(\d)'", res).group(1)
|
||||
if status == '1':
|
||||
real_url = 'http://ks-hlslive.yuanbobo.com/live/{}/index.m3u8'.format(stream_id.group(1))
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
th = YuanBoBo(rid)
|
||||
return th.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入热猫直播房间号:\n')
|
||||
print(yuanbobo(r))
|
||||
print(get_real_url(r))
|
||||
|
61
yy.py
61
yy.py
@ -1,35 +1,50 @@
|
||||
# 获取YY直播的真实流媒体地址。https://www.yy.com/1349606469
|
||||
# 默认获取最高画质
|
||||
|
||||
import requests
|
||||
import re
|
||||
import json
|
||||
|
||||
|
||||
def yy(rid):
|
||||
headers = {
|
||||
'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=rid),
|
||||
'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'
|
||||
}
|
||||
room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=rid)
|
||||
with requests.Session() as s:
|
||||
res = s.get(room_url, headers=headers)
|
||||
if res.status_code == 200:
|
||||
data = json.loads(res.text[1:-1])
|
||||
if data.get('hls', 0):
|
||||
xa = data['audio']
|
||||
xv = data['video']
|
||||
xv = re.sub(r'0_\d+_0', '0_0_0', xv)
|
||||
url = 'https://interface.yy.com/hls/get/stream/15013/{}/15013/{}?source=h5player&type=m3u8'.format(xv, xa)
|
||||
res = s.get(url).json()
|
||||
real_url = res['hls']
|
||||
return real_url
|
||||
class YY:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
headers = {
|
||||
'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=self.rid),
|
||||
'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'
|
||||
}
|
||||
room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=self.rid)
|
||||
with requests.Session() as s:
|
||||
res = s.get(room_url, headers=headers)
|
||||
if res.status_code == 200:
|
||||
data = json.loads(res.text[1:-1])
|
||||
if data.get('hls', 0):
|
||||
xa = data['audio']
|
||||
xv = data['video']
|
||||
xv = re.sub(r'0_\d+_0', '0_0_0', xv)
|
||||
url = 'https://interface.yy.com/hls/get/stream/15013/{}/15013/{}?source=h5player&type=m3u8'.format(xv, xa)
|
||||
res = s.get(url).json()
|
||||
real_url = res['hls']
|
||||
return real_url
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
else:
|
||||
raise Exception('直播间不存在')
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
yy = YY(rid)
|
||||
return yy.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入YY直播房间号:\n')
|
||||
print(yy(r))
|
||||
print(get_real_url(r))
|
||||
|
46
zhanqi.py
46
zhanqi.py
@ -3,23 +3,37 @@
|
||||
import requests
|
||||
|
||||
|
||||
def zhanqi(rid):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(rid))
|
||||
try:
|
||||
res = res.json()
|
||||
videoid = res['data']['videoId']
|
||||
status = res['data']['status']
|
||||
if status == '4':
|
||||
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
|
||||
real_url = s.get(url).text
|
||||
else:
|
||||
real_url = '未开播'
|
||||
except:
|
||||
real_url = '直播间不存在'
|
||||
return real_url
|
||||
class ZhanQi:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
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))
|
||||
try:
|
||||
res = res.json()
|
||||
videoid = res['data']['videoId']
|
||||
status = res['data']['status']
|
||||
if status == '4':
|
||||
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
|
||||
real_url = s.get(url).text
|
||||
else:
|
||||
raise Exception('未开播')
|
||||
except:
|
||||
raise Exception('直播间不存在')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
zq = ZhanQi(rid)
|
||||
return zq.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入战旗直播房间号:\n')
|
||||
print(zhanqi(r))
|
||||
print(get_real_url(r))
|
||||
|
Loading…
x
Reference in New Issue
Block a user