1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-06-17 08:25:25 +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

42
173.py
View File

@ -1,22 +1,38 @@
# 艺气山直播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)
with requests.Session() as s: def __init__(self, rid):
res = s.post('http://www.173.com/room/getVieoUrl', params=params).json() self.rid = rid
data = res['data']
if data: def get_real_url(self):
status = data['status'] params = 'roomId={}&format=m3u8'.format(self.rid)
if status == 2: with requests.Session() as s:
return data['url'] 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: else:
raise Exception('未开播') raise Exception('直播间不存在')
else:
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
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): def get_real_url(rid):
try: try:
response = requests.get(url='https://api-dsa.17app.co/api/v1/lives/' + rid).json() live17 = Live17(rid)
real_url_default = response.get('rtmpUrls')[0].get('url') return live17.get_real_url()
real_url_modify = real_url_default.replace('global-pull-rtmp.17app.co', 'china-pull-rtmp-17.tigafocus.com') except Exception as e:
real_url = [real_url_modify, real_url_default] print('Exception', e)
except: return False
real_url = '该直播间不存在或未开播'
return real_url
rid = input('请输入17直播房间号\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入17直播房间号\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

42
2cq.py
View File

@ -1,22 +1,38 @@
# 棉花糖直播https://www.2cq.com/rank # 棉花糖直播https://www.2cq.com/rank
import requests import requests
def mht(rid): class MHT:
with requests.Session() as s:
res = s.get('https://www.2cq.com/proxy/room/room/info?roomId={}&appId=1004'.format(rid)) def __init__(self, rid):
res = res.json() self.rid = rid
if res['status'] == 1:
result = res['result'] def get_real_url(self):
if result['liveState'] == 1: with requests.Session() as s:
real_url = result['pullUrl'] res = s.get('https://www.2cq.com/proxy/room/room/info?roomId={}&appId=1004'.format(self.rid))
return real_url 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: else:
raise Exception('未开播') raise Exception('直播间可能不存在')
else:
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))

75
51lm.py
View File

@ -1,43 +1,58 @@
# 羚萌直播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 g(d): def __init__(self, rid):
return hashlib.md5((d + '#' + urlencode(roominfo) + '#Ogvbm2ZiKE').encode('utf-8')).hexdigest() self.rid = rid
lminfo = { def get_real_url(self):
'h': int(time.time()) * 1000, roominfo = {'programId': self.rid}
'i': -246397986,
'o': 'iphone', def g(d):
's': 'G_c17a64eff3f144a1a48d9f02e8d981c2', return hashlib.md5((d + '#' + urlencode(roominfo) + '#Ogvbm2ZiKE').encode('utf-8')).hexdigest()
't': 'H',
'v': '4.20.43', lminfo = {
'w': 'a710244508d3cc14f50d24e9fecc496a' 'h': int(time.time()) * 1000,
} 'i': -246397986,
u = g(urlencode(lminfo)) 'o': 'iphone',
lminfo = 'G=' + u + '&' + urlencode(lminfo) 's': 'G_c17a64eff3f144a1a48d9f02e8d981c2',
with requests.Session() as s: 't': 'H',
res = s.post('https://www.51lm.tv/live/room/info/basic', json=roominfo, headers={'lminfo': lminfo}).json() 'v': '4.20.43',
code = res['code'] 'w': 'a710244508d3cc14f50d24e9fecc496a'
if code == 200: }
status = res['data']['isLiving'] u = g(urlencode(lminfo))
if status == 'True': lminfo = 'G=' + u + '&' + urlencode(lminfo)
real_url = res['data']['playUrl'] with requests.Session() as s:
return real_url res = s.post('https://www.51lm.tv/live/room/info/basic', json=roominfo, headers={'lminfo': lminfo}).json()
else: code = res['code']
raise Exception('未开播') if code == 200:
elif code == -1: status = res['data']['isLiving']
raise Exception('输入错误') if status == 'True':
elif code == 1201: real_url = res['data']['playUrl']
raise Exception('直播间不存在') 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__': if __name__ == '__main__':
r = input('输入羚萌直播房间号:\n') r = input('输入羚萌直播房间号:\n')
print(lm(r)) print(get_real_url(r))

View File

@ -1,23 +1,39 @@
# 95秀http://www.95.cn/ # 95秀http://www.95.cn/
import requests import requests
import re import re
def jwxiu(rid): class JWXiu:
with requests.Session() as s:
res = s.get('http://www.95.cn/{}.html'.format(rid)).text 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: try:
uid = re.search(r'"uid":(\d+),', res).group(1) jwx = JWXiu(rid)
status = re.search(r'"is_offline":"(\d)"', res).group(1) return jwx.get_real_url()
except AttributeError: except Exception as e:
raise Exception('没有找到直播间') print('Exception', e)
if status == '0': return False
real_url = 'http://play.95xiu.com/app/{}.flv'.format(uid)
return real_url
else:
raise Exception('未开播')
if __name__ == '__main__': if __name__ == '__main__':
r = input('输入95秀房间号\n') r = input('输入95秀房间号\n')
print(jwxiu(r)) print(get_real_url(r))

