1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-07-24 17:41:45 +08:00

所有链接获取方式改为面向对象; 无链接时以返回异常的形式,统一接口进行处理;代码格式化;

This commit is contained in:
parzulpan 2020-09-03 22:50:38 +08:00
parent c4ab4dfb71
commit c489e88590
48 changed files with 1645 additions and 978 deletions

22
173.py
View File

@ -1,9 +1,15 @@
# 艺气山直播http://www.173.com/room/category?categoryId=11 # 艺气山直播http://www.173.com/room/category?categoryId=11
import requests import requests
def _173(rid): class YQS:
params = 'roomId={}&format=m3u8'.format(rid)
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
params = 'roomId={}&format=m3u8'.format(self.rid)
with requests.Session() as s: with requests.Session() as s:
res = s.post('http://www.173.com/room/getVieoUrl', params=params).json() res = s.post('http://www.173.com/room/getVieoUrl', params=params).json()
data = res['data'] data = res['data']
@ -17,6 +23,16 @@ def _173(rid):
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__': if __name__ == '__main__':
r = input('输入艺气山直播房间号:\n') r = input('输入艺气山直播房间号:\n')
print(_173(r)) print(get_real_url(r))

View File

@ -4,18 +4,31 @@
import requests import requests
def get_real_url(rid): class Live17:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
response = requests.get(url='https://api-dsa.17app.co/api/v1/lives/' + rid).json() 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_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_modify = real_url_default.replace('global-pull-rtmp.17app.co', 'china-pull-rtmp-17.tigafocus.com')
real_url = [real_url_modify, real_url_default] real_url = [real_url_modify, real_url_default]
except: except:
real_url = '该直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入17直播房间号\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') live17 = Live17(rid)
print(real_url) return live17.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入17直播房间号\n')
print(get_real_url(r))

22
2cq.py
View File

@ -1,10 +1,16 @@
# 棉花糖直播https://www.2cq.com/rank # 棉花糖直播https://www.2cq.com/rank
import requests import requests
def mht(rid): class MHT:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://www.2cq.com/proxy/room/room/info?roomId={}&appId=1004'.format(rid)) res = s.get('https://www.2cq.com/proxy/room/room/info?roomId={}&appId=1004'.format(self.rid))
res = res.json() res = res.json()
if res['status'] == 1: if res['status'] == 1:
result = res['result'] result = res['result']
@ -17,6 +23,16 @@ def mht(rid):
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__': if __name__ == '__main__':
r = input('输入棉花糖直播房间号:\n') r = input('输入棉花糖直播房间号:\n')
print(mht(r)) print(get_real_url(r))

21
51lm.py
View File

@ -1,12 +1,18 @@
# 羚萌直播https://live.51lm.tv/programs/Hot # 羚萌直播https://live.51lm.tv/programs/Hot
from urllib.parse import urlencode from urllib.parse import urlencode
import requests import requests
import time import time
import hashlib import hashlib
def lm(rid): class LM:
roominfo = {'programId': rid}
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
roominfo = {'programId': self.rid}
def g(d): def g(d):
return hashlib.md5((d + '#' + urlencode(roominfo) + '#Ogvbm2ZiKE').encode('utf-8')).hexdigest() return hashlib.md5((d + '#' + urlencode(roominfo) + '#Ogvbm2ZiKE').encode('utf-8')).hexdigest()
@ -38,6 +44,15 @@ def lm(rid):
raise Exception('直播间不存在') 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__': if __name__ == '__main__':
r = input('输入羚萌直播房间号:\n') r = input('输入羚萌直播房间号:\n')
print(lm(r)) print(get_real_url(r))

View File

@ -1,11 +1,17 @@
# 95秀http://www.95.cn/ # 95秀http://www.95.cn/
import requests import requests
import re import re
def jwxiu(rid): class JWXiu:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('http://www.95.cn/{}.html'.format(rid)).text res = s.get('http://www.95.cn/{}.html'.format(self.rid)).text
try: try:
uid = re.search(r'"uid":(\d+),', res).group(1) uid = re.search(r'"uid":(\d+),', res).group(1)
status = re.search(r'"is_offline":"(\d)"', res).group(1) status = re.search(r'"is_offline":"(\d)"', res).group(1)
@ -18,6 +24,16 @@ def jwxiu(rid):
raise Exception('未开播') raise Exception('未开播')
def get_real_url(rid):
try:
jwx = JWXiu(rid)
return jwx.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__': if __name__ == '__main__':
r = input('输入95秀房间号\n') r = input('输入95秀房间号\n')
print(jwxiu(r)) print(get_real_url(r))

21
9xiu.py
View File

@ -1,10 +1,16 @@
# 九秀直播https://www.9xiu.com/other/classify?tag=all&index=all # 九秀直播https://www.9xiu.com/other/classify?tag=all&index=all
import requests import requests
def j_xiu(rid): class JXiu:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str(rid) url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str( self.rid)
headers = { headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) ' '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' 'AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
@ -21,6 +27,15 @@ def j_xiu(rid):
raise Exception('直播间可能不存在') 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__': if __name__ == '__main__':
r = input('输入九秀直播房间号:\n') r = input('输入九秀直播房间号:\n')
print(j_xiu(r)) print(get_real_url(r))

View File

@ -1,10 +1,16 @@
# AcFun直播https://live.acfun.cn/ # AcFun直播https://live.acfun.cn/
# 默认最高画质 # 默认最高画质
import requests import requests
import json import json
def acfun(rid): class AcFun:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
headers = { headers = {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
'cookie': '_did=H5_', 'cookie': '_did=H5_',
@ -26,7 +32,7 @@ def acfun(rid):
'did': 'H5_', 'did': 'H5_',
'acfun.api.visitor_st': visitor_st 'acfun.api.visitor_st': visitor_st
} }
data = 'authorId={}&pullStreamType=FLV'.format(rid) data = 'authorId={}&pullStreamType=FLV'.format(self.rid)
res = s.post(url, params=params, data=data, headers=headers).json() res = s.post(url, params=params, data=data, headers=headers).json()
if res['result'] == 1: if res['result'] == 1:
data = res['data'] data = res['data']
@ -40,6 +46,16 @@ def acfun(rid):
raise Exception('直播已关闭') 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__': if __name__ == '__main__':
r = input('输入AcFun直播间号\n') r = input('请输入AcFun直播房间号\n')
print(acfun(r)) print(get_real_url(r))

