1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-08-05 01:41:32 +08:00

Compare commits

..

No commits in common. "89e4a356f16b3a3078585868ba6d25b947d1c4cf" and "c4ab4dfb71350fcb62fdcad83dab755b17058c7d" have entirely different histories.

54 changed files with 1014 additions and 3169 deletions

42
173.py
View File

@ -1,38 +1,22 @@
# 艺气山直播http://www.173.com/room/category?categoryId=11 # 艺气山直播http://www.173.com/room/category?categoryId=11
import requests import requests
class YQS: def _173(rid):
params = 'roomId={}&format=m3u8'.format(rid)
def __init__(self, rid): with requests.Session() as s:
self.rid = rid res = s.post('http://www.173.com/room/getVieoUrl', params=params).json()
data = res['data']
def get_real_url(self): if data:
params = 'roomId={}&format=m3u8'.format(self.rid) status = data['status']
with requests.Session() as s: if status == 2:
res = s.post('http://www.173.com/room/getVieoUrl', params=params).json() return data['url']
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(get_real_url(r)) print(_173(r))

View File

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

42
2cq.py
View File

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

75
51lm.py
View File

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

View File

@ -1,39 +1,23 @@
# 95秀http://www.95.cn/ # 95秀http://www.95.cn/
import requests import requests
import re import re
class JWXiu: def jwxiu(rid):
with requests.Session() as s:
def __init__(self, rid): res = s.get('http://www.95.cn/{}.html'.format(rid)).text
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:
jwx = JWXiu(rid) uid = re.search(r'"uid":(\d+),', res).group(1)
return jwx.get_real_url() status = re.search(r'"is_offline":"(\d)"', res).group(1)
except Exception as e: except AttributeError:
print('Exception', e) raise Exception('没有找到直播间')
return False if status == '0':
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(get_real_url(r)) print(jwxiu(r))

51
9xiu.py
View File

@ -1,41 +1,26 @@
# 九秀直播https://www.9xiu.com/other/classify?tag=all&index=all # 九秀直播https://www.9xiu.com/other/classify?tag=all&index=all
import requests import requests
class JXiu: def j_xiu(rid):
with requests.Session() as s:
def __init__(self, rid): url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str(rid)
self.rid = rid headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) '
def get_real_url(self): 'AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
with requests.Session() as s: }
url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str( self.rid) res = s.get(url, headers=headers).json()
headers = { if res['code'] == 200:
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) ' status = res['data']['status']
'AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1' if status == 0:
} raise Exception('未开播')
res = s.get(url, headers=headers).json() elif status == 1:
if res['code'] == 200: live_url = res['data']['live_url']
status = res['data']['status'] return live_url
if status == 0: else:
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(get_real_url(r)) print(j_xiu(r))

View File

@ -10,7 +10,7 @@
**48** 个直播平台的直播源获取:斗鱼直播、虎牙直播、哔哩哔哩直播、战旗直播、网易 CC 直播、火猫直播、企鹅电竞、YY 直播、一直播、快手直播、花椒直播、映客直播、西瓜直播、触手直播、NOW 直播、抖音直播爱奇艺直播、酷狗直播、龙珠直播、PPS 奇秀直播、六间房、17 直播、来疯直播、优酷轮播台、网易 LOOK 直播、千帆直播、陌陌直播、小米直播、迅雷直播、京东直播、企鹅体育、人人直播、棉花糖直播、九秀直播、羚萌直播、95秀、新浪疯播、红人直播、艾米直播、KK直播、酷我聚星、乐嗨直播、秀色直播、星光直播、我秀直播、热猫直播、艺气山直播、AcFun 直播。 **48** 个直播平台的直播源获取:斗鱼直播、虎牙直播、哔哩哔哩直播、战旗直播、网易 CC 直播、火猫直播、企鹅电竞、YY 直播、一直播、快手直播、花椒直播、映客直播、西瓜直播、触手直播、NOW 直播、抖音直播爱奇艺直播、酷狗直播、龙珠直播、PPS 奇秀直播、六间房、17 直播、来疯直播、优酷轮播台、网易 LOOK 直播、千帆直播、陌陌直播、小米直播、迅雷直播、京东直播、企鹅体育、人人直播、棉花糖直播、九秀直播、羚萌直播、95秀、新浪疯播、红人直播、艾米直播、KK直播、酷我聚星、乐嗨直播、秀色直播、星光直播、我秀直播、热猫直播、艺气山直播、AcFun 直播。
**18** 个直播平台的弹幕获取:斗鱼直播、虎牙直播、哔哩哔哩直播、快手直播、火猫直播、企鹅电竞、花椒直播、映客直播、网易 CC 直播、酷狗直播、龙珠直播、PPS 奇秀、搜狐千帆、战旗直播、来疯直播、网易 LOOK 直播、AcFun 直播、艺气山直播。 **16** 个直播平台的弹幕获取:斗鱼直播、虎牙直播、哔哩哔哩直播、快手直播、火猫直播、企鹅电竞、花椒直播、映客直播、网易 CC 直播、酷狗直播、龙珠直播、PPS 奇秀、搜狐千帆、战旗直播、来疯直播、网易 LOOK 直播。
## 运行 ## 运行
@ -25,9 +25,7 @@
## 更新 ## 更新
### 2020.09.12新增斗鱼添加一个从PC网页端获取直播源的方法可选线路和清晰度新增requirements.txt文件更新代码。 ### 2020.08.18:更新快手直播源,现在播放链接需要带参数;更新快手直播弹幕,直接用 protobuf 序列化;新增 AcFun、艺气山两个平台的弹幕功能。
2020.08.18:更新快手直播源,现在播放链接需要带参数;更新快手直播弹幕,直接用 protobuf 序列化;新增 AcFun、艺气山两个平台的弹幕功能。
2020.08.08:新增 AcFun 直播、艺气山直播;更新:哔哩哔哩直播、虎牙直播、红人直播;优化:斗鱼直播。 2020.08.08:新增 AcFun 直播、艺气山直播;更新:哔哩哔哩直播、虎牙直播、红人直播;优化:斗鱼直播。

View File

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

View File

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

48
cc.py
View File

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

View File

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

View File