51
9xiu.py
View File

@ -1,26 +1,41 @@
# 九秀直播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:
with requests.Session() as s:
url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str(rid) def __init__(self, rid):
headers = { self.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' def get_real_url(self):
} with requests.Session() as s:
res = s.get(url, headers=headers).json() url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str( self.rid)
if res['code'] == 200: headers = {
status = res['data']['status'] 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) '
if status == 0: 'AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
raise Exception('未开播') }
elif status == 1: res = s.get(url, headers=headers).json()
live_url = res['data']['live_url'] if res['code'] == 200:
return live_url status = res['data']['status']
else: if status == 0:
raise Exception('直播间可能不存在') 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__': if __name__ == '__main__':
r = input('输入九秀直播房间号:\n') r = input('输入九秀直播房间号:\n')
print(j_xiu(r)) print(get_real_url(r))

View File

@ -1,45 +1,61 @@
# AcFun直播https://live.acfun.cn/ # AcFun直播https://live.acfun.cn/
# 默认最高画质 # 默认最高画质
import requests import requests
import json import json
def acfun(rid): class AcFun:
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' def __init__(self, rid):
params = { self.rid = rid
'subBiz': 'mainApp',
'kpn': 'ACFUN_APP', def get_real_url(self):
'kpf': 'PC_WEB', headers = {
'userId': userid, 'content-type': 'application/x-www-form-urlencoded',
'did': 'H5_', 'cookie': '_did=H5_',
'acfun.api.visitor_st': visitor_st 'referer': 'https://m.acfun.cn/'
} }
data = 'authorId={}&pullStreamType=FLV'.format(rid) url = 'https://id.app.acfun.cn/rest/app/visitor/login'
res = s.post(url, params=params, data=data, headers=headers).json() data = 'sid=acfun.api.visitor'
if res['result'] == 1: with requests.Session() as s:
data = res['data'] res = s.post(url, data=data, headers=headers).json()
videoplayres = json.loads(data['videoPlayRes']) userid = res['userId']
liveadaptivemanifest, = videoplayres['liveAdaptiveManifest'] visitor_st = res['acfun.api.visitor_st']
adaptationset = liveadaptivemanifest['adaptationSet']
representation = adaptationset['representation'][-1] url = 'https://api.kuaishouzt.com/rest/zt/live/web/startPlay'
real_url = representation['url'] params = {
return real_url 'subBiz': 'mainApp',
else: 'kpn': 'ACFUN_APP',
raise Exception('直播已关闭') '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__': if __name__ == '__main__':
r = input('输入AcFun直播间号\n') r = input('请输入AcFun直播房间号\n')
print(acfun(r)) print(get_real_url(r))

View File

@ -6,45 +6,59 @@
import requests import requests
def bilibili(rid): class BiliBili:
# 先获取直播状态和真实房间号
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']
def u(pf): def __init__(self, rid):
f_url = 'https://api.live.bilibili.com/xlive/web-room/v1/playUrl/playUrl' self.rid = rid
params = {
'cid': room_id, def get_real_url(self):
'qn': 10000, # 先获取直播状态和真实房间号
'platform': pf, r_url = 'https://api.live.bilibili.com/room/v1/Room/room_init?id={}'.format(self.rid)
'https_url_req': 1, with requests.Session() as s:
'ptype': 16 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: else:
raise Exception('未开播') raise Exception('房间不存在')
else:
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))