View File

@ -6,9 +6,14 @@
import requests import requests
def bilibili(rid): class BiliBili:
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(rid) r_url = 'https://api.live.bilibili.com/room/v1/Room/room_init?id={}'.format(self.rid)
with requests.Session() as s: with requests.Session() as s:
res = s.get(r_url).json() res = s.get(r_url).json()
code = res['code'] code = res['code']
@ -45,6 +50,15 @@ def bilibili(rid):
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__': if __name__ == '__main__':
r = input('输入bilibili直播间号\n') r = input('输入bilibili直播间号:\n')
print(bilibili(r)) print(get_real_url(r))

32
cc.py
View File

@ -1,26 +1,40 @@
# 获取网易CC的真实流媒体地址。 # 获取网易CC的真实流媒体地址。
# 默认为最高画质 # 默认为最高画质
import requests import requests
def get_real_url(rid): class CC:
room_url = 'https://api.cc.163.com/v1/activitylives/anchor/lives?anchor_ccid=' + str(rid)
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() response = requests.get(url=room_url).json()
data = response.get('data', 0) data = response.get('data', 0)
if data: if data:
channel_id = data.get('{}'.format(rid)).get('channel_id', 0) channel_id = data.get('{}'.format(self.rid)).get('channel_id', 0)
if channel_id: if channel_id:
response = requests.get('https://cc.163.com/live/channel/?channelids=' + str(channel_id)).json() response = requests.get('https://cc.163.com/live/channel/?channelids=' + str(channel_id)).json()
real_url = response.get('data')[0].get('sharefile') real_url = response.get('data')[0].get('sharefile')
else: else:
real_url = '直播间不存在' raise Exception('直播间不存在')
else: else:
real_url = '输入错误' raise Exception('输入错误')
return real_url return real_url
rid = input('请输入网易CC直播房间号\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:\n' + real_url) 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))

View File

@ -1,12 +1,16 @@
# 获取触手直播的真实流媒体地址。 # 获取触手直播的真实流媒体地址。
import requests import requests
def get_real_url(rid): class ChuShou:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
room_url = 'https://chushou.tv/h5player/video/get-play-url.htm?roomId={}&protocols=2&callback='.format(rid) 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() response = requests.get(url=room_url).json()
data = response.get('data')[0] data = response.get('data')[0]
real_url = { real_url = {
@ -15,11 +19,20 @@ def get_real_url(rid):
'shdPlayUrl': data.get('shdPlayUrl', 0) 'shdPlayUrl': data.get('shdPlayUrl', 0)
} }
except: except:
real_url = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入触手直播间数字ID\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播源地址为:') cs = ChuShou(rid)
print(real_url) return cs.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入触手直播房间号:\n')
print(get_real_url(r))

View File

@ -2,28 +2,40 @@
# 如果知道该直播间如“6779127643792280332”形式的room_id则直接传入room_id。 # 如果知道该直播间如“6779127643792280332”形式的room_id则直接传入room_id。
# 如果不知道room_id可以使用手机上打开直播间后选择“分享--复制链接”传入如“https://v.douyin.com/qyRqMp/”形式的分享链接。 # 如果不知道room_id可以使用手机上打开直播间后选择“分享--复制链接”传入如“https://v.douyin.com/qyRqMp/”形式的分享链接。
import requests import requests
import re import re
def get_real_url(rid): class DouYin:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
if 'v.douyin.com' in rid: if 'v.douyin.com' in self.rid:
room_id = re.findall(r'(\d{19})', requests.get(url=rid).url)[0] room_id = re.findall(r'(\d{19})', requests.get(url=self.rid).url)[0]
else: else:
room_id = rid room_id = self.rid
room_url = 'https://webcast-hl.amemv.com/webcast/room/reflow/info/?room_id={}&live_id=1'.format(room_id) 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() response = requests.get(url=room_url).json()
hls_pull_url = response.get('data').get('room').get('stream_url').get('hls_pull_url') 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') rtmp_pull_url = response.get('data').get('room').get('stream_url').get('rtmp_pull_url')
real_url = [rtmp_pull_url, hls_pull_url] real_url = [rtmp_pull_url, hls_pull_url]
except: except:
real_url = '直播间不存在或未开播或参数错误' raise Exception('直播间不存在或未开播或参数错误')
return real_url return real_url
rid = input('请输入抖音直播间room_id或分享链接\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') dy = DouYin(rid)
print(real_url) return dy.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入抖音直播间room_id或分享链接\n')
print(get_real_url(r))

View File

@ -1,4 +1,5 @@
# 获取斗鱼直播间的真实流媒体地址,默认最高画质。 # 获取斗鱼直播间的真实流媒体地址,默认最高画质。
import requests import requests
import re import re
import execjs import execjs
@ -74,7 +75,7 @@ class DouYu:
def get_real_url(self): def get_real_url(self):
error, key = self.get_pre() error, key = self.get_pre()
if error == 0: if error == 0:
pass raise Exception('未知错误')
elif error == 102: elif error == 102:
raise Exception('房间不存在') raise Exception('房间不存在')
elif error == 104: elif error == 104:
@ -85,7 +86,15 @@ class DouYu:
return "http://tx2play1.douyucdn.cn/live/{}.flv?uuid=".format(key) 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__': if __name__ == '__main__':
r = input('输入斗鱼直播间号:\n') r = input('输入斗鱼直播间号:\n')
s = DouYu(r) print(get_real_url(r))
print(s.get_real_url())

View File