@ -3,7 +3,7 @@ import re
import aiohttp import aiohttp
from .yqs import YiQiShan from ._173 import YiQiShan
from .acfun import AcFun from .acfun import AcFun
from .bilibili import Bilibili from .bilibili import Bilibili
from .cc import CC from .cc import CC
@ -21,7 +21,6 @@ from .look import Look
from .pps import QiXiu from .pps import QiXiu
from .qf import QF from .qf import QF
from .zhanqi import ZhanQi from .zhanqi import ZhanQi
from .yy import YY
__all__ = ['DanmakuClient'] __all__ = ['DanmakuClient']
@ -56,8 +55,7 @@ class DanmakuClient:
'laifeng.com': LaiFeng, 'laifeng.com': LaiFeng,
'look.163.com': Look, 'look.163.com': Look,
'acfun.cn': AcFun, 'acfun.cn': AcFun,
'173.com': YiQiShan, '173.com': YiQiShan}.items():
'yy.com': YY}.items():
if re.match(r'^(?:http[s]?://)?.*?%s/(.+?)$' % u, url): if re.match(r'^(?:http[s]?://)?.*?%s/(.+?)$' % u, url):
self.__site = s self.__site = s
self.__u = u self.__u = u
@ -116,77 +114,56 @@ class DanmakuClient:
await self.__dm_queue.put(m) await self.__dm_queue.put(m)
count += 1 count += 1
async def init_ws_acfun(self): async def init_ws_acfun(self, s):
self.__ws = await self.__hs.ws_connect(self.__site.ws_url) self.__ws = await self.__hs.ws_connect(self.__site.ws_url)
await self.__ws.send_bytes(self.__s.encode_packet('register')) await self.__ws.send_bytes(s.encode_packet('register'))
async def ping_acfun(self): async def ping_acfun(self, s):
while True: while True:
await asyncio.sleep(1) await asyncio.sleep(1)
await self.__ws.send_bytes(self.__s.encode_packet('ping')) await self.__ws.send_bytes(s.encode_packet('ping'))
async def keepalive_acfun(self): async def keepalive_acfun(self, s):
while True: while True:
await asyncio.sleep(50) await asyncio.sleep(50)
await self.__ws.send_bytes(self.__s.encode_packet('keepalive')) await self.__ws.send_bytes(s.encode_packet('keepalive'))
async def heartbeat_acfun(self): async def heartbeat_acfun(self, s):
while True: while True:
await asyncio.sleep(10) await asyncio.sleep(10)
await self.__ws.send_bytes(self.__s.encode_packet('ztlivecsheartbeat')) await self.__ws.send_bytes(s.encode_packet('ztlivecsheartbeat'))
async def fetch_danmaku_acfun(self): async def fetch_danmaku_acfun(self, s):
count = 0 count = 0
async for msg in self.__ws: async for msg in self.__ws:
self.__link_status = True self.__link_status = True
ms = self.__s.decode_packet(msg.data) ms = s.decode_packet(msg.data)
if count == 0: if count == 0:
await self.__ws.send_bytes(self.__s.encode_packet('ztlivecsenterroom')) await self.__ws.send_bytes(s.encode_packet('ztlivecsenterroom'))
count += 1 count += 1
for m in ms: for m in ms:
await self.__dm_queue.put(m) await self.__dm_queue.put(m)
async def init_ws_173(self): async def init_ws_173(self, s):
self.__ws = await self.__hs.ws_connect(self.__site.ws_url) self.__ws = await self.__hs.ws_connect(self.__site.ws_url)
await self.__ws.send_bytes(self.__s.pack('startup')) await self.__ws.send_bytes(s.pack('startup'))
await asyncio.sleep(1) await asyncio.sleep(1)
await self.__ws.send_bytes(self.__s.pack('enterroomreq')) await self.__ws.send_bytes(s.pack('enterroomreq'))
async def tcphelloreq_173(self): async def tcphelloreq_173(self, s):
while True: while True:
await asyncio.sleep(10) await asyncio.sleep(10)
await self.__ws.send_bytes(self.__s.pack('tcphelloreq')) await self.__ws.send_bytes(s.pack('tcphelloreq'))
async def roomhelloreq_173(self): async def roomhelloreq_173(self, s):
while True: while True:
await asyncio.sleep(5) await asyncio.sleep(5)
await self.__ws.send_bytes(self.__s.pack('roomhelloreq')) await self.__ws.send_bytes(s.pack('roomhelloreq'))
async def fetch_danmaku_173(self): async def fetch_danmaku_173(self, s):
async for msg in self.__ws: async for msg in self.__ws:
self.__link_status = True self.__link_status = True
ms = self.__s.unpack(msg.data) ms = s.unpack(msg.data)
for m in ms:
await self.__dm_queue.put(m)
async def init_ws_yy(self):
self.__ws = await self.__hs.ws_connect(self.__site.ws_url)
await self.__ws.send_bytes(self.__s.LoginUDB())
async def heartbeat_yy(self):
while True:
await asyncio.sleep(10)
await self.__ws.send_bytes(self.__s.pingAp())
async def fetch_danmaku_yy(self):
count = 0
async for msg in self.__ws:
self.__link_status = True
ms = self.__s.onProto(msg.data)
if count == 0:
await self.__ws.send_bytes(self.__s.loginAp())
await self.__ws.send_bytes(self.__s.joinServiceBc())
count += 1
for m in ms: for m in ms:
await self.__dm_queue.put(m) await self.__dm_queue.put(m)
@ -195,30 +172,22 @@ class DanmakuClient:
await self.init_ws_huajiao() await self.init_ws_huajiao()
elif self.__u == 'acfun.cn': elif self.__u == 'acfun.cn':
rid = re.search(r'\d+', self.__url).group(0) rid = re.search(r'\d+', self.__url).group(0)
self.__s = self.__site(rid) s = self.__site(rid)
await self.init_ws_acfun() await self.init_ws_acfun(s)
await asyncio.gather( await asyncio.gather(
self.ping_acfun(), self.ping_acfun(s),
self.fetch_danmaku_acfun(), self.fetch_danmaku_acfun(s),
self.keepalive_acfun(), self.keepalive_acfun(s),
self.heartbeat_acfun(), self.heartbeat_acfun(s),
) )
elif self.__u == '173.com': elif self.__u == '173.com':
rid = self.__url.split('/')[-1] rid = self.__url.split('/')[-1]
self.__s = self.__site(rid) s = self.__site(rid)
await self.init_ws_173() await self.init_ws_173(s)
await asyncio.gather( await asyncio.gather(
self.fetch_danmaku_173(), self.fetch_danmaku_173(s),
self.tcphelloreq_173(), self.tcphelloreq_173(s),
self.roomhelloreq_173(), self.roomhelloreq_173(s),
)
elif self.__u == 'yy.com':
rid = self.__url.split('/')[-1]
self.__s = self.__site(int(rid))
await self.init_ws_yy()
await asyncio.gather(
self.fetch_danmaku_yy(),
self.heartbeat_yy()
) )
else: else:
await self.init_ws() await self.init_ws()