48
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)
response = requests.get(url=room_url).json() def __init__(self, rid):
data = response.get('data', 0) self.rid = rid
if data:
channel_id = data.get('{}'.format(rid)).get('channel_id', 0) def get_real_url(self):
if channel_id: room_url = 'https://api.cc.163.com/v1/activitylives/anchor/lives?anchor_ccid=' + str(self.rid)
response = requests.get('https://cc.163.com/live/channel/?channelids=' + str(channel_id)).json() response = requests.get(url=room_url).json()
real_url = response.get('data')[0].get('sharefile') 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: else:
real_url = '直播间不存在' raise Exception('输入错误')
else: return real_url
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,25 +1,38 @@
# 获取触手直播的真实流媒体地址。 # 获取触手直播的真实流媒体地址。
import requests 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): def get_real_url(rid):
try: try:
room_url = 'https://chushou.tv/h5player/video/get-play-url.htm?roomId={}&protocols=2&callback='.format(rid) cs = ChuShou(rid)
response = requests.get(url=room_url).json() return cs.get_real_url()
data = response.get('data')[0] except Exception as e:
real_url = { print('Exception', e)
'sdPlayUrl': data.get('sdPlayUrl', 0), return False
'hdPlayUrl': data.get('hdPlayUrl', 0),
'shdPlayUrl': data.get('shdPlayUrl', 0)
}
except:
real_url = '直播间不存在或未开播'
return real_url
rid = input('请输入触手直播间数字ID\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入触手直播房间号:\n')
print('该直播源地址为:') print(get_real_url(r))
print(real_url)

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
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): def get_real_url(rid):
try: try:
if 'v.douyin.com' in rid: dy = DouYin(rid)
room_id = re.findall(r'(\d{19})', requests.get(url=rid).url)[0] return dy.get_real_url()
else: except Exception as e:
room_id = rid print('Exception', e)
room_url = 'https://webcast-hl.amemv.com/webcast/room/reflow/info/?room_id={}&live_id=1'.format(room_id) return False
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
rid = input('请输入抖音直播间room_id或分享链接\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入抖音直播间room_id或分享链接\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

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,42 +1,55 @@
# 获取企鹅电竞的真实流媒体地址。 # 获取企鹅电竞的真实流媒体地址。
# 默认画质为超清 # 默认画质为超清
import requests import requests
import json
import re import re
def get_real_url(rid): class EGame:
room_url = 'https://share.egame.qq.com/cgi-bin/pgg_async_fcgi'
post_data = { def __init__(self, rid):
'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}}}''' self.rid = rid
}
try: def get_real_url(self):
response = requests.post(url=room_url, data=post_data).json() room_url = 'https://share.egame.qq.com/cgi-bin/pgg_async_fcgi'
data = response.get('data', 0) post_data = {
if data: 'param': '''{"0":{"module":"pgg_live_read_svr","method":"get_live_and_profile_info","param":{"anchor_id":'''
video_info = data.get('0').get( + str(self.rid) + ''',"layout_id":"hot","index":1,"other_uid":0}}}'''
'retBody').get('data').get('video_info') }
pid = video_info.get('pid', 0) try:
if pid: response = requests.post(url=room_url, data=post_data).json()
is_live = data.get('0').get( data = response.get('data', 0)
'retBody').get('data').get('profile_info').get('is_live', 0) if data:
if is_live: video_info = data.get('0').get(
play_url = video_info.get('stream_infos')[ 'retBody').get('data').get('video_info')
0].get('play_url') pid = video_info.get('pid', 0)
real_url = re.findall(r'([\w\W]+?)&uid=', play_url)[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: else:
real_url = '直播间未开播' raise Exception('直播间未启用')
else: else:
real_url = '直播间未启用' raise Exception('直播间不存在')
else: except:
real_url = '直播间不存在' raise Exception('数据请求错误')
except: return real_url
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,32 +8,46 @@ import json
import requests import requests
def fengbo(rid): class FengBo:
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')
# 开始AES解密 def __init__(self, rid):
def pad(t): self.rid = rid
return t + (16 - len(t) % 16) * b'\x00'
key = iv = 'abcdefghqwertyui'.encode('utf8') def get_real_url(self):
cipher = AES.new(key, AES.MODE_CBC, iv) with requests.Session() as s:
info = info.encode('utf8') res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(self.rid)).json()
info = pad(info) if res['ret'] == 1:
result = cipher.decrypt(base64.decodebytes(info)).rstrip(b'\0') info = res['info']
info = unquote(info, 'utf-8')
result = json.loads(result.decode('utf-8')) # 开始AES解密
url = result['url'] def pad(t):
url = url.replace('hdl', 'hls') return t + (16 - len(t) % 16) * b'\x00'
url = url.replace('.flv', '/playlist.m3u8')
return url key = iv = 'abcdefghqwertyui'.encode('utf8')
else: cipher = AES.new(key, AES.MODE_CBC, iv)
raise Exception('房间号错误') 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__': if __name__ == '__main__':
r = input('输入疯播直播房间号:\n') r = input('输入疯播直播房间号:\n')
print(fengbo(r)) print(get_real_url(r))

123
hongle.py
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,66 +10,80 @@ import hashlib
import json import json
def hongle(rid): class HongLe:
# 模拟登陆
with requests.Session() as s:
pass
tt = int(time.time() * 1000) def __init__(self, rid):
url = 'https://service.hongle.tv/v2/userw/login?_st1={}'.format(tt) self.rid = rid
data = {
'_st1': tt,
'geetest_challenge': '7f4f6fd6257799c0bcac1f38c21c042dl0',
'geetest_seccode': 'd1163915f4cfd6c998014c4ca8899c9d|jordan',
'geetest_validate': 'd1163915f4cfd6c998014c4ca8899c9d',
'name': '16530801176',
'password': 'QTXz9/Sp40BbMHwVtcb7AQ==',
}
data1 = urlencode(data) + 'yuj1ah5o' def get_real_url(self):
_ajaxdata1 = hashlib.md5(data1.encode('utf-8')).hexdigest() # 模拟登陆
data['_ajaxData1'] = _ajaxdata1 with requests.Session() as s:
del data['_st1'] pass
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('登陆信息过期')
url = 'https://service.hongle.tv/v2/roomw/media' tt = int(time.time() * 1000)
accesstoken = sessionid url = 'https://service.hongle.tv/v2/userw/login?_st1={}'.format(tt)
params = { data = {
'_st1': tt, '_st1': tt,
'accessToken': accesstoken, 'geetest_challenge': '7f4f6fd6257799c0bcac1f38c21c042dl0',
'of': 1, 'geetest_seccode': 'd1163915f4cfd6c998014c4ca8899c9d|jordan',
'showid': rid, 'geetest_validate': 'd1163915f4cfd6c998014c4ca8899c9d',
'tku': 43112608, 'name': '16530801176',
} 'password': 'QTXz9/Sp40BbMHwVtcb7AQ==',
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) data1 = urlencode(data) + 'yuj1ah5o'
if res.status_code == 200: _ajaxdata1 = hashlib.md5(data1.encode('utf-8')).hexdigest()
res = res.json() data['_ajaxData1'] = _ajaxdata1
statuscode = res['status']['statuscode'] del data['_st1']
if statuscode == '0': data = json.dumps(data, separators=(',', ':'))
if res['data']['live_status'] == '1': headers = {'Content-Type': 'application/x-www-form-urlencoded'}
real_url = res['data']['media_url_web'] res = s.post(url, data=data, headers=headers).json()
real_url = real_url.replace('http', 'https') if res['status']['statuscode'] == '0':
real_url = real_url.replace('__', '&') sessionid = res['data']['sessionid']
return real_url
else:
raise Exception('未开播')
else: else:
raise Exception('房间不存在') raise Exception('登陆信息过期')
else:
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__': 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
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): def get_real_url(rid):
tt = str(time.time())
try: try:
room_url = 'https://h.huajiao.com/api/getFeedInfo?sid={tt}&liveid={rid}'.format(tt=tt, rid=rid) hj = HuaJiao(rid)
response = requests.get(url=room_url).json() return hj.get_real_url()
real_url = response.get('data').get('live').get('main') except Exception as e:
except: print('Exception', e)
real_url = '直播间不存在或未开播' return False
return real_url
rid = input('请输入花椒直播间号:\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入花椒直播房间号:\n')
print('该直播源地址为:\n' + real_url) print(get_real_url(r))