@ -1,16 +1,20 @@
# 获取企鹅电竞的真实流媒体地址。 # 获取企鹅电竞的真实流媒体地址。
# 默认画质为超清 # 默认画质为超清
import requests import requests
import json
import re import re
def get_real_url(rid): 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' room_url = 'https://share.egame.qq.com/cgi-bin/pgg_async_fcgi'
post_data = { 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}}}''' '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: try:
response = requests.post(url=room_url, data=post_data).json() response = requests.post(url=room_url, data=post_data).json()
@ -27,16 +31,25 @@ def get_real_url(rid):
0].get('play_url') 0].get('play_url')
real_url = re.findall(r'([\w\W]+?)&uid=', play_url)[0] real_url = re.findall(r'([\w\W]+?)&uid=', play_url)[0]
else: else:
real_url = '直播间未开播' raise Exception('直播间未开播')
else: else:
real_url = '直播间未启用' raise Exception('直播间未启用')
else: else:
real_url = '直播间不存在' raise Exception('直播间不存在')
except: except:
real_url = '数据请求错误' raise Exception('数据请求错误')
return real_url return real_url
rid = input('请输入企鹅电竞房间号:\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:\n' + real_url) 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))

View File

@ -1,5 +1,6 @@
# 新浪疯播直播http://www.fengbolive.com/list?type=hot # 新浪疯播直播http://www.fengbolive.com/list?type=hot
# 链接样式http://www.fengbolive.com/live/88057518 # 链接样式http://www.fengbolive.com/live/88057518
from Crypto.Cipher import AES from Crypto.Cipher import AES
from urllib.parse import unquote from urllib.parse import unquote
import base64 import base64
@ -7,9 +8,14 @@ import json
import requests import requests
def fengbo(rid): class FengBo:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(rid)).json() res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(self.rid)).json()
if res['ret'] == 1: if res['ret'] == 1:
info = res['info'] info = res['info']
info = unquote(info, 'utf-8') info = unquote(info, 'utf-8')
@ -33,6 +39,15 @@ def fengbo(rid):
raise Exception('房间号错误') 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__': if __name__ == '__main__':
r = input('输入疯播直播房间号:\n') r = input('输入疯播直播房间号:\n')
print(fengbo(r)) print(get_real_url(r))

View File

@ -1,6 +1,7 @@
# 红人直播https://www.hongle.tv/ # 红人直播https://www.hongle.tv/
# 该平台需登陆,下面代码中已集成一个账号的登陆方式; # 该平台需登陆,下面代码中已集成一个账号的登陆方式;
# 如登陆信息过期可用自己的账号登陆后查找浏览器Local Storage中的hrtk字段替换代码中的accesstoken # 如登陆信息过期可用自己的账号登陆后查找浏览器Local Storage中的hrtk字段替换代码中的accesstoken
from urllib.parse import urlencode from urllib.parse import urlencode
from urllib.parse import unquote from urllib.parse import unquote
import requests import requests
@ -9,7 +10,12 @@ import hashlib
import json import json
def hongle(rid): class HongLe:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
# 模拟登陆 # 模拟登陆
with requests.Session() as s: with requests.Session() as s:
pass pass
@ -43,7 +49,7 @@ def hongle(rid):
'_st1': tt, '_st1': tt,
'accessToken': accesstoken, 'accessToken': accesstoken,
'of': 1, 'of': 1,
'showid': rid, 'showid': self.rid,
'tku': 43112608, 'tku': 43112608,
} }
data = urlencode(params) + 'yuj1ah5o' data = urlencode(params) + 'yuj1ah5o'
@ -69,6 +75,15 @@ def hongle(rid):
raise Exception('参数错误') 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__': if __name__ == '__main__':
r = input('输入红人直播房间号:\n') r = input('输入红人直播房间号:\n')
print(hongle(r)) print(get_real_url(r))

View File

@ -1,21 +1,34 @@
# 获取花椒直播的真实流媒体地址。 # 获取花椒直播的真实流媒体地址。
import requests import requests
import time import time
def get_real_url(rid): class HuaJiao:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
tt = str(time.time()) tt = str(time.time())
try: try:
room_url = 'https://h.huajiao.com/api/getFeedInfo?sid={tt}&liveid={rid}'.format(tt=tt, rid=rid) 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() response = requests.get(url=room_url).json()
real_url = response.get('data').get('live').get('main') real_url = response.get('data').get('live').get('main')
except: except:
real_url = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入花椒直播间号:\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播源地址为:\n' + real_url) hj = HuaJiao(rid)
return hj.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入花椒直播房间号:\n')
print(get_real_url(r))

View File

@ -3,19 +3,24 @@
# 实际上使用http://live-lx-hdl.huomaotv.cn/live/qvCESZ?token=44a7f115f0af496e268bcbb7cdbb63b1,即可播放 # 实际上使用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 # 链接中lx可替换cdn(lx,tx,ws,js,jd2等),媒体类型可为.flv或.m3u8,码率可为BL8M,BL4M,TD,BD,HD,SD
import requests import requests
import time import time
import hashlib import hashlib
import re import re
def get_time(): class HuoMao:
def __init__(self, rid):
self.rid = rid
@staticmethod
def get_time():
tt = str(int((time.time() * 1000))) tt = str(int((time.time() * 1000)))
return tt return tt
@staticmethod
def get_videoids(rid): def get_videoids(rid):
room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid) room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid)
response = requests.get(url=room_url).text response = requests.get(url=room_url).text
try: try:
@ -24,18 +29,17 @@ def get_videoids(rid):
videoids = 0 videoids = 0
return videoids return videoids
@staticmethod
def get_token(videoids, time): def get_token(videoids, time):
token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) + token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) +
'6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest() '6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest()
return token return token
def get_real_url(self):
def get_real_url(rid): videoids = self.get_videoids(self.rid)
videoids = get_videoids(rid)
if videoids: if videoids:
time = get_time() time = self.get_time()
token = get_token(videoids, time) token = self.get_token(videoids, time)
room_url = 'https://www.huomao.com/swf/live_data' room_url = 'https://www.huomao.com/swf/live_data'
post_data = { post_data = {
'cdns': 1, 'cdns': 1,
@ -52,13 +56,21 @@ def get_real_url(rid):
real_url_m3u8 = response.get('streamList')[-1].get('list_hls')[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', '')] real_url = [real_url_flv, real_url_m3u8.replace('_480', '')]
else: else:
real_url = '直播间未开播' raise Exception('直播间未开播')
else: else:
real_url = '直播间不存在' raise Exception('直播间不存在')
return real_url return real_url
rid = input('请输入火猫直播房间号:\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') hm = HuoMao(rid)
print(real_url) return hm.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入火猫直播房间号:\n')
print(get_real_url(r))

71
huya.py
View File

@ -1,5 +1,6 @@
# 获取虎牙直播的真实流媒体地址。 # 获取虎牙直播的真实流媒体地址。
# 虎牙"一起看"频道的直播间可能会卡顿 # 虎牙"一起看"频道的直播间可能会卡顿
import requests import requests
import re import re
import base64 import base64
@ -8,7 +9,41 @@ import hashlib
import time import time
def live(e): class HuYa:
def __init__(self, rid):
self.rid = rid
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:
raise Exception('未开播或直播间不存在')
except Exception as e:
raise Exception('未开播或直播间不存在')
return real_url
@staticmethod
def live(e):
i, b = e.split('?') i, b = e.split('?')
r = i.split('/') r = i.split('/')
s = re.sub(r'.(flv|m3u8)', '', r[-1]) s = re.sub(r'.(flv|m3u8)', '', r[-1])
@ -28,33 +63,15 @@ def live(e):
return url return url
def huya(room_id): def get_real_url(rid):
try: try:
room_url = 'https://m.huya.com/' + str(room_id) hy = HuYa(rid)
header = { return hy.get_real_url()
'Content-Type': 'application/x-www-form-urlencoded', except Exception as e:
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 ' print('Exception', e)
'(KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36 ' return False
}
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
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
if __name__ == '__main__': if __name__ == '__main__':
rid = input('输入虎牙直播间号:\n') rid = input('输入虎牙直播房间号:\n')
print(huya(rid)) print(get_real_url(rid))

View File

@ -1,11 +1,17 @@
# 艾米直播https://www.imifun.com/ # 艾米直播https://www.imifun.com/
import requests import requests
import re import re
def imifun(rid): class IMFun:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://www.imifun.com/' + str(rid)).text res = s.get('https://www.imifun.com/' + str(self.rid)).text
roomid = re.search(r"roomId:\s'([\w-]+)'", res) roomid = re.search(r"roomId:\s'([\w-]+)'", res)
if roomid: if roomid:
status = re.search(r"isLive:(\d),", res).group(1) status = re.search(r"isLive:(\d),", res).group(1)
@ -18,6 +24,15 @@ def imifun(rid):
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__': if __name__ == '__main__':
r = input('输入艾米直播房间号:\n') r = input('输入艾米直播房间号:\n')
print(imifun(r)) print(get_real_url(r))

View File

@ -1,10 +1,14 @@
import requests import requests
def immomo(rid): class ImMoMo:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos' url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos'
data = { data = {
'stid': rid, 'stid': self.rid,
'src': 'url' 'src': 'url'
} }
@ -24,8 +28,16 @@ def immomo(rid):
raise Exception('未开播') raise Exception('未开播')
if __name__ == '__main__': def get_real_url(rid):
r = input('输入陌陌直播房间号:\n') try:
print(immomo(r)) mm = ImMoMo(rid)
return mm.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入陌陌直播房间号:\n')
print(get_real_url(r))
# https://web.immomo.com/live/337033339

28
inke.py
View File

@ -1,12 +1,16 @@
# 获取映客直播的真实流媒体地址。 # 获取映客直播的真实流媒体地址。
import requests import requests
def get_real_url(rid): class InKe:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
room_url = 'https://webapi.busi.inke.cn/web/live_share_pc?uid=' + str(rid) room_url = 'https://webapi.busi.inke.cn/web/live_share_pc?uid=' + str(self.rid)
response = requests.get(url=room_url).json() response = requests.get(url=room_url).json()
record_url = response.get('data').get('file').get('record_url') record_url = response.get('data').get('file').get('record_url')
stream_addr = response.get('data').get('live_addr') stream_addr = response.get('data').get('live_addr')
@ -15,11 +19,19 @@ def get_real_url(rid):
'stream_addr': stream_addr 'stream_addr': stream_addr
} }
except: except:
real_url = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入映客直播间uid\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播源地址为:') inke = InKe(rid)
print(real_url) return inke.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入映客直播房间号:\n')
print(get_real_url(r))

View File

@ -9,9 +9,14 @@ import time
import urllib.parse import urllib.parse
def get_real_url(rid): class IQiYi:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
response = requests.get('https://m-gamelive.iqiyi.com/w/' + rid).text response = requests.get('https://m-gamelive.iqiyi.com/w/' + self.rid).text
# 获取直播间的qipuId # 获取直播间的qipuId
qipuId = re.findall(r'"qipuId":(\d*?),"roomId', response)[0] qipuId = re.findall(r'"qipuId":(\d*?),"roomId', response)[0]
callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000' callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000'
@ -36,12 +41,19 @@ def get_real_url(rid):
real_url = (url_json.get('data').get('streams'))[0].get('url') real_url = (url_json.get('data').get('streams'))[0].get('url')
real_url = real_url.replace('hlslive.video.iqiyi.com', 'm3u8live.video.iqiyi.com') real_url = real_url.replace('hlslive.video.iqiyi.com', 'm3u8live.video.iqiyi.com')
except: except:
real_url = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
def get_real_url(rid):
try:
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) if __name__ == '__main__':
print('该直播间源地址为:') r = input('请输入爱奇艺直播房间号:\n')
print(real_url) print(get_real_url(r))

View File

@ -1,22 +1,34 @@
# 获取西瓜直播的真实流媒体地址。 # 获取西瓜直播的真实流媒体地址。
import requests import requests
import re import re
import json
def get_real_url(rid):
class IXiGua:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
room_url = rid room_url = self.rid
response = requests.get(url=room_url).text response = requests.get(url=room_url).text
real_url = re.findall(r'playInfo":([\s\S]*?),"authStatus', response)[0] real_url = re.findall(r'playInfo":([\s\S]*?),"authStatus', response)[0]
real_url = re.sub(r'\\u002F', '/', real_url) real_url = re.sub(r'\\u002F', '/', real_url)
except: except:
real_url = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入西瓜直播URL\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播源地址为:') xg = IXiGua(rid)
print(real_url) return xg.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入西瓜直播房间号:\n')
print(get_real_url(r))

23
jd.py
View File

@ -1,13 +1,19 @@
# 京东直播https://h5.m.jd.com/dev/3pbY8ZuCx4ML99uttZKLHC2QcAMn/live.html?id=1807004&position=0 # 京东直播https://h5.m.jd.com/dev/3pbY8ZuCx4ML99uttZKLHC2QcAMn/live.html?id=1807004&position=0
import requests import requests
import json import json
def jd(rid): class JD:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
url = 'https://api.m.jd.com/client.action' url = 'https://api.m.jd.com/client.action'
params = { params = {
'functionId': 'liveDetail', 'functionId': 'liveDetail',
'body': json.dumps({'id': rid, 'videoType': 1}, separators=(',', ':')), 'body': json.dumps({'id': self.rid, 'videoType': 1}, separators=(',', ':')),
'client': 'wh5' 'client': 'wh5'
} }
with requests.Session() as s: with requests.Session() as s:
@ -26,6 +32,15 @@ def jd(rid):
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__': if __name__ == '__main__':
r = input('输入京东直播间id\n') r = input('请输入京东直播房间号\n')
print(jd(r)) print(get_real_url(r))

20
kk.py
View File

@ -2,9 +2,14 @@
import requests import requests
def kk(rid): class KK:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}' url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(rid), 'platform': 1, 'a': 1, 'c': 100101} parameter = {'FuncTag': 10005043, 'userId': '{}'.format(self.rid), 'platform': 1, 'a': 1, 'c': 100101}
with requests.Session() as s: with requests.Session() as s:
res = s.get(url.format(parameter)).json() res = s.get(url.format(parameter)).json()
tagcode = res['TagCode'] tagcode = res['TagCode']
@ -22,6 +27,15 @@ def kk(rid):
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__': if __name__ == '__main__':
r = input('输入KK直播房间号\n') r = input('输入KK直播房间号\n')
print(kk(r)) print(get_real_url(r))

View File

@ -2,17 +2,21 @@
import json import json
import re import re
import requests import requests
def kuaishou(rid): class KuaiShou:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
headers = { headers = {
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 ' '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', '(KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
'cookie': 'did=web_'} 'cookie': 'did=web_'}
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://m.gifshow.com/fw/live/{}'.format(rid), headers=headers) res = s.get('https://m.gifshow.com/fw/live/{}'.format(self.rid), headers=headers)
livestream = re.search(r'liveStream":(.*),"obfuseData', res.text) livestream = re.search(r'liveStream":(.*),"obfuseData', res.text)
if livestream: if livestream:
livestream = json.loads(livestream.group(1)) livestream = json.loads(livestream.group(1))
@ -24,6 +28,15 @@ def kuaishou(rid):
raise Exception('直播间不存在或未开播') 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__': if __name__ == '__main__':
r = input('输入快手直播房间号:\n') # 例jjworld126 r = input('请输入快手直播房间地址:\n')
print(kuaishou(r)) print(get_real_url(r))

View File

@ -3,18 +3,31 @@
import requests import requests
def get_real_url(rid): class KuGou:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: 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() 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(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_flv = response1.get('data').get('horizontal')[0].get('httpflv')[0]
real_url_hls = response2.get('data').get('horizontal')[0].get('httpshls')[0] real_url_hls = response2.get('data').get('horizontal')[0].get('httpshls')[0]
except: except:
real_url_flv = real_url_hls = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url_flv, real_url_hls return {"flv": real_url_flv, "hls": real_url_hls}
rid = input('请输入酷狗直播房间号:\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') kg = KuGou(rid)
print(real_url) return kg.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入酷狗直播房间号:\n')
print(get_real_url(r))

22
kuwo.py
View File

@ -1,10 +1,16 @@
# 酷我聚星直播http://jx.kuwo.cn/ # 酷我聚星直播http://jx.kuwo.cn/
import requests import requests
def kuwo(rid): class KuWo:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: 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 = s.get('https://zhiboserver.kuwo.cn/proxy.p?src=h5&cmd=enterroom&rid={}&videotype=1&auto=1'.format(self.rid))
res = res.json() res = res.json()
try: try:
livestatus = res['room']['livestatus'] livestatus = res['room']['livestatus']
@ -17,6 +23,16 @@ def kuwo(rid):
raise Exception('未开播') raise Exception('未开播')
def get_real_url(rid):
try:
kw = KuWo(rid)
return kw.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__': if __name__ == '__main__':
r = input('输入酷我聚星直播房间号:\n') r = input('输入酷我聚星直播房间号:\n')
print(kuwo(r)) print(get_real_url(r))

View File

@ -6,9 +6,14 @@ import requests
import re import re
def get_real_url(rid): class LaiFeng:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
response_main = requests.get(url='http://v.laifeng.com/{}/m'.format(rid)).text response_main = requests.get(url='http://v.laifeng.com/{}/m'.format(self.rid)).text
stream_name = re.findall(r"initAlias:'(.*)?'", response_main)[0] stream_name = re.findall(r"initAlias:'(.*)?'", response_main)[0]
real_url = {} real_url = {}
for stream_format in ['HttpFlv', 'Hls']: for stream_format in ['HttpFlv', 'Hls']:
@ -16,11 +21,19 @@ def get_real_url(rid):
response = requests.get(url=request_url).json() response = requests.get(url=request_url).json()
real_url[stream_format] = response.get(stream_format)[0].get('Url') real_url[stream_format] = response.get(stream_format)[0].get('Url')
except: except:
real_url = '该直播间不存在或未开播' raise Exception('该直播间不存在或未开播')
return real_url return real_url
rid = input('请输入来疯直播房间号:\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') lf = LaiFeng(rid)
print(real_url) return lf.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入来疯直播房间号:\n')
print(get_real_url(r))

View File

@ -1,4 +1,5 @@
# 乐嗨直播https://www.lehaitv.com/ # 乐嗨直播https://www.lehaitv.com/
from urllib.parse import urlencode from urllib.parse import urlencode
from urllib.parse import unquote from urllib.parse import unquote
import requests import requests
@ -6,8 +7,13 @@ import time
import hashlib import hashlib
def lehai(rid): class LeHai:
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(rid)
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(self.rid)
params = { params = {
'_st1': int(time.time() * 1e3), '_st1': int(time.time() * 1e3),
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D', 'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
@ -35,6 +41,15 @@ def lehai(rid):
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__': if __name__ == '__main__':
r = input('输入乐嗨直播房间号:\n') r = input('输入乐嗨直播房间号:\n')
print(lehai(r)) print(get_real_url(r))

View File

@ -4,18 +4,31 @@ import requests
import re import re
def get_real_url(rid): class LongZhu:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
response = requests.get('http://m.longzhu.com/' + str(rid)).text response = requests.get('http://m.longzhu.com/' + str(self.rid)).text
roomId = re.findall(r'roomId = (\d*);', response)[0] 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() 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') real_url = response.get('playLines')[0].get('urls')[-1].get('securityUrl')
except: except:
real_url = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入龙珠直播房间号:\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') lz = LongZhu(rid)
print(real_url) return lz.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入龙珠直播房间号:\n')
print(get_real_url(r))

29
look.py
View File

@ -1,21 +1,34 @@
# 获取网易云音乐旗下look直播的真实流媒体地址。 # 获取网易云音乐旗下look直播的真实流媒体地址。
# look直播间链接形式https://look.163.com/live?id=73694082 # look直播间链接形式https://look.163.com/live?id=73694082
import requests import requests
import re import re
def get_real_url(rid): class Look:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
response = requests.post(url='https://look.163.com/live?id=' + rid).text response = requests.post(url='https://look.163.com/live?id=' + self.rid).text
real_url = re.findall(r'"liveUrl":([\s\S]*),"liveType"', response)[0] real_url = re.findall(r'"liveUrl":([\s\S]*),"liveType"', response)[0]
except: except:
real_url = '该直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入look直播房间号\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') look = Look(rid)
print(real_url) return look.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入Look直播房间号\n')
print(get_real_url(r))

28
now.py
View File

@ -1,12 +1,16 @@
# 获取NOW直播的真实流媒体地址。 # 获取NOW直播的真实流媒体地址。
import requests import requests
def get_real_url(rid): class Now:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
room_url = 'https://now.qq.com/cgi-bin/now/web/room/get_live_room_url?room_id={}&platform=8'.format(rid) 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() response = requests.get(url=room_url).json()
result = response.get('result') result = response.get('result')
real_url = { real_url = {
@ -15,11 +19,19 @@ def get_real_url(rid):
'raw_flv_url': result.get('raw_flv_url', 0) 'raw_flv_url': result.get('raw_flv_url', 0)
} }
except: except:
real_url = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入NOW直播间数字ID\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播源地址为:') now = Now(rid)
print(real_url) return now.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入NOW直播间号\n')
print(get_real_url(r))

27
pps.py
View File

@ -5,9 +5,14 @@ import re
import time import time
def get_real_url(rid): class PPS:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
response = requests.get('http://m-x.pps.tv/room/' + str(rid)).text 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] anchor_id = re.findall(r'anchor_id":(\d*),"online_uid', response)[0]
tt = int(time.time() * 1000) 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) 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)
@ -18,11 +23,19 @@ def get_real_url(rid):
response = requests.get(url=url, headers=headers).text response = requests.get(url=url, headers=headers).text
real_url = re.findall(r'"hls":"(.*)","rate_list', response)[0] real_url = re.findall(r'"hls":"(.*)","rate_list', response)[0]
except: except:
real_url = '直播间未开播或不存在' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入奇秀直播房间号:\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') pps = PPS(rid)
print(real_url) return pps.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入奇秀直播房间号:\n')
print(get_real_url(r))

27
qf.py
View File

@ -5,17 +5,30 @@ import requests
import re import re
def get_real_url(rid): class QF:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
response = requests.post(url='https://qf.56.com/' + rid).text response = requests.post(url='https://qf.56.com/' + self.rid).text
real_url = re.findall(r"flvUrl:'(.*)\?wsSecret", response) real_url = re.findall(r"flvUrl:'(.*)\?wsSecret", response)
real_url = real_url[0] real_url = real_url[0]
except: except:
real_url = '该直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入千帆直播房间号:\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') qf = QF(rid)
print(real_url) return qf.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入千帆直播房间号:\n')
print(get_real_url(r))

23
qie.py
View File

@ -1,11 +1,17 @@
# 企鹅体育https://live.qq.com/directory/all # 企鹅体育https://live.qq.com/directory/all
import requests import requests
import re import re
def qie(rid): class ESport:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://m.live.qq.com/' + str(rid)) res = s.get('https://m.live.qq.com/' + str(self.rid))
show_status = re.search(r'"show_status":"(\d)"', res.text) show_status = re.search(r'"show_status":"(\d)"', res.text)
if show_status: if show_status:
if show_status.group(1) == '1': if show_status.group(1) == '1':
@ -17,6 +23,15 @@ def qie(rid):
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__': if __name__ == '__main__':
r = input('输入企鹅体育直播间号:\n') r = input('输入企鹅体育直播间号:\n')
print(qie(r)) print(get_real_url(r))

View File

@ -1,12 +1,18 @@
# 人人直播http://zhibo.renren.com/ # 人人直播http://zhibo.renren.com/
import requests import requests
import re import re
import hashlib import hashlib
def renren(rid): class RenRen:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('http://activity.renren.com/liveroom/' + str(rid)) res = s.get('http://activity.renren.com/liveroom/' + str(self.rid))
livestate = re.search(r'"liveState":(\d)', res.text) livestate = re.search(r'"liveState":(\d)', res.text)
if livestate: if livestate:
try: try:
@ -28,6 +34,15 @@ def renren(rid):
raise Exception('直播间不存在') 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__': if __name__ == '__main__':
r = input('输入人人直播房间号:\n') r = input('输入人人直播房间号:\n')
print(renren(r)) print(get_real_url(r))

View File

@ -1,11 +1,17 @@
# 秀色直播https://www.showself.com/ # 秀色直播https://www.showself.com/
from urllib.parse import urlencode from urllib.parse import urlencode
import requests import requests
import time import time
import hashlib import hashlib
def showself(rid): class ShowSelf:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://service.showself.com/v2/custuser/visitor').json() res = s.get('https://service.showself.com/v2/custuser/visitor').json()
uid = res['data']['uid'] uid = res['data']['uid']
@ -17,7 +23,7 @@ def showself(rid):
} }
payload = { payload = {
'groupid': '999', 'groupid': '999',
'roomid': rid, 'roomid': self.rid,
'sessionid': sessionid, 'sessionid': sessionid,
'sessionId': sessionid 'sessionId': sessionid
} }
@ -25,7 +31,7 @@ def showself(rid):
data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5' data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5'
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest() _ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
payload['_ajaxData1'] = _ajaxData1 payload['_ajaxData1'] = _ajaxData1
url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(rid, urlencode(params)) url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(self.rid, urlencode(params))
with requests.Session() as s: with requests.Session() as s:
res = s.post(url, json=payload) res = s.post(url, json=payload)
if res.status_code == 200: if res.status_code == 200:
@ -44,6 +50,15 @@ def showself(rid):
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__': if __name__ == '__main__':
r = input('输入秀色直播房间号:\n') rid = input('输入秀色直播房间号:\n')
print(showself(r)) print(get_real_url(rid))

21
tuho.py
View File

@ -1,11 +1,17 @@
# 星光直播https://www.tuho.tv/28545037 # 星光直播https://www.tuho.tv/28545037
import requests import requests
import re import re
def tuho(rid): class TuHo:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://www.tuho.tv/' + str(rid)).text res = s.get('https://www.tuho.tv/' + str(self.rid)).text
flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res) flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res)
if flv: if flv:
status = re.search(r'isPlaying\s:\s(\w+),', res).group(1) status = re.search(r'isPlaying\s:\s(\w+),', res).group(1)
@ -18,6 +24,15 @@ def tuho(rid):
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__': if __name__ == '__main__':
r = input('输入星光直播房间号:\n') r = input('输入星光直播房间号:\n')
print(tuho(r)) print(get_real_url(r))

28
v6cn.py
View File

@ -4,9 +4,14 @@ import requests
import re import re
def get_real_url(rid): class V6CN:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
response = requests.get('https://v.6.cn/' + str(rid)).text response = requests.get('https://v.6.cn/' + str(self.rid)).text
result = re.findall(r'"flvtitle":"v(\d*?)-(\d*?)"', response)[0] result = re.findall(r'"flvtitle":"v(\d*?)-(\d*?)"', response)[0]
uid = result[0] uid = result[0]
flvtitle = 'v{}-{}'.format(*result) flvtitle = 'v{}-{}'.format(*result)
@ -14,11 +19,20 @@ def get_real_url(rid):
hip = 'https://' + re.findall(r'<watchip>(.*\.xiu123\.cn).*</watchip>', response)[0] hip = 'https://' + re.findall(r'<watchip>(.*\.xiu123\.cn).*</watchip>', response)[0]
real_url = [hip + '/' + flvtitle + '/playlist.m3u8', hip + '/httpflv/' + flvtitle] real_url = [hip + '/' + flvtitle + '/playlist.m3u8', hip + '/httpflv/' + flvtitle]
except: except:
real_url = '直播间不存在或未开播' raise Exception('直播间不存在或未开播')
return real_url return real_url
rid = input('请输入六间房直播ID\n') def get_real_url(rid):
real_url = get_real_url(rid) try:
print('该直播间源地址为:') v6cn = V6CN(rid)
print(real_url) return v6cn.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入六间房直播房间号:\n')
print(get_real_url(r))

25
wali.py
View File

@ -1,11 +1,17 @@
# 小米直播https://live.wali.com/fe # 小米直播https://live.wali.com/fe
import requests import requests
def wali(rid): class WaLi:
zuid = rid.split('_')[0]
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
zuid = self.rid.split('_')[0]
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://s.zb.mi.com/get_liveinfo?lid={}&zuid={}'.format(rid, zuid)).json() res = s.get('https://s.zb.mi.com/get_liveinfo?lid={}&zuid={}'.format(self.rid, zuid)).json()
status = res['data']['status'] status = res['data']['status']
if status == 1: if status == 1:
flv = res['data']['video']['flv'] flv = res['data']['video']['flv']
@ -14,6 +20,15 @@ def wali(rid):
raise Exception('直播间不存在或未开播') 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__': if __name__ == '__main__':
r = input('输入小米直播房间号:\n') r = input('输入小米直播房间号:\n')
print(wali(r)) print(get_real_url(r))

View File

@ -1,13 +1,19 @@
# 我秀直播https://www.woxiu.com/ # 我秀直播https://www.woxiu.com/
import requests import requests
def woxiu(rid): class WoXiu:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
headers = { headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) ' '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' 'Version/11.0 Mobile/15A372 Safari/604.1'
} }
url = 'https://m.woxiu.com/index.php?action=M/Live&do=LiveInfo&room_id={}'.format(rid) url = 'https://m.woxiu.com/index.php?action=M/Live&do=LiveInfo&room_id={}'.format(self.rid)
with requests.Session() as s: with requests.Session() as s:
res = s.get(url, headers=headers) res = s.get(url, headers=headers)
try: try:
@ -22,6 +28,15 @@ def woxiu(rid):
raise Exception('未开播') raise Exception('未开播')
def get_real_url(rid):
try:
wx = WoXiu(rid)
return wx.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__': if __name__ == '__main__':
r = input('输入我秀直播房间号:\n') r = input('输入我秀直播房间号:\n')
print(woxiu(r)) print(get_real_url(r))

View File

@ -1,11 +1,17 @@
# 迅雷直播https://live.xunlei.com/global/index.html?id=0 # 迅雷直播https://live.xunlei.com/global/index.html?id=0
import requests import requests
import hashlib import hashlib
import time import time
from urllib.parse import urlencode from urllib.parse import urlencode
def xunlei(rid): class XunLei:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
url = 'https://biz-live-ssl.xunlei.com//caller' url = 'https://biz-live-ssl.xunlei.com//caller'
headers = { headers = {
'cookie': 'appid=1002' 'cookie': 'appid=1002'
@ -18,7 +24,7 @@ def xunlei(rid):
'a': 'play', 'a': 'play',
'c': 'room', 'c': 'room',
'hid': 'h5-e70560ea31cc17099395c15595bdcaa1', 'hid': 'h5-e70560ea31cc17099395c15595bdcaa1',
'uuid': rid, 'uuid': self.rid,
} }
data = urlencode(params) data = urlencode(params)
p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest() p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest()
@ -36,6 +42,16 @@ def xunlei(rid):
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__': if __name__ == '__main__':
r = input('输入迅雷直播房间号:\n') r = input('请输入迅雷直播房间号:\n')
print(xunlei(r)) print(get_real_url(r))

View File

@ -1,13 +1,17 @@
# 获取一直播的真实流媒体地址。 # 获取一直播的真实流媒体地址。
import requests import requests
import re import re
def get_real_url(room_url): class YiZhiBo:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
scid = re.findall(r'/l/(\S*).html', room_url)[0] scid = re.findall(r'/l/(\S*).html', self.rid)[0]
flvurl = 'http://alcdn.f01.xiaoka.tv/live/{}.flv'.format(scid) flvurl = 'http://alcdn.f01.xiaoka.tv/live/{}.flv'.format(scid)
m3u8url = 'http://al01.alcdn.hls.xiaoka.tv/live/{}.m3u8'.format(scid) m3u8url = 'http://al01.alcdn.hls.xiaoka.tv/live/{}.m3u8'.format(scid)
rtmpurl = 'rtmp://alcdn.r01.xiaoka.tv/live/live/{}'.format(scid) rtmpurl = 'rtmp://alcdn.r01.xiaoka.tv/live/live/{}'.format(scid)
@ -17,25 +21,30 @@ def get_real_url(room_url):
'rtmpurl': rtmpurl 'rtmpurl': rtmpurl
} }
except: except:
real_url = '链接错误' raise Exception('链接错误')
return real_url return real_url
def get_status(self):
def get_status(room_url):
try: try:
scid = re.findall(r'/l/(\S*).html', room_url)[0] scid = re.findall(r'/l/(\S*).html', self.rid)[0]
response = requests.get( response = requests.get(
url='https://m.yizhibo.com/www/live/get_live_video?scid=' + str(scid)).json() url='https://m.yizhibo.com/www/live/get_live_video?scid=' + str(scid)).json()
status_code = response.get('data').get('info').get('status') status_code = response.get('data').get('info').get('status')
status = '直播中' if status_code == 10 else '未开播' status = '直播中' if status_code == 10 else '未开播'
except: except:
status = '链接错误' raise Exception('链接错误')
return status return status
rid = input('请输入一直播房间地址:\n') def get_real_url(rid):
status = get_status(rid) try:
print('当前直播状态', status) yzb = YiZhiBo(rid)
real_url = get_real_url(rid) return yzb.get_real_url()
print('该直播间源地址为:') except Exception as e:
print(real_url) print('Exception', e)
return False
if __name__ == '__main__':
r = input('请输入一直播房间地址:\n')
print(get_real_url(r))

View File

@ -3,16 +3,22 @@
# 而且没有平台水印和主播自己贴的乱七八糟的字幕遮挡。 # 而且没有平台水印和主播自己贴的乱七八糟的字幕遮挡。
# liveId 是如下形式直播间链接: # 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字段。 # “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 requests
import time import time
import hashlib import hashlib
import json import json
def youku(liveid): class YouKu:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
try: try:
tt = str(int(time.time() * 1000)) tt = str(int(time.time() * 1000))
data = json.dumps({'liveId': liveid, 'app': 'Pc'}, separators=(',', ':')) data = json.dumps({'liveId': self.rid, 'app': 'Pc'}, separators=(',', ':'))
url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788' url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788'
s = requests.Session() s = requests.Session()
cookies = s.get(url).cookies cookies = s.get(url).cookies
@ -29,10 +35,19 @@ def youku(liveid):
real_url = 'http://lvo-live.youku.com/vod2live/{}_mp4hd2v3.m3u8?&expire=21600&psid=1&ups_ts={}&vkey='.format( real_url = 'http://lvo-live.youku.com/vod2live/{}_mp4hd2v3.m3u8?&expire=21600&psid=1&ups_ts={}&vkey='.format(
streamname, int(time.time())) streamname, int(time.time()))
except: except:
real_url = '请求错误' raise Exception('请求错误')
return real_url return real_url
def get_real_url(rid):
try:
yk = YouKu(rid)
return yk.get_real_url()
except Exception as e:
print('Exception', e)
return False
if __name__ == '__main__': if __name__ == '__main__':
r = input('输入优酷轮播台liveId\n') r = input('请输入优酷轮播台房间号\n')
print(youku(r)) print(get_real_url(r))

View File

@ -3,9 +3,14 @@ import requests
import re import re
def yuanbobo(rid): class YuanBoBo:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://zhibo.yuanbobo.com/' + str(rid)).text res = s.get('https://zhibo.yuanbobo.com/' + str(self.rid)).text
stream_id = re.search(r"stream_id:\s+'(\d+)'", res) stream_id = re.search(r"stream_id:\s+'(\d+)'", res)
if stream_id: if stream_id:
status = re.search(r"status:\s+'(\d)'", res).group(1) status = re.search(r"status:\s+'(\d)'", res).group(1)
@ -18,6 +23,15 @@ def yuanbobo(rid):
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__': if __name__ == '__main__':
r = input('输入热猫直播房间号:\n') r = input('输入热猫直播房间号:\n')
print(yuanbobo(r)) print(get_real_url(r))

23
yy.py
View File

@ -1,17 +1,23 @@
# 获取YY直播的真实流媒体地址。https://www.yy.com/1349606469 # 获取YY直播的真实流媒体地址。https://www.yy.com/1349606469
# 默认获取最高画质 # 默认获取最高画质
import requests import requests
import re import re
import json import json
def yy(rid): class YY:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
headers = { headers = {
'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=rid), '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)' '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' ' 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) room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=self.rid)
with requests.Session() as s: with requests.Session() as s:
res = s.get(room_url, headers=headers) res = s.get(room_url, headers=headers)
if res.status_code == 200: if res.status_code == 200:
@ -30,6 +36,15 @@ def yy(rid):
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__': if __name__ == '__main__':
r = input('输入YY直播房间号\n') r = input('输入YY直播房间号\n')
print(yy(r)) print(get_real_url(r))

View File

@ -3,9 +3,14 @@
import requests import requests
def zhanqi(rid): class ZhanQi:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(rid)) res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
try: try:
res = res.json() res = res.json()
videoid = res['data']['videoId'] videoid = res['data']['videoId']
@ -14,12 +19,21 @@ def zhanqi(rid):
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid) url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
real_url = s.get(url).text real_url = s.get(url).text
else: else:
real_url = '未开播' raise Exception('未开播')
except: except:
real_url = '直播间不存在' raise Exception('直播间不存在')
return real_url 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__': if __name__ == '__main__':
r = input('输入战旗直播房间号:\n') r = input('输入战旗直播房间号:\n')
print(zhanqi(r)) print(get_real_url(r))