View File

@ -1,139 +0,0 @@
syntax = "proto2";
package YiQishanPack;
message CSHead {
optional uint32 command = 1;
optional uint32 subcmd = 2;
optional uint32 seq = 3;
optional bytes uuid = 4;
optional uint32 clientType = 5;
optional uint32 headFlag = 6;
optional uint32 clientVer = 7;
optional bytes signature = 8;
optional uint32 routeKey = 9;
}
message TCPAccessReq {
optional bytes AccessToken = 1;
optional bytes MachineCode = 2;
}
message TcpHelloReq {
optional string uuid = 1;
}
message EnterRoomReq {
optional bytes uuid = 1;
optional bytes roomid = 2;
optional uint32 neednum = 3;
optional bool isfake = 4;
optional bool needbroadcast = 5;
optional bytes nick = 6;
optional bytes clientip = 7;
optional bytes subroomid = 8;
optional uint32 gameid = 10;
}
message RoomHelloReq {
optional bytes uuid = 1;
optional bytes roomid = 2;
optional bytes roomsig = 3;
optional uint32 connsvrip = 4;
optional bool isinternal = 5;
optional bytes subroomid = 6;
}
message Token {
optional string uuid = 1;
optional bytes gtkey = 2;
optional uint32 ip = 3;
optional uint32 expiresstime = 4;
optional uint32 gentime = 5;
}
message PublicChatNotify {
optional bytes roomid = 1;
optional bytes uuid = 2;
optional bytes nick = 3;
optional ChatInfo info = 4;
optional bytes touuid = 5;
optional bytes tonick = 6;
optional uint32 privilege = 7;
optional uint32 rank = 8;
optional uint32 fromgame = 9;
optional bytes gameid = 10;
repeated BadgeType badges = 11;
optional RoomUserInfo userinfo = 12;
optional bool isnoble = 13;
optional uint32 noblelevelid = 14;
optional string noblelevelname = 15;
optional bool isnoblemessage = 16;
}
enum BadgeType {
NOBARRAGE = 0;
FIRST_CHARGE_BADGE = 1;
FIRST_CHARGE_COPPER = 2;
FIRST_CHARGE_SLIVER = 3;
FIRST_CHARGE_GOLD = 4;
}
message ChatInfo {
optional uint32 chattype = 1;
optional bytes textmsg = 2;
}
message RoomUserInfo {
optional bytes uuid = 1;
optional bytes nick = 2;
optional uint32 weekartistconsume = 3;
optional uint32 artisttotalconsume = 4;
optional uint32 totalconsume = 5;
optional uint32 guardendtime = 6;
optional uint32 peerageid = 7;
}
message GiftNotyInfo {
optional bytes roomid = 1;
optional bytes giftid = 2;
optional uint32 giftcnt = 3;
optional bytes fromuuid = 4;
optional bytes fromnick = 5;
optional bytes touuid = 6;
optional bytes tonick = 7;
optional uint32 consume = 8;
optional bytes sessid = 9;
optional uint32 hits = 10;
optional uint32 hitsall = 11;
optional uint32 flag = 12;
optional uint32 fromviplevel = 13;
optional uint32 fanslevel = 14;
optional bool fromisnoble = 15;
optional uint32 fromnoblelevelid = 16;
}
message NotifyFreeGift {
optional bytes uuid = 1;
optional bytes fromnick = 2;
optional bytes touuid = 3;
optional bytes tonick = 4;
optional bytes roomid = 5;
optional uint32 giftid = 6;
optional uint32 giftcnt = 7;
optional uint32 fromviplevel = 8;
optional uint32 fanslevel = 9;
optional bool fromisnoble = 11;
optional uint32 fromnoblelevelid = 12;
}
message SendBroadcastPkg {
optional bytes uuid = 1;
repeated BroadcastMsg broadcastmsg = 2;
message BroadcastMsg {
optional uint32 businesstype = 1;
optional bytes title = 2;
optional bytes content = 3;
optional uint32 msgseq = 4;
}
}

View File

@ -1,137 +0,0 @@
import binascii
import struct
import requests
from Crypto.Cipher import DES
from Crypto.Util.Padding import pad
from . import yqs_pb2 as pb
class YiQiShan:
ws_url = 'wss://websocket.173.com/'
def __init__(self, rid):
self.rid = str(rid)
self.key = b'e#>&*m16'
with requests.Session() as se:
res = se.get('http://www.173.com/{}'.format(rid))
try:
self.uuid, _, token, _ = res.cookies.values()
except ValueError:
raise Exception('房间不存在')
self.accesstoken = binascii.a2b_hex(token)
s = YiQiShan.des_decode(self.accesstoken, self.key)
p = pb.Token()
p.ParseFromString(s)
self.gtkey = p.gtkey[:8]
@staticmethod
def des_encode(t, key):
t = pad(t, DES.block_size)
c = DES.new(key, DES.MODE_ECB)
res = c.encrypt(t)
return res
@staticmethod
def des_decode(t, key):
c = DES.new(key, DES.MODE_ECB)
res = c.decrypt(t)
length = len(res)
padding = res[length - 1]
res = res[0:length - padding]
return res
def startup(self):
p = pb.TCPAccessReq()
p.AccessToken = self.accesstoken
return p.SerializeToString()
def tcphelloreq(self):
p = pb.TcpHelloReq()
p.uuid = self.uuid
return p.SerializeToString()
def enterroomreq(self):
p = pb.EnterRoomReq()
p.uuid = self.uuid.encode()
p.roomid = self.rid.encode()
return p.SerializeToString()
def roomhelloreq(self):
p = pb.RoomHelloReq()
p.uuid = self.uuid.encode()
p.roomid = self.rid.encode()
return p.SerializeToString()
def pack(self, paylod_type):
command = {
'startup': 123,
'tcphelloreq': 122,
'enterroomreq': 601,
'roomhelloreq': 600
}
subcmd = {
'startup': 0,
'tcphelloreq': 0,
'enterroomreq': 1,
'roomhelloreq': 1
}
p = pb.CSHead()
p.command = command[paylod_type]
p.subcmd = subcmd[paylod_type]
p.uuid = self.uuid.encode()
p.clientType = 4
p.routeKey = int(self.rid)
n = p.SerializeToString()
key = self.key if paylod_type == 'startup' else self.gtkey
payload = getattr(self, paylod_type)()
s = YiQiShan.des_encode(payload, key)
buf = struct.pack('!HcH', len(n) + len(s) + 8, b'W', len(n))
buf += n
buf += struct.pack('!H', len(s))
buf += s + b'M'
return buf
def unpack(self, data):
msgs = [{'name': '', 'content': '', 'msg_type': 'other'}]
s, = struct.unpack_from('!h', data, 3)
p, = struct.unpack_from('!h', data, 5 + s)
u = data[7 + s:7 + s + p]
a = pb.CSHead()
a.ParseFromString(data[5:5 + s])
cmd = a.command
key = self.key if cmd == 123 else self.gtkey
t = u if cmd == 102 else YiQiShan.des_decode(u, key)
o = cmd
# r = a.subcmd
if o == 102:
p = pb.SendBroadcastPkg()
p.ParseFromString(t)
for i in p.broadcastmsg:
# PublicChatNotify = 1
# BUSINESS_TYPE_FREE_GIFT = 2
# BUSINESS_TYPE_PAY_GIFT = 3
if i.businesstype == 1: # 发言
q = pb.PublicChatNotify()
q.ParseFromString(i.content)
user = q.nick.decode()
content = q.info.textmsg.decode()
# elif i.businesstype == 2: # 免费礼物
# print(i.businesstype)
# q = pb.NotifyFreeGift()
# q.ParseFromString(i.content)
# elif i.businesstype == 3: # 收费礼物
# print(i.businesstype)
# q = pb.GiftNotyInfo()
# q.ParseFromString(i.content)
# else:
# pass
msg = {'name': user, 'content': content, 'msg_type': 'danmaku'}
msgs.append(msg.copy())
return msgs