100
huomao.py
View File

@ -3,62 +3,74 @@
# 实际上使用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:
tt = str(int((time.time() * 1000)))
return tt
def __init__(self, rid):
self.rid = rid
def get_videoids(rid): @staticmethod
room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid) def get_time():
response = requests.get(url=room_url).text tt = str(int((time.time() * 1000)))
try: return tt
videoids = re.findall(r'var stream = "([\w\W]+?)";', response)[0]
except:
videoids = 0
return videoids
@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): @staticmethod
token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) + def get_token(videoids, time):
'6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest() token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) +
return token '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): def get_real_url(rid):
videoids = get_videoids(rid) try:
if videoids: hm = HuoMao(rid)
time = get_time() return hm.get_real_url()
token = get_token(videoids, time) except Exception as e:
room_url = 'https://www.huomao.com/swf/live_data' print('Exception', e)
post_data = { return False
'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
rid = input('请输入火猫直播房间号:\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入火猫直播房间号:\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

105
huya.py
View File

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

View File

@ -1,23 +1,38 @@
# 艾米直播https://www.imifun.com/ # 艾米直播https://www.imifun.com/
import requests import requests
import re import re
def imifun(rid): class IMFun:
with requests.Session() as s:
res = s.get('https://www.imifun.com/' + str(rid)).text def __init__(self, rid):
roomid = re.search(r"roomId:\s'([\w-]+)'", res) self.rid = rid
if roomid:
status = re.search(r"isLive:(\d),", res).group(1) def get_real_url(self):
if status == '1': with requests.Session() as s:
real_url = 'https://wsmd.happyia.com/ivp/{}.flv'.format(roomid.group(1)) res = s.get('https://www.imifun.com/' + str(self.rid)).text
return real_url 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: else:
raise Exception('未开播') raise Exception('直播间不存在')
else:
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,31 +1,43 @@
import requests import requests
def immomo(rid): class ImMoMo:
url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos' def __init__(self, rid):
data = { self.rid = rid
'stid': rid,
'src': 'url'
}
with requests.Session() as s: def get_real_url(self):
s.get('https://web.immomo.com') url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos'
res = s.post(url, data=data).json() data = {
'stid': self.rid,
'src': 'url'
}
ec = res.get('ec', 0) with requests.Session() as s:
if ec != 200: s.get('https://web.immomo.com')
raise Exception('请求参数错误') res = s.post(url, data=data).json()
else:
live = res['data']['live'] ec = res.get('ec', 0)
if live: if ec != 200:
real_url = res['data']['url'] raise Exception('请求参数错误')
return real_url
else: 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__': if __name__ == '__main__':
r = input('输入陌陌直播房间号:\n') r = input('输入陌陌直播房间号:\n')
print(immomo(r)) print(get_real_url(r))
# https://web.immomo.com/live/337033339

44
inke.py
View File

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

View File

@ -9,39 +9,51 @@ import time
import urllib.parse 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): def get_real_url(rid):
try: try:
response = requests.get('https://m-gamelive.iqiyi.com/w/' + rid).text iqiyi = IQiYi(rid)
# 获取直播间的qipuId return iqiyi.get_real_url()
qipuId = re.findall(r'"qipuId":(\d*?),"roomId', response)[0] except Exception as e:
callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000' print('Exception', e)
params = { return False
'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
if __name__ == '__main__':
rid = input('请输入爱奇艺直播间id\n') # 如19732 r = input('请输入爱奇艺直播房间号:\n')
real_url = get_real_url(rid) print(get_real_url(r))
print('该直播间源地址为:')
print(real_url)

View File

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

59
jd.py
View File

@ -1,31 +1,46 @@
# 京东直播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:
url = 'https://api.m.jd.com/client.action'
params = { def __init__(self, rid):
'functionId': 'liveDetail', self.rid = rid
'body': json.dumps({'id': rid, 'videoType': 1}, separators=(',', ':')),
'client': 'wh5' def get_real_url(self):
} url = 'https://api.m.jd.com/client.action'
with requests.Session() as s: params = {
res = s.get(url, params=params).json() 'functionId': 'liveDetail',
data = res.get('data', 0) 'body': json.dumps({'id': self.rid, 'videoType': 1}, separators=(',', ':')),
if data: 'client': 'wh5'
status = data['status'] }
if status == 1: with requests.Session() as s:
real_url = data['h5Pull'] res = s.get(url, params=params).json()
return real_url 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: else:
print('未开播') raise Exception('直播间不存在')
real_url = '回放:' + data.get('playBack').get('videoUrl', 0)
return real_url
else: def get_real_url(rid):
raise Exception('直播间不存在') 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))