File diff suppressed because it is too large Load Diff

View File

@ -2,40 +2,28 @@
# 如果知道该直播间如“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:
dy = DouYin(rid) if 'v.douyin.com' in rid:
return dy.get_real_url() room_id = re.findall(r'(\d{19})', requests.get(url=rid).url)[0]
except Exception as e: else:
print('Exception', e) room_id = rid
return False room_url = 'https://webcast-hl.amemv.com/webcast/room/reflow/info/?room_id={}&live_id=1'.format(room_id)
response = requests.get(url=room_url).json()
hls_pull_url = response.get('data').get('room').get('stream_url').get('hls_pull_url')
rtmp_pull_url = response.get('data').get('room').get('stream_url').get('rtmp_pull_url')
real_url = [rtmp_pull_url, hls_pull_url]
except:
real_url = '直播间不存在或未开播或参数错误'
return real_url
if __name__ == '__main__': rid = input('请输入抖音直播间room_id或分享链接\n')
r = input('请输入抖音直播间room_id或分享链接\n') real_url = get_real_url(rid)
print(get_real_url(r)) print('该直播间源地址为:')
print(real_url)

View File

@ -1,10 +1,9 @@
# 获取斗鱼直播间的真实流媒体地址,默认最高画质。 # 获取斗鱼直播间的真实流媒体地址,默认最高画质。
import hashlib
import re
import time
import execjs
import requests import requests
import re
import execjs
import time
import hashlib
class DouYu: class DouYu:
@ -72,35 +71,6 @@ class DouYu:
return key return key
def get_pc_js(self, cdn='ws-h5', rate=0):
"""
通过PC网页端的接口获取完整直播源
:param cdn: 主线路ws-h5备用线路tct-h5
:param rate: 1流畅2高清3超清4蓝光4M0蓝光8M或10M
:return: JSON格式
"""
res = self.s.get('https://www.douyu.com/' + str(self.rid)).text
result = re.search(r'(vdwdae325w_64we[\s\S]*function ub98484234[\s\S]*?)function', res).group(1)
func_ub9 = re.sub(r'eval.*?;}', 'strc;}', result)
js = execjs.compile(func_ub9)
res = js.call('ub98484234')
v = re.search(r'v=(\d+)', res).group(1)
rb = DouYu.md5(self.rid + self.did + self.t10 + v)
func_sign = re.sub(r'return rt;}\);?', 'return rt;}', res)
func_sign = func_sign.replace('(function (', 'function sign(')
func_sign = func_sign.replace('CryptoJS.MD5(cb).toString()', '"' + rb + '"')
js = execjs.compile(func_sign)
params = js.call('sign', self.rid, self.did, self.t10)
params += '&cdn={}&rate={}'.format(cdn, rate)
url = 'https://www.douyu.com/lapi/live/getH5Play/{}'.format(self.rid)
res = self.s.post(url, params=params).json()
return res
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:
@ -111,6 +81,7 @@ class DouYu:
raise Exception('房间未开播') raise Exception('房间未开播')
else: else:
key = self.get_js() key = self.get_js()
return "http://tx2play1.douyucdn.cn/live/{}.flv?uuid=".format(key) return "http://tx2play1.douyucdn.cn/live/{}.flv?uuid=".format(key)

View File

@ -1,55 +1,42 @@
# 获取企鹅电竞的真实流媒体地址。 # 获取企鹅电竞的真实流媒体地址。
# 默认画质为超清 # 默认画质为超清
import requests import requests
import json
import re import re
class EGame:
def __init__(self, rid):
self.rid = rid
def get_real_url(self):
room_url = 'https://share.egame.qq.com/cgi-bin/pgg_async_fcgi'
post_data = {
'param': '''{"0":{"module":"pgg_live_read_svr","method":"get_live_and_profile_info","param":{"anchor_id":'''
+ str(self.rid) + ''',"layout_id":"hot","index":1,"other_uid":0}}}'''
}
try:
response = requests.post(url=room_url, data=post_data).json()
data = response.get('data', 0)
if data:
video_info = data.get('0').get(
'retBody').get('data').get('video_info')
pid = video_info.get('pid', 0)
if pid:
is_live = data.get('0').get(
'retBody').get('data').get('profile_info').get('is_live', 0)
if is_live:
play_url = video_info.get('stream_infos')[
0].get('play_url')
real_url = re.findall(r'([\w\W]+?)&uid=', play_url)[0]
else:
raise Exception('直播间未开播')
else:
raise Exception('直播间未启用')
else:
raise Exception('直播间不存在')
except:
raise Exception('数据请求错误')
return real_url
def get_real_url(rid): def get_real_url(rid):
room_url = 'https://share.egame.qq.com/cgi-bin/pgg_async_fcgi'
post_data = {
'param': '''{"0":{"module":"pgg_live_read_svr","method":"get_live_and_profile_info","param":{"anchor_id":''' + str(rid) + ''',"layout_id":"hot","index":1,"other_uid":0}}}'''
}
try: try:
eg = EGame(rid) response = requests.post(url=room_url, data=post_data).json()
return eg.get_real_url() data = response.get('data', 0)
except Exception as e: if data:
print('Exception', e) video_info = data.get('0').get(
return False 'retBody').get('data').get('video_info')
pid = video_info.get('pid', 0)
if pid:
is_live = data.get('0').get(
'retBody').get('data').get('profile_info').get('is_live', 0)
if is_live:
play_url = video_info.get('stream_infos')[
0].get('play_url')
real_url = re.findall(r'([\w\W]+?)&uid=', play_url)[0]
else:
real_url = '直播间未开播'
else:
real_url = '直播间未启用'
else:
real_url = '直播间不存在'
except:
real_url = '数据请求错误'
return real_url
if __name__ == '__main__': rid = input('请输入企鹅电竞房间号:\n')
r = input('请输入企鹅电竞房间号:\n') real_url = get_real_url(rid)
print(get_real_url(r)) print('该直播间源地址为:\n' + real_url)

View File

@ -1,6 +1,5 @@
# 新浪疯播直播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
@ -8,46 +7,32 @@ import json
import requests import requests
class FengBo: def fengbo(rid):
with requests.Session() as s:
res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(rid)).json()
if res['ret'] == 1:
info = res['info']
info = unquote(info, 'utf-8')
def __init__(self, rid): # 开始AES解密
self.rid = rid def pad(t):
return t + (16 - len(t) % 16) * b'\x00'
def get_real_url(self): key = iv = 'abcdefghqwertyui'.encode('utf8')
with requests.Session() as s: cipher = AES.new(key, AES.MODE_CBC, iv)
res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(self.rid)).json() info = info.encode('utf8')
if res['ret'] == 1: info = pad(info)
info = res['info'] result = cipher.decrypt(base64.decodebytes(info)).rstrip(b'\0')
info = unquote(info, 'utf-8')
# 开始AES解密 result = json.loads(result.decode('utf-8'))
def pad(t): url = result['url']
return t + (16 - len(t) % 16) * b'\x00' url = url.replace('hdl', 'hls')
url = url.replace('.flv', '/playlist.m3u8')
key = iv = 'abcdefghqwertyui'.encode('utf8') return url
cipher = AES.new(key, AES.MODE_CBC, iv) else:
info = info.encode('utf8') raise Exception('房间号错误')
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(get_real_url(r)) print(fengbo(r))

121
hongle.py
View File

@ -1,7 +1,6 @@
# 红人直播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
@ -10,80 +9,66 @@ import hashlib
import json import json
class HongLe: def hongle(rid):
# 模拟登陆
with requests.Session() as s:
pass
def __init__(self, rid): tt = int(time.time() * 1000)
self.rid = rid url = 'https://service.hongle.tv/v2/userw/login?_st1={}'.format(tt)
data = {
'_st1': tt,
'geetest_challenge': '7f4f6fd6257799c0bcac1f38c21c042dl0',
'geetest_seccode': 'd1163915f4cfd6c998014c4ca8899c9d|jordan',
'geetest_validate': 'd1163915f4cfd6c998014c4ca8899c9d',
'name': '16530801176',
'password': 'QTXz9/Sp40BbMHwVtcb7AQ==',
}
def get_real_url(self): data1 = urlencode(data) + 'yuj1ah5o'
# 模拟登陆 _ajaxdata1 = hashlib.md5(data1.encode('utf-8')).hexdigest()
with requests.Session() as s: data['_ajaxData1'] = _ajaxdata1
pass del data['_st1']
data = json.dumps(data, separators=(',', ':'))
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
res = s.post(url, data=data, headers=headers).json()
if res['status']['statuscode'] == '0':
sessionid = res['data']['sessionid']
else:
raise Exception('登陆信息过期')
tt = int(time.time() * 1000) url = 'https://service.hongle.tv/v2/roomw/media'
url = 'https://service.hongle.tv/v2/userw/login?_st1={}'.format(tt) accesstoken = sessionid
data = { params = {
'_st1': tt, '_st1': tt,
'geetest_challenge': '7f4f6fd6257799c0bcac1f38c21c042dl0', 'accessToken': accesstoken,
'geetest_seccode': 'd1163915f4cfd6c998014c4ca8899c9d|jordan', 'of': 1,
'geetest_validate': 'd1163915f4cfd6c998014c4ca8899c9d', 'showid': rid,
'name': '16530801176', 'tku': 43112608,
'password': 'QTXz9/Sp40BbMHwVtcb7AQ==', }
} data = urlencode(params) + 'yuj1ah5o'
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
params['_ajaxData1'] = _ajaxData1
params['accessToken'] = unquote(accesstoken)
data1 = urlencode(data) + 'yuj1ah5o' res = s.get(url, params=params)
_ajaxdata1 = hashlib.md5(data1.encode('utf-8')).hexdigest() if res.status_code == 200:
data['_ajaxData1'] = _ajaxdata1 res = res.json()
del data['_st1'] statuscode = res['status']['statuscode']
data = json.dumps(data, separators=(',', ':')) if statuscode == '0':
headers = {'Content-Type': 'application/x-www-form-urlencoded'} if res['data']['live_status'] == '1':
res = s.post(url, data=data, headers=headers).json() real_url = res['data']['media_url_web']
if res['status']['statuscode'] == '0': real_url = real_url.replace('http', 'https')
sessionid = res['data']['sessionid'] real_url = real_url.replace('__', '&')
else: return real_url
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: else:
raise Exception('房间不存在') raise Exception('未开播')
else: else:
raise Exception('参数错误') 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(get_real_url(r)) print(hongle(r))

View File

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

100
huomao.py
View File