50
kk.py
View File

@ -2,26 +2,40 @@
import requests import requests
def kk(rid): class KK:
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(rid), 'platform': 1, 'a': 1, 'c': 100101} def __init__(self, rid):
with requests.Session() as s: self.rid = rid
res = s.get(url.format(parameter)).json()
tagcode = res['TagCode'] def get_real_url(self):
if tagcode == '00000000': url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
if res.get('liveType', 0) == 1: parameter = {'FuncTag': 10005043, 'userId': '{}'.format(self.rid), 'platform': 1, 'a': 1, 'c': 100101}
roomid = res['roomId'] with requests.Session() as s:
parameter = {'FuncTag': 60001002, 'roomId': roomid, 'platform': 1, 'a': 1, 'c': 100101} res = s.get(url.format(parameter)).json()
with requests.Session() as s: tagcode = res['TagCode']
res = s.get(url.format(parameter)).json() if tagcode == '00000000':
real_url = res['liveStream'] if res.get('liveType', 0) == 1:
return real_url 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: else:
raise Exception('未开播') raise Exception('直播间不存在')
else:
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,28 +2,41 @@
import json import json
import re import re
import requests import requests
def kuaishou(rid): class KuaiShou:
headers = {
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 ' def __init__(self, rid):
'(KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1', self.rid = rid
'cookie': 'did=web_'}
with requests.Session() as s: def get_real_url(self):
res = s.get('https://m.gifshow.com/fw/live/{}'.format(rid), headers=headers) headers = {
livestream = re.search(r'liveStream":(.*),"obfuseData', res.text) 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 '
if livestream: '(KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
livestream = json.loads(livestream.group(1)) 'cookie': 'did=web_'}
*_, hlsplayurls = livestream['multiResolutionHlsPlayUrls'] with requests.Session() as s:
urls, = hlsplayurls['urls'] res = s.get('https://m.gifshow.com/fw/live/{}'.format(self.rid), headers=headers)
url = urls['url'] livestream = re.search(r'liveStream":(.*),"obfuseData', res.text)
return url if livestream:
else: livestream = json.loads(livestream.group(1))
raise Exception('直播间不存在或未开播') *_, 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__': 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
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): def get_real_url(rid):
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() kg = KuGou(rid)
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() return kg.get_real_url()
real_url_flv = response1.get('data').get('horizontal')[0].get('httpflv')[0] except Exception as e:
real_url_hls = response2.get('data').get('horizontal')[0].get('httpshls')[0] print('Exception', e)
except: return False
real_url_flv = real_url_hls = '直播间不存在或未开播'
return real_url_flv, real_url_hls
rid = input('请输入酷狗直播房间号:\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入酷狗直播房间号:\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

42
kuwo.py
View File

@ -1,22 +1,38 @@
# 酷我聚星直播http://jx.kuwo.cn/ # 酷我聚星直播http://jx.kuwo.cn/
import requests import requests
def kuwo(rid): class KuWo:
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)) def __init__(self, rid):
res = res.json() 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: try:
livestatus = res['room']['livestatus'] kw = KuWo(rid)
except KeyError: return kw.get_real_url()
raise Exception('房间号错误') except Exception as e:
if livestatus == 2: print('Exception', e)
real_url = res['live']['url'] return False
return real_url
else:
raise Exception('未开播')
if __name__ == '__main__': if __name__ == '__main__':
r = input('输入酷我聚星直播房间号:\n') r = input('输入酷我聚星直播房间号:\n')
print(kuwo(r)) print(get_real_url(r))

View File