@ -3,74 +3,62 @@
# 实际上使用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
class HuoMao: def get_time():
tt = str(int((time.time() * 1000)))
return tt
def __init__(self, rid):
self.rid = rid
@staticmethod def get_videoids(rid):
def get_time(): room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid)
tt = str(int((time.time() * 1000))) response = requests.get(url=room_url).text
return tt try:
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
@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):
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):
try: videoids = get_videoids(rid)
hm = HuoMao(rid) if videoids:
return hm.get_real_url() time = get_time()
except Exception as e: token = get_token(videoids, time)
print('Exception', e) room_url = 'https://www.huomao.com/swf/live_data'
return False post_data = {
'cdns': 1,
'streamtype': 'live',
'VideoIDS': videoids,
'from': 'huomaoh5room',
'time': time,
'token': token
}
response = requests.post(url=room_url, data=post_data).json()
roomStatus = response.get('roomStatus', 0)
if roomStatus == '1':
real_url_flv = response.get('streamList')[-1].get('list')[0].get('url')
real_url_m3u8 = response.get('streamList')[-1].get('list_hls')[0].get('url')
real_url = [real_url_flv, real_url_m3u8.replace('_480', '')]
else:
real_url = '直播间未开播'
else:
real_url = '直播间不存在'
return real_url
if __name__ == '__main__': rid = input('请输入火猫直播房间号:\n')
r = input('请输入火猫直播房间号:\n') real_url = get_real_url(rid)
print(get_real_url(r)) print('该直播间源地址为:')
print(real_url)

105
huya.py
View File

@ -1,6 +1,5 @@
# 获取虎牙直播的真实流媒体地址。 # 获取虎牙直播的真实流媒体地址。
# 虎牙"一起看"频道的直播间可能会卡顿 # 虎牙"一起看"频道的直播间可能会卡顿
import requests import requests
import re import re
import base64 import base64
@ -9,69 +8,53 @@ import hashlib
import time import time
class HuYa: def live(e):
i, b = e.split('?')
def __init__(self, rid): r = i.split('/')
self.rid = rid s = re.sub(r'.(flv|m3u8)', '', r[-1])
c = b.split('&', 3)
def get_real_url(self): c = [i for i in c if i != '']
try: n = {i.split('=')[0]: i.split('=')[1] for i in c}
room_url = 'https://m.huya.com/' + str(self.rid) fm = urllib.parse.unquote(n['fm'])
header = { u = base64.b64decode(fm).decode('utf-8')
'Content-Type': 'application/x-www-form-urlencoded', p = u.split('_')[0]
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 ' f = str(int(time.time() * 1e7))
'(KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36 ' ll = n['wsTime']
} t = '0'
response = requests.get(url=room_url, headers=header).text h = '_'.join([p, t, s, f, ll])
livelineurl = re.findall(r'liveLineUrl = "([\s\S]*?)";', response)[0] m = hashlib.md5(h.encode('utf-8')).hexdigest()
if livelineurl: y = c[-1]
if 'replay' in livelineurl: url = "{}?wsSecret={}&wsTime={}&u={}&seqid={}&{}".format(i, m, ll, t, f, y)
real_url = { return 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('?')
r = i.split('/')
s = re.sub(r'.(flv|m3u8)', '', r[-1])
c = b.split('&', 3)
c = [i for i in c if i != '']
n = {i.split('=')[0]: i.split('=')[1] for i in c}
fm = urllib.parse.unquote(n['fm'])
u = base64.b64decode(fm).decode('utf-8')
p = u.split('_')[0]
f = str(int(time.time() * 1e7))
ll = n['wsTime']
t = '0'
h = '_'.join([p, t, s, f, ll])
m = hashlib.md5(h.encode('utf-8')).hexdigest()
y = c[-1]
url = "{}?wsSecret={}&wsTime={}&u={}&seqid={}&{}".format(i, m, ll, t, f, y)
return url
def get_real_url(rid): def huya(room_id):
try: try:
hy = HuYa(rid) room_url = 'https://m.huya.com/' + str(room_id)
return hy.get_real_url() header = {
except Exception as e: 'Content-Type': 'application/x-www-form-urlencoded',
print('Exception', e) 'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 '
return False '(KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36 '
}
response = requests.get(url=room_url, headers=header).text
livelineurl = re.findall(r'liveLineUrl = "([\s\S]*?)";', response)[0]
if livelineurl:
if 'replay' in livelineurl:
return '直播录像https:' + livelineurl
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(get_real_url(rid)) print(huya(rid))

View File

@ -1,38 +1,23 @@
# 艾米直播https://www.imifun.com/ # 艾米直播https://www.imifun.com/
import requests import requests
import re import re
class IMFun: def imifun(rid):
with requests.Session() as s:
def __init__(self, rid): res = s.get('https://www.imifun.com/' + str(rid)).text
self.rid = rid roomid = re.search(r"roomId:\s'([\w-]+)'", res)
if roomid:
def get_real_url(self): status = re.search(r"isLive:(\d),", res).group(1)
with requests.Session() as s: if status == '1':
res = s.get('https://www.imifun.com/' + str(self.rid)).text real_url = 'https://wsmd.happyia.com/ivp/{}.flv'.format(roomid.group(1))
roomid = re.search(r"roomId:\s'([\w-]+)'", res) return real_url
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(get_real_url(r)) print(imifun(r))

View File

@ -1,43 +1,31 @@
import requests import requests
class ImMoMo: def immomo(rid):
def __init__(self, rid): url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos'
self.rid = rid data = {
'stid': rid,
'src': 'url'
}
def get_real_url(self): with requests.Session() as s:
url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos' s.get('https://web.immomo.com')
data = { res = s.post(url, data=data).json()
'stid': self.rid,
'src': 'url'
}
with requests.Session() as s: ec = res.get('ec', 0)
s.get('https://web.immomo.com') if ec != 200:
res = s.post(url, data=data).json() raise Exception('请求参数错误')
else:
ec = res.get('ec', 0) live = res['data']['live']
if ec != 200: if live:
raise Exception('请求参数错误') real_url = res['data']['url']
return real_url
else: else:
live = res['data']['live'] raise Exception('未开播')
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(get_real_url(r)) print(immomo(r))
# https://web.immomo.com/live/337033339

44
inke.py
View File

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

View File

@ -9,51 +9,39 @@ 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:
iqiyi = IQiYi(rid) response = requests.get('https://m-gamelive.iqiyi.com/w/' + rid).text
return iqiyi.get_real_url() # 获取直播间的qipuId
except Exception as e: qipuId = re.findall(r'"qipuId":(\d*?),"roomId', response)[0]
print('Exception', e) callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000'
return False params = {
'lp': qipuId,
'src': '01010031010000000000',
'rateVers': 'H5_QIYI',
'qd_v': 1,
'callback': callback
}
# ba传参iqiyi.js
ba = '/jp/live?' + urllib.parse.urlencode(params)
with open('iqiyi.js', 'r') as f:
content = f.read()
cmd5x = execjs.compile(content)
vf = cmd5x.call('cmd5x', ba)
# 请求
response = requests.get('https://live.video.iqiyi.com' + ba, params={'vf': vf}).text
url_json = json.loads(re.findall(r'try{.*?\((.*)\);}catch\(e\){};', response)[0])
real_url = (url_json.get('data').get('streams'))[0].get('url')
real_url = real_url.replace('hlslive.video.iqiyi.com', 'm3u8live.video.iqiyi.com')
except:
real_url = '直播间不存在或未开播'
return real_url
if __name__ == '__main__':
r = input('请输入爱奇艺直播房间号:\n') rid = input('请输入爱奇艺直播间id\n') # 如19732
print(get_real_url(r)) real_url = get_real_url(rid)
print('该直播间源地址为:')
print(real_url)

View File

@ -1,37 +1,22 @@
# 获取西瓜直播的真实流媒体地址。 # 获取西瓜直播的真实流媒体地址。
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:
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:83.0) Gecko/20100101 Firefox/83.0'
}
room_url = self.rid
response = requests.get(url=room_url, headers=headers).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:
xg = IXiGua(rid) room_url = rid
return xg.get_real_url() response = requests.get(url=room_url).text
except Exception as e: real_url = re.findall(r'playInfo":([\s\S]*?),"authStatus', response)[0]
print('Exception', e) real_url = re.sub(r'\\u002F', '/', real_url)
return False except:
real_url = '直播间不存在或未开播'
return real_url
if __name__ == '__main__': rid = input('请输入西瓜直播URL\n')
r = input('请输入西瓜直播房间号:\n') real_url = get_real_url(rid)
print(get_real_url(r)) print('该直播源地址为:')
print(real_url)