@ -6,21 +6,34 @@ import requests
import re 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): def get_real_url(rid):
try: try:
response_main = requests.get(url='http://v.laifeng.com/{}/m'.format(rid)).text lf = LaiFeng(rid)
stream_name = re.findall(r"initAlias:'(.*)?'", response_main)[0] return lf.get_real_url()
real_url = {} except Exception as e:
for stream_format in ['HttpFlv', 'Hls']: print('Exception', e)
request_url = 'https://lapi.lcloud.laifeng.com/Play?AppId=101&StreamName={}&Action=Schedule&Version=2.0&Format={}'.format(stream_name, stream_format) return False
response = requests.get(url=request_url).json()
real_url[stream_format] = response.get(stream_format)[0].get('Url')
except:
real_url = '该直播间不存在或未开播'
return real_url
rid = input('请输入来疯直播房间号:\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入来疯直播房间号:\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

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,35 +7,49 @@ import time
import hashlib import hashlib
def lehai(rid): class LeHai:
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(rid)
params = { def __init__(self, rid):
'_st1': int(time.time() * 1e3), self.rid = rid
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
'tku': 3000006, def get_real_url(self):
} url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(self.rid)
data = urlencode(params) + '1eha12h5' params = {
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest() '_st1': int(time.time() * 1e3),
params['_ajaxData1'] = _ajaxData1 'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
params['accessToken'] = unquote(params['accessToken']) 'tku': 3000006,
with requests.Session() as s: }
res = s.get(url, params=params) data = urlencode(params) + '1eha12h5'
if res.status_code == 200: _ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
res = res.json() params['_ajaxData1'] = _ajaxData1
statuscode = res['status']['statuscode'] params['accessToken'] = unquote(params['accessToken'])
if statuscode == '0': with requests.Session() as s:
if res['data']['live_status'] == '1': res = s.get(url, params=params)
anchor, = res['data']['anchor'] if res.status_code == 200:
real_url = anchor['media_url'] res = res.json()
return real_url 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: else:
raise Exception('未开播') raise Exception('房间不存在 或 权限检查错误')
else: else:
raise Exception('房间不存在 或 权限检查错误') raise Exception('请求错误')
else:
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
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): def get_real_url(rid):
try: try:
response = requests.get('http://m.longzhu.com/' + str(rid)).text lz = LongZhu(rid)
roomId = re.findall(r'roomId = (\d*);', response)[0] return lz.get_real_url()
response = requests.get('http://livestream.longzhu.com/live/getlivePlayurl?roomId={}&hostPullType=2&isAdvanced=true&playUrlsType=1'.format(roomId)).json() except Exception as e:
real_url = response.get('playLines')[0].get('urls')[-1].get('securityUrl') print('Exception', e)
except: return False
real_url = '直播间不存在或未开播'
return real_url
rid = input('请输入龙珠直播房间号:\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入龙珠直播房间号:\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

33
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
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): def get_real_url(rid):
try: try:
response = requests.post(url='https://look.163.com/live?id=' + rid).text look = Look(rid)
real_url = re.findall(r'"liveUrl":([\s\S]*),"liveType"', response)[0] return look.get_real_url()
except: except Exception as e:
real_url = '该直播间不存在或未开播' print('Exception', e)
return real_url return False
rid = input('请输入look直播房间号\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入Look直播房间号\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

44
now.py
View File

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

47
pps.py
View File

@ -5,24 +5,37 @@ import re
import time 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): def get_real_url(rid):
try: try:
response = requests.get('http://m-x.pps.tv/room/' + str(rid)).text pps = PPS(rid)
anchor_id = re.findall(r'anchor_id":(\d*),"online_uid', response)[0] return pps.get_real_url()
tt = int(time.time() * 1000) except Exception as e:
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) print('Exception', e)
headers = { return False
'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
rid = input('请输入奇秀直播房间号:\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入奇秀直播房间号:\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

33
qf.py
View File

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

41
qie.py
View File

@ -1,22 +1,37 @@
# 企鹅体育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:
with requests.Session() as s:
res = s.get('https://m.live.qq.com/' + str(rid)) def __init__(self, rid):
show_status = re.search(r'"show_status":"(\d)"', res.text) self.rid = rid
if show_status:
if show_status.group(1) == '1': def get_real_url(self):
hls_url = re.search(r'"hls_url":"(.*)","use_p2p"', res.text).group(1) with requests.Session() as s:
return hls_url 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: else:
raise Exception('未开播') raise Exception('直播间不存在')
else:
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,33 +1,48 @@
# 人人直播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:
with requests.Session() as s:
res = s.get('http://activity.renren.com/liveroom/' + str(rid)) def __init__(self, rid):
livestate = re.search(r'"liveState":(\d)', res.text) self.rid = rid
if livestate:
try: def get_real_url(self):
s = re.search(r'"playUrl":"([\s\S]*?)"', res.text).group(1) with requests.Session() as s:
if livestate.group(1) == '0': res = s.get('http://activity.renren.com/liveroom/' + str(self.rid))
accesskey = re.search(r'accesskey=(\w+)', s).group(1) livestate = re.search(r'"liveState":(\d)', res.text)
expire = re.search(r'expire=(\d+)', s).group(1) if livestate:
live = re.search(r'(/live/\d+)', s).group(1) try:
c = accesskey + expire + live s = re.search(r'"playUrl":"([\s\S]*?)"', res.text).group(1)
key = hashlib.md5(c.encode('utf-8')).hexdigest() if livestate.group(1) == '0':
e = s.split('?')[0].split('/')[4] accesskey = re.search(r'accesskey=(\w+)', s).group(1)
t = 'http://ksy-hls.renren.com/live/' + e + '/index.m3u8?key=' + key expire = re.search(r'expire=(\d+)', s).group(1)
return t live = re.search(r'(/live/\d+)', s).group(1)
elif livestate.group(1) == '1': c = accesskey + expire + live
return '回放:' + s key = hashlib.md5(c.encode('utf-8')).hexdigest()
except IndexError: e = s.split('?')[0].split('/')[4]
raise Exception('解析错误') t = 'http://ksy-hls.renren.com/live/' + e + '/index.m3u8?key=' + key
else: return t
raise Exception('直播间不存在') 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__': if __name__ == '__main__':
r = input('输入人人直播房间号:\n') r = input('输入人人直播房间号:\n')
print(renren(r)) print(get_real_url(r))

View File

@ -1,49 +1,64 @@
# 秀色直播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:
with requests.Session() as s:
res = s.get('https://service.showself.com/v2/custuser/visitor').json() def __init__(self, rid):
uid = res['data']['uid'] self.rid = rid
accesstoken = sessionid = res['data']['sessionid']
params = { def get_real_url(self):
'accessToken': accesstoken, with requests.Session() as s:
'tku': uid, res = s.get('https://service.showself.com/v2/custuser/visitor').json()
'_st1': int(time.time() * 1000) uid = res['data']['uid']
} accesstoken = sessionid = res['data']['sessionid']
payload = { params = {
'groupid': '999', 'accessToken': accesstoken,
'roomid': rid, 'tku': uid,
'sessionid': sessionid, '_st1': int(time.time() * 1000)
'sessionId': sessionid }
} payload = {
data = dict(params, **payload) 'groupid': '999',
data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5' 'roomid': self.rid,
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest() 'sessionid': sessionid,
payload['_ajaxData1'] = _ajaxData1 'sessionId': sessionid
url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(rid, urlencode(params)) }
with requests.Session() as s: data = dict(params, **payload)
res = s.post(url, json=payload) data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5'
if res.status_code == 200: _ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
res = res.json() payload['_ajaxData1'] = _ajaxData1
statuscode = res['status']['statuscode'] url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(self.rid, urlencode(params))
if statuscode == '0': with requests.Session() as s:
if res['data']['roomInfo']['live_status'] == '1': res = s.post(url, json=payload)
anchor, = res['data']['roomInfo']['anchor'] if res.status_code == 200:
real_url = anchor['media_url'] res = res.json()
return real_url 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: else:
raise Exception('未开播') raise Exception('房间不存在')
else: else:
raise Exception('房间不存在') raise Exception('参数错误')
else:
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))