59
jd.py
View File

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

50
kk.py
View File

@ -2,40 +2,26 @@
import requests import requests
class KK: def kk(rid):
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
def __init__(self, rid): parameter = {'FuncTag': 10005043, 'userId': '{}'.format(rid), 'platform': 1, 'a': 1, 'c': 100101}
self.rid = rid with requests.Session() as s:
res = s.get(url.format(parameter)).json()
def get_real_url(self): tagcode = res['TagCode']
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}' if tagcode == '00000000':
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(self.rid), 'platform': 1, 'a': 1, 'c': 100101} if res.get('liveType', 0) == 1:
with requests.Session() as s: roomid = res['roomId']
res = s.get(url.format(parameter)).json() parameter = {'FuncTag': 60001002, 'roomId': roomid, 'platform': 1, 'a': 1, 'c': 100101}
tagcode = res['TagCode'] with requests.Session() as s:
if tagcode == '00000000': res = s.get(url.format(parameter)).json()
if res.get('liveType', 0) == 1: real_url = res['liveStream']
roomid = res['roomId'] return real_url
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(get_real_url(r)) print(kk(r))

View File

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

View File

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

42
kuwo.py
View File

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

View File

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

View File

@ -1,5 +1,4 @@
# 乐嗨直播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
@ -7,49 +6,35 @@ import time
import hashlib import hashlib
class LeHai: def lehai(rid):
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(rid)
def __init__(self, rid): params = {
self.rid = rid '_st1': int(time.time() * 1e3),
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
def get_real_url(self): 'tku': 3000006,
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(self.rid) }
params = { data = urlencode(params) + '1eha12h5'
'_st1': int(time.time() * 1e3), _ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D', params['_ajaxData1'] = _ajaxData1
'tku': 3000006, params['accessToken'] = unquote(params['accessToken'])
} with requests.Session() as s:
data = urlencode(params) + '1eha12h5' res = s.get(url, params=params)
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest() if res.status_code == 200:
params['_ajaxData1'] = _ajaxData1 res = res.json()
params['accessToken'] = unquote(params['accessToken']) statuscode = res['status']['statuscode']
with requests.Session() as s: if statuscode == '0':
res = s.get(url, params=params) if res['data']['live_status'] == '1':
if res.status_code == 200: anchor, = res['data']['anchor']
res = res.json() real_url = anchor['media_url']
statuscode = res['status']['statuscode'] return real_url
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(get_real_url(r)) print(lehai(r))

View File

@ -4,31 +4,18 @@ 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:
lz = LongZhu(rid) response = requests.get('http://m.longzhu.com/' + str(rid)).text
return lz.get_real_url() roomId = re.findall(r'roomId = (\d*);', response)[0]
except Exception as e: response = requests.get('http://livestream.longzhu.com/live/getlivePlayurl?roomId={}&hostPullType=2&isAdvanced=true&playUrlsType=1'.format(roomId)).json()
print('Exception', e) real_url = response.get('playLines')[0].get('urls')[-1].get('securityUrl')
return False except:
real_url = '直播间不存在或未开播'
return real_url
if __name__ == '__main__': rid = input('请输入龙珠直播房间号:\n')
r = input('请输入龙珠直播房间号:\n') real_url = get_real_url(rid)
print(get_real_url(r)) print('该直播间源地址为:')
print(real_url)

33
look.py
View File

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

44
now.py
View File

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

47
pps.py
View File

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

33
qf.py
View File

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

41
qie.py
View File

@ -1,37 +1,22 @@
# 企鹅体育https://live.qq.com/directory/all # 企鹅体育https://live.qq.com/directory/all
import requests import requests
import re import re
class ESport: def qie(rid):
with requests.Session() as s:
def __init__(self, rid): res = s.get('https://m.live.qq.com/' + str(rid))
self.rid = rid show_status = re.search(r'"show_status":"(\d)"', res.text)
if show_status:
def get_real_url(self): if show_status.group(1) == '1':
with requests.Session() as s: hls_url = re.search(r'"hls_url":"(.*)","use_p2p"', res.text).group(1)
res = s.get('https://m.live.qq.com/' + str(self.rid)) return hls_url
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(get_real_url(r)) print(qie(r))

View File