41
tuho.py
View File

@ -1,23 +1,38 @@
# 星光直播https://www.tuho.tv/28545037 # 星光直播https://www.tuho.tv/28545037
import requests import requests
import re import re
def tuho(rid): class TuHo:
with requests.Session() as s:
res = s.get('https://www.tuho.tv/' + str(rid)).text def __init__(self, rid):
flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res) self.rid = rid
if flv:
status = re.search(r'isPlaying\s:\s(\w+),', res).group(1) def get_real_url(self):
if status == 'true': with requests.Session() as s:
real_url = flv.group(1).replace('\\', '') res = s.get('https://www.tuho.tv/' + str(self.rid)).text
return real_url 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: else:
raise Exception('未开播') raise Exception('直播间不存在')
else:
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))

42
v6cn.py
View File

@ -4,21 +4,35 @@ import requests
import re 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): def get_real_url(rid):
try: try:
response = requests.get('https://v.6.cn/' + str(rid)).text v6cn = V6CN(rid)
result = re.findall(r'"flvtitle":"v(\d*?)-(\d*?)"', response)[0] return v6cn.get_real_url()
uid = result[0] except Exception as e:
flvtitle = 'v{}-{}'.format(*result) print('Exception', e)
response = requests.get('https://rio.6rooms.com/live/?s=' + str(uid)).text return False
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
rid = input('请输入六间房直播ID\n') if __name__ == '__main__':
real_url = get_real_url(rid) r = input('请输入六间房直播房间号:\n')
print('该直播间源地址为:') print(get_real_url(r))
print(real_url)

39
wali.py
View File

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

View File

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

View File

@ -1,41 +1,57 @@
# 迅雷直播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:
url = 'https://biz-live-ssl.xunlei.com//caller'
headers = { def __init__(self, rid):
'cookie': 'appid=1002' self.rid = rid
}
_t = int(time.time() * 1000) def get_real_url(self):
u = '1002' url = 'https://biz-live-ssl.xunlei.com//caller'
f = '&*%$7987321GKwq' headers = {
params = { 'cookie': 'appid=1002'
'_t': _t, }
'a': 'play', _t = int(time.time() * 1000)
'c': 'room', u = '1002'
'hid': 'h5-e70560ea31cc17099395c15595bdcaa1', f = '&*%$7987321GKwq'
'uuid': rid, params = {
} '_t': _t,
data = urlencode(params) 'a': 'play',
p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest() 'c': 'room',
params['sign'] = p 'hid': 'h5-e70560ea31cc17099395c15595bdcaa1',
with requests.Session() as s: 'uuid': self.rid,
res = s.get(url, params=params, headers=headers).json() }
if res['result'] == 0: data = urlencode(params)
play_status = res['data']['play_status'] p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest()
if play_status == 1: params['sign'] = p
real_url = res['data']['data']['stream_pull_https'] with requests.Session() as s:
return real_url 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: else:
raise Exception('未开播') raise Exception('直播间可能不存在')
else:
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,41 +1,50 @@
# 获取一直播的真实流媒体地址。 # 获取一直播的真实流媒体地址。
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:
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: try:
scid = re.findall(r'/l/(\S*).html', room_url)[0] yzb = YiZhiBo(rid)
flvurl = 'http://alcdn.f01.xiaoka.tv/live/{}.flv'.format(scid) return yzb.get_real_url()
m3u8url = 'http://al01.alcdn.hls.xiaoka.tv/live/{}.m3u8'.format(scid) except Exception as e:
rtmpurl = 'rtmp://alcdn.r01.xiaoka.tv/live/live/{}'.format(scid) print('Exception', e)
real_url = { return False
'flvurl': flvurl,
'm3u8url': m3u8url,
'rtmpurl': rtmpurl
}
except:
real_url = '链接错误'
return real_url
def get_status(room_url): if __name__ == '__main__':
try: r = input('请输入一直播房间地址:\n')
scid = re.findall(r'/l/(\S*).html', room_url)[0] print(get_real_url(r))
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)

View File

@ -3,36 +3,51 @@
# 而且没有平台水印和主播自己贴的乱七八糟的字幕遮挡。 # 而且没有平台水印和主播自己贴的乱七八糟的字幕遮挡。
# 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:
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: try:
tt = str(int(time.time() * 1000)) yk = YouKu(rid)
data = json.dumps({'liveId': liveid, 'app': 'Pc'}, separators=(',', ':')) return yk.get_real_url()
url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788' except Exception as e:
s = requests.Session() print('Exception', e)
cookies = s.get(url).cookies return False
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
if __name__ == '__main__': if __name__ == '__main__':
r = input('输入优酷轮播台liveId\n') r = input('请输入优酷轮播台房间号:\n')
print(youku(r)) print(get_real_url(r))

View File

@ -3,21 +3,35 @@ import requests
import re import re
def yuanbobo(rid): class YuanBoBo:
with requests.Session() as s:
res = s.get('https://zhibo.yuanbobo.com/' + str(rid)).text def __init__(self, rid):
stream_id = re.search(r"stream_id:\s+'(\d+)'", res) self.rid = rid
if stream_id:
status = re.search(r"status:\s+'(\d)'", res).group(1) def get_real_url(self):
if status == '1': with requests.Session() as s:
real_url = 'http://ks-hlslive.yuanbobo.com/live/{}/index.m3u8'.format(stream_id.group(1)) res = s.get('https://zhibo.yuanbobo.com/' + str(self.rid)).text
return real_url 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: else:
raise Exception('未开播') raise Exception('直播间不存在')
else:
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))

61
yy.py
View File

@ -1,35 +1,50 @@
# 获取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:
headers = {
'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=rid), def __init__(self, rid):
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)' self.rid = rid
' Version/11.0 Mobile/15A372 Safari/604.1'
} def get_real_url(self):
room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=rid) headers = {
with requests.Session() as s: 'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=self.rid),
res = s.get(room_url, headers=headers) 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)'
if res.status_code == 200: ' Version/11.0 Mobile/15A372 Safari/604.1'
data = json.loads(res.text[1:-1]) }
if data.get('hls', 0): room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=self.rid)
xa = data['audio'] with requests.Session() as s:
xv = data['video'] res = s.get(room_url, headers=headers)
xv = re.sub(r'0_\d+_0', '0_0_0', xv) if res.status_code == 200:
url = 'https://interface.yy.com/hls/get/stream/15013/{}/15013/{}?source=h5player&type=m3u8'.format(xv, xa) data = json.loads(res.text[1:-1])
res = s.get(url).json() if data.get('hls', 0):
real_url = res['hls'] xa = data['audio']
return real_url 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: else:
raise Exception('未开播') raise Exception('直播间不存在')
else:
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,23 +3,37 @@
import requests import requests
def zhanqi(rid): class ZhanQi:
with requests.Session() as s:
res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(rid)) def __init__(self, rid):
try: self.rid = rid
res = res.json()
videoid = res['data']['videoId'] def get_real_url(self):
status = res['data']['status'] with requests.Session() as s:
if status == '4': res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid) try:
real_url = s.get(url).text res = res.json()
else: videoid = res['data']['videoId']
real_url = '未开播' status = res['data']['status']
except: if status == '4':
real_url = '直播间不存在' url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
return real_url 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__': if __name__ == '__main__':
r = input('输入战旗直播房间号:\n') r = input('输入战旗直播房间号:\n')
print(zhanqi(r)) print(get_real_url(r))