@ -1,48 +1,33 @@
# 人人直播http://zhibo.renren.com/ # 人人直播http://zhibo.renren.com/
import requests import requests
import re import re
import hashlib import hashlib
class RenRen: def renren(rid):
with requests.Session() as s:
def __init__(self, rid): res = s.get('http://activity.renren.com/liveroom/' + str(rid))
self.rid = rid livestate = re.search(r'"liveState":(\d)', res.text)
if livestate:
def get_real_url(self): try:
with requests.Session() as s: s = re.search(r'"playUrl":"([\s\S]*?)"', res.text).group(1)
res = s.get('http://activity.renren.com/liveroom/' + str(self.rid)) if livestate.group(1) == '0':
livestate = re.search(r'"liveState":(\d)', res.text) accesskey = re.search(r'accesskey=(\w+)', s).group(1)
if livestate: expire = re.search(r'expire=(\d+)', s).group(1)
try: live = re.search(r'(/live/\d+)', s).group(1)
s = re.search(r'"playUrl":"([\s\S]*?)"', res.text).group(1) c = accesskey + expire + live
if livestate.group(1) == '0': key = hashlib.md5(c.encode('utf-8')).hexdigest()
accesskey = re.search(r'accesskey=(\w+)', s).group(1) e = s.split('?')[0].split('/')[4]
expire = re.search(r'expire=(\d+)', s).group(1) t = 'http://ksy-hls.renren.com/live/' + e + '/index.m3u8?key=' + key
live = re.search(r'(/live/\d+)', s).group(1) return t
c = accesskey + expire + live elif livestate.group(1) == '1':
key = hashlib.md5(c.encode('utf-8')).hexdigest() return '回放:' + s
e = s.split('?')[0].split('/')[4] except IndexError:
t = 'http://ksy-hls.renren.com/live/' + e + '/index.m3u8?key=' + key raise Exception('解析错误')
return t else:
elif livestate.group(1) == '1': raise Exception('直播间不存在')
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(get_real_url(r)) print(renren(r))

View File

@ -1,15 +0,0 @@
aiohttp==3.6.2
async-timeout==3.0.1
attrs==20.2.0
certifi==2020.6.20
chardet==3.0.4
idna==2.10
multidict==4.7.6
protobuf==3.12.2
pycryptodome==3.9.8
PyExecJS==1.5.1
requests==2.24.0
six==1.15.0
typing-extensions==3.7.4.3
urllib3==1.25.10
yarl==1.5.1

View File

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

41
tuho.py
View File

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

42
v6cn.py
View File

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

39
wali.py
View File

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

View File

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

View File

@ -1,57 +1,41 @@
# 迅雷直播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
class XunLei: def xunlei(rid):
url = 'https://biz-live-ssl.xunlei.com//caller'
def __init__(self, rid): headers = {
self.rid = rid 'cookie': 'appid=1002'
}
def get_real_url(self): _t = int(time.time() * 1000)
url = 'https://biz-live-ssl.xunlei.com//caller' u = '1002'
headers = { f = '&*%$7987321GKwq'
'cookie': 'appid=1002' params = {
} '_t': _t,
_t = int(time.time() * 1000) 'a': 'play',
u = '1002' 'c': 'room',
f = '&*%$7987321GKwq' 'hid': 'h5-e70560ea31cc17099395c15595bdcaa1',
params = { 'uuid': rid,
'_t': _t, }
'a': 'play', data = urlencode(params)
'c': 'room', p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest()
'hid': 'h5-e70560ea31cc17099395c15595bdcaa1', params['sign'] = p
'uuid': self.rid, with requests.Session() as s:
} res = s.get(url, params=params, headers=headers).json()
data = urlencode(params) if res['result'] == 0:
p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest() play_status = res['data']['play_status']
params['sign'] = p if play_status == 1:
with requests.Session() as s: real_url = res['data']['data']['stream_pull_https']
res = s.get(url, params=params, headers=headers).json() return real_url
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(get_real_url(r)) print(xunlei(r))

View File

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

View File

@ -3,51 +3,36 @@
# 而且没有平台水印和主播自己贴的乱七八糟的字幕遮挡。 # 而且没有平台水印和主播自己贴的乱七八糟的字幕遮挡。
# 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
class YouKu: def youku(liveid):
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:
yk = YouKu(rid) tt = str(int(time.time() * 1000))
return yk.get_real_url() data = json.dumps({'liveId': liveid, 'app': 'Pc'}, separators=(',', ':'))
except Exception as e: url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788'
print('Exception', e) s = requests.Session()
return False cookies = s.get(url).cookies
token = requests.utils.dict_from_cookiejar(cookies).get('_m_h5_tk')[0:32]
sign = hashlib.md5((token + '&' + tt + '&' + '24679788' + '&' + data).encode('utf-8')).hexdigest()
params = {
't': tt,
'sign': sign,
'data': data
}
response = s.get(url, params=params).json()
# name = response.get('data').get('data').get('name')
streamname = response.get('data').get('data').get('stream')[0].get('streamName')
real_url = 'http://lvo-live.youku.com/vod2live/{}_mp4hd2v3.m3u8?&expire=21600&psid=1&ups_ts={}&vkey='.format(
streamname, int(time.time()))
except:
real_url = '请求错误'
return real_url
if __name__ == '__main__': if __name__ == '__main__':
r = input('请输入优酷轮播台房间号:\n') r = input('输入优酷轮播台liveId\n')
print(get_real_url(r)) print(youku(r))

View File

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

61
yy.py
View File

@ -1,50 +1,35 @@
# 获取YY直播的真实流媒体地址。https://www.yy.com/1349606469 # 获取YY直播的真实流媒体地址。https://www.yy.com/1349606469
# 默认获取最高画质 # 默认获取最高画质
import requests import requests
import re import re
import json import json
class YY: def yy(rid):
headers = {
def __init__(self, rid): 'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=rid),
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): }
headers = { room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=rid)
'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=self.rid), with requests.Session() as s:
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)' res = s.get(room_url, headers=headers)
' Version/11.0 Mobile/15A372 Safari/604.1' if res.status_code == 200:
} data = json.loads(res.text[1:-1])
room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=self.rid) if data.get('hls', 0):
with requests.Session() as s: xa = data['audio']
res = s.get(room_url, headers=headers) xv = data['video']
if res.status_code == 200: xv = re.sub(r'0_\d+_0', '0_0_0', xv)
data = json.loads(res.text[1:-1]) url = 'https://interface.yy.com/hls/get/stream/15013/{}/15013/{}?source=h5player&type=m3u8'.format(xv, xa)
if data.get('hls', 0): res = s.get(url).json()
xa = data['audio'] real_url = res['hls']
xv = data['video'] return real_url
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(get_real_url(r)) print(yy(r))

View File

@ -3,37 +3,23 @@
import requests import requests
class ZhanQi: def zhanqi(rid):
with requests.Session() as s:
def __init__(self, rid): res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(rid))
self.rid = rid try:
res = res.json()
def get_real_url(self): videoid = res['data']['videoId']
with requests.Session() as s: status = res['data']['status']
res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid)) if status == '4':
try: url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
res = res.json() real_url = s.get(url).text
videoid = res['data']['videoId'] else:
status = res['data']['status'] real_url = '未开播'
if status == '4': except:
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid) real_url = '直播间不存在'
real_url = s.get(url).text return real_url
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(get_real_url(r)) print(zhanqi(r))