mirror of
https://github.com/wbt5/real-url.git
synced 2025-08-04 17:32:46 +08:00
Compare commits
12 Commits
c4ab4dfb71
...
89e4a356f1
Author | SHA1 | Date | |
---|---|---|---|
|
89e4a356f1 | ||
|
95376dfea0 | ||
|
50b3a3e81e | ||
|
36f6764752 | ||
|
952ed5c2fb | ||
|
1a184cbb14 | ||
|
fa6d2995ab | ||
|
6ec73b61d9 | ||
|
d60a55fb68 | ||
|
ddf7065176 | ||
|
c489e88590 | ||
|
1bd979b521 |
22
173.py
22
173.py
@ -1,9 +1,15 @@
|
||||
# 艺气山直播:http://www.173.com/room/category?categoryId=11
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def _173(rid):
|
||||
params = 'roomId={}&format=m3u8'.format(rid)
|
||||
class YQS:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
params = 'roomId={}&format=m3u8'.format(self.rid)
|
||||
with requests.Session() as s:
|
||||
res = s.post('http://www.173.com/room/getVieoUrl', params=params).json()
|
||||
data = res['data']
|
||||
@ -17,6 +23,16 @@ def _173(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
yqs = YQS(rid)
|
||||
return yqs.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入艺气山直播房间号:\n')
|
||||
print(_173(r))
|
||||
print(get_real_url(r))
|
||||
|
||||
|
27
17live.py
27
17live.py
@ -4,18 +4,31 @@
|
||||
import requests
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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/' + rid).json()
|
||||
response = requests.get(url='https://api-dsa.17app.co/api/v1/lives/' + self.rid).json()
|
||||
real_url_default = response.get('rtmpUrls')[0].get('url')
|
||||
real_url_modify = real_url_default.replace('global-pull-rtmp.17app.co', 'china-pull-rtmp-17.tigafocus.com')
|
||||
real_url = [real_url_modify, real_url_default]
|
||||
except:
|
||||
real_url = '该直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入17直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
live17 = Live17(rid)
|
||||
return live17.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入17直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
22
2cq.py
22
2cq.py
@ -1,10 +1,16 @@
|
||||
# 棉花糖直播:https://www.2cq.com/rank
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def mht(rid):
|
||||
class MHT:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://www.2cq.com/proxy/room/room/info?roomId={}&appId=1004'.format(rid))
|
||||
res = s.get('https://www.2cq.com/proxy/room/room/info?roomId={}&appId=1004'.format(self.rid))
|
||||
res = res.json()
|
||||
if res['status'] == 1:
|
||||
result = res['result']
|
||||
@ -17,6 +23,16 @@ def mht(rid):
|
||||
raise Exception('直播间可能不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
mht = MHT(rid)
|
||||
return mht.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入棉花糖直播房间号:\n')
|
||||
print(mht(r))
|
||||
print(get_real_url(r))
|
||||
|
||||
|
21
51lm.py
21
51lm.py
@ -1,12 +1,18 @@
|
||||
# 羚萌直播:https://live.51lm.tv/programs/Hot
|
||||
|
||||
from urllib.parse import urlencode
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
|
||||
|
||||
def lm(rid):
|
||||
roominfo = {'programId': rid}
|
||||
class LM:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
roominfo = {'programId': self.rid}
|
||||
|
||||
def g(d):
|
||||
return hashlib.md5((d + '#' + urlencode(roominfo) + '#Ogvbm2ZiKE').encode('utf-8')).hexdigest()
|
||||
@ -38,6 +44,15 @@ def lm(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
lm = LM(rid)
|
||||
return lm.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入羚萌直播房间号:\n')
|
||||
print(lm(r))
|
||||
print(get_real_url(r))
|
||||
|
22
95xiu.py
22
95xiu.py
@ -1,11 +1,17 @@
|
||||
# 95秀:http://www.95.cn/
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def jwxiu(rid):
|
||||
class JWXiu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('http://www.95.cn/{}.html'.format(rid)).text
|
||||
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)
|
||||
@ -18,6 +24,16 @@ def jwxiu(rid):
|
||||
raise Exception('未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
jwx = JWXiu(rid)
|
||||
return jwx.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入95秀房间号:\n')
|
||||
print(jwxiu(r))
|
||||
print(get_real_url(r))
|
||||
|
||||
|
21
9xiu.py
21
9xiu.py
@ -1,10 +1,16 @@
|
||||
# 九秀直播:https://www.9xiu.com/other/classify?tag=all&index=all
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def j_xiu(rid):
|
||||
class JXiu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str(rid)
|
||||
url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str( self.rid)
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) '
|
||||
'AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
|
||||
@ -21,6 +27,15 @@ def j_xiu(rid):
|
||||
raise Exception('直播间可能不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
jx = JXiu(rid)
|
||||
return jx.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入九秀直播房间号:\n')
|
||||
print(j_xiu(r))
|
||||
print(get_real_url(r))
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
**48** 个直播平台的直播源获取:斗鱼直播、虎牙直播、哔哩哔哩直播、战旗直播、网易 CC 直播、火猫直播、企鹅电竞、YY 直播、一直播、快手直播、花椒直播、映客直播、西瓜直播、触手直播、NOW 直播、抖音直播,爱奇艺直播、酷狗直播、龙珠直播、PPS 奇秀直播、六间房、17 直播、来疯直播、优酷轮播台、网易 LOOK 直播、千帆直播、陌陌直播、小米直播、迅雷直播、京东直播、企鹅体育、人人直播、棉花糖直播、九秀直播、羚萌直播、95秀、新浪疯播、红人直播、艾米直播、KK直播、酷我聚星、乐嗨直播、秀色直播、星光直播、我秀直播、热猫直播、艺气山直播、AcFun 直播。
|
||||
|
||||
**16** 个直播平台的弹幕获取:斗鱼直播、虎牙直播、哔哩哔哩直播、快手直播、火猫直播、企鹅电竞、花椒直播、映客直播、网易 CC 直播、酷狗直播、龙珠直播、PPS 奇秀、搜狐千帆、战旗直播、来疯直播、网易 LOOK 直播。
|
||||
**18** 个直播平台的弹幕获取:斗鱼直播、虎牙直播、哔哩哔哩直播、快手直播、火猫直播、企鹅电竞、花椒直播、映客直播、网易 CC 直播、酷狗直播、龙珠直播、PPS 奇秀、搜狐千帆、战旗直播、来疯直播、网易 LOOK 直播、AcFun 直播、艺气山直播。
|
||||
|
||||
## 运行
|
||||
|
||||
@ -25,7 +25,9 @@
|
||||
|
||||
## 更新
|
||||
|
||||
### 2020.08.18:更新快手直播源,现在播放链接需要带参数;更新快手直播弹幕,直接用 protobuf 序列化;新增 AcFun、艺气山两个平台的弹幕功能。
|
||||
### 2020.09.12:新增:斗鱼添加一个从PC网页端获取直播源的方法,可选线路和清晰度;新增requirements.txt文件;更新代码。
|
||||
|
||||
2020.08.18:更新快手直播源,现在播放链接需要带参数;更新快手直播弹幕,直接用 protobuf 序列化;新增 AcFun、艺气山两个平台的弹幕功能。
|
||||
|
||||
2020.08.08:新增 AcFun 直播、艺气山直播;更新:哔哩哔哩直播、虎牙直播、红人直播;优化:斗鱼直播。
|
||||
|
||||
|
24
acfun.py
24
acfun.py
@ -1,10 +1,16 @@
|
||||
# AcFun直播:https://live.acfun.cn/
|
||||
# 默认最高画质
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def acfun(rid):
|
||||
class AcFun:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
headers = {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'cookie': '_did=H5_',
|
||||
@ -26,7 +32,7 @@ def acfun(rid):
|
||||
'did': 'H5_',
|
||||
'acfun.api.visitor_st': visitor_st
|
||||
}
|
||||
data = 'authorId={}&pullStreamType=FLV'.format(rid)
|
||||
data = 'authorId={}&pullStreamType=FLV'.format(self.rid)
|
||||
res = s.post(url, params=params, data=data, headers=headers).json()
|
||||
if res['result'] == 1:
|
||||
data = res['data']
|
||||
@ -40,6 +46,16 @@ def acfun(rid):
|
||||
raise Exception('直播已关闭')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
acfun = AcFun(rid)
|
||||
return acfun.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入AcFun直播间号:\n')
|
||||
print(acfun(r))
|
||||
r = input('请输入AcFun直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
22
bilibili.py
22
bilibili.py
@ -6,9 +6,14 @@
|
||||
import requests
|
||||
|
||||
|
||||
def bilibili(rid):
|
||||
class BiliBili:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
# 先获取直播状态和真实房间号
|
||||
r_url = 'https://api.live.bilibili.com/room/v1/Room/room_init?id={}'.format(rid)
|
||||
r_url = 'https://api.live.bilibili.com/room/v1/Room/room_init?id={}'.format(self.rid)
|
||||
with requests.Session() as s:
|
||||
res = s.get(r_url).json()
|
||||
code = res['code']
|
||||
@ -45,6 +50,15 @@ def bilibili(rid):
|
||||
raise Exception('房间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
bilibili = BiliBili(rid)
|
||||
return bilibili.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入bilibili直播间号:\n')
|
||||
print(bilibili(r))
|
||||
r = input('请输入bilibili直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
32
cc.py
32
cc.py
@ -1,26 +1,40 @@
|
||||
# 获取网易CC的真实流媒体地址。
|
||||
# 默认为最高画质
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
room_url = 'https://api.cc.163.com/v1/activitylives/anchor/lives?anchor_ccid=' + str(rid)
|
||||
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(rid)).get('channel_id', 0)
|
||||
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:
|
||||
real_url = '直播间不存在'
|
||||
raise Exception('直播间不存在')
|
||||
else:
|
||||
real_url = '输入错误'
|
||||
raise Exception('输入错误')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入网易CC直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:\n' + real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
cc = CC(rid)
|
||||
return cc.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入网易CC直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
29
chushou.py
29
chushou.py
@ -1,12 +1,16 @@
|
||||
# 获取触手直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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(rid)
|
||||
room_url = 'https://chushou.tv/h5player/video/get-play-url.htm?roomId={}&protocols=2&callback='.format(self.rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
data = response.get('data')[0]
|
||||
real_url = {
|
||||
@ -15,11 +19,20 @@ def get_real_url(rid):
|
||||
'shdPlayUrl': data.get('shdPlayUrl', 0)
|
||||
}
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入触手直播间数字ID:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
cs = ChuShou(rid)
|
||||
return cs.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入触手直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
@ -3,7 +3,7 @@ import re
|
||||
|
||||
import aiohttp
|
||||
|
||||
from ._173 import YiQiShan
|
||||
from .yqs import YiQiShan
|
||||
from .acfun import AcFun
|
||||
from .bilibili import Bilibili
|
||||
from .cc import CC
|
||||
@ -21,6 +21,7 @@ from .look import Look
|
||||
from .pps import QiXiu
|
||||
from .qf import QF
|
||||
from .zhanqi import ZhanQi
|
||||
from .yy import YY
|
||||
|
||||
__all__ = ['DanmakuClient']
|
||||
|
||||
@ -55,7 +56,8 @@ class DanmakuClient:
|
||||
'laifeng.com': LaiFeng,
|
||||
'look.163.com': Look,
|
||||
'acfun.cn': AcFun,
|
||||
'173.com': YiQiShan}.items():
|
||||
'173.com': YiQiShan,
|
||||
'yy.com': YY}.items():
|
||||
if re.match(r'^(?:http[s]?://)?.*?%s/(.+?)$' % u, url):
|
||||
self.__site = s
|
||||
self.__u = u
|
||||
@ -114,56 +116,77 @@ class DanmakuClient:
|
||||
await self.__dm_queue.put(m)
|
||||
count += 1
|
||||
|
||||
async def init_ws_acfun(self, s):
|
||||
async def init_ws_acfun(self):
|
||||
self.__ws = await self.__hs.ws_connect(self.__site.ws_url)
|
||||
await self.__ws.send_bytes(s.encode_packet('register'))
|
||||
await self.__ws.send_bytes(self.__s.encode_packet('register'))
|
||||
|
||||
async def ping_acfun(self, s):
|
||||
async def ping_acfun(self):
|
||||
while True:
|
||||
await asyncio.sleep(1)
|
||||
await self.__ws.send_bytes(s.encode_packet('ping'))
|
||||
await self.__ws.send_bytes(self.__s.encode_packet('ping'))
|
||||
|
||||
async def keepalive_acfun(self, s):
|
||||
async def keepalive_acfun(self):
|
||||
while True:
|
||||
await asyncio.sleep(50)
|
||||
await self.__ws.send_bytes(s.encode_packet('keepalive'))
|
||||
await self.__ws.send_bytes(self.__s.encode_packet('keepalive'))
|
||||
|
||||
async def heartbeat_acfun(self, s):
|
||||
async def heartbeat_acfun(self):
|
||||
while True:
|
||||
await asyncio.sleep(10)
|
||||
await self.__ws.send_bytes(s.encode_packet('ztlivecsheartbeat'))
|
||||
await self.__ws.send_bytes(self.__s.encode_packet('ztlivecsheartbeat'))
|
||||
|
||||
async def fetch_danmaku_acfun(self, s):
|
||||
async def fetch_danmaku_acfun(self):
|
||||
count = 0
|
||||
async for msg in self.__ws:
|
||||
self.__link_status = True
|
||||
ms = s.decode_packet(msg.data)
|
||||
ms = self.__s.decode_packet(msg.data)
|
||||
if count == 0:
|
||||
await self.__ws.send_bytes(s.encode_packet('ztlivecsenterroom'))
|
||||
await self.__ws.send_bytes(self.__s.encode_packet('ztlivecsenterroom'))
|
||||
count += 1
|
||||
for m in ms:
|
||||
await self.__dm_queue.put(m)
|
||||
|
||||
async def init_ws_173(self, s):
|
||||
async def init_ws_173(self):
|
||||
self.__ws = await self.__hs.ws_connect(self.__site.ws_url)
|
||||
await self.__ws.send_bytes(s.pack('startup'))
|
||||
await self.__ws.send_bytes(self.__s.pack('startup'))
|
||||
await asyncio.sleep(1)
|
||||
await self.__ws.send_bytes(s.pack('enterroomreq'))
|
||||
await self.__ws.send_bytes(self.__s.pack('enterroomreq'))
|
||||
|
||||
async def tcphelloreq_173(self, s):
|
||||
async def tcphelloreq_173(self):
|
||||
while True:
|
||||
await asyncio.sleep(10)
|
||||
await self.__ws.send_bytes(s.pack('tcphelloreq'))
|
||||
await self.__ws.send_bytes(self.__s.pack('tcphelloreq'))
|
||||
|
||||
async def roomhelloreq_173(self, s):
|
||||
async def roomhelloreq_173(self):
|
||||
while True:
|
||||
await asyncio.sleep(5)
|
||||
await self.__ws.send_bytes(s.pack('roomhelloreq'))
|
||||
await self.__ws.send_bytes(self.__s.pack('roomhelloreq'))
|
||||
|
||||
async def fetch_danmaku_173(self, s):
|
||||
async def fetch_danmaku_173(self):
|
||||
async for msg in self.__ws:
|
||||
self.__link_status = True
|
||||
ms = s.unpack(msg.data)
|
||||
ms = self.__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:
|
||||
await self.__dm_queue.put(m)
|
||||
|
||||
@ -172,22 +195,30 @@ class DanmakuClient:
|
||||
await self.init_ws_huajiao()
|
||||
elif self.__u == 'acfun.cn':
|
||||
rid = re.search(r'\d+', self.__url).group(0)
|
||||
s = self.__site(rid)
|
||||
await self.init_ws_acfun(s)
|
||||
self.__s = self.__site(rid)
|
||||
await self.init_ws_acfun()
|
||||
await asyncio.gather(
|
||||
self.ping_acfun(s),
|
||||
self.fetch_danmaku_acfun(s),
|
||||
self.keepalive_acfun(s),
|
||||
self.heartbeat_acfun(s),
|
||||
self.ping_acfun(),
|
||||
self.fetch_danmaku_acfun(),
|
||||
self.keepalive_acfun(),
|
||||
self.heartbeat_acfun(),
|
||||
)
|
||||
elif self.__u == '173.com':
|
||||
rid = self.__url.split('/')[-1]
|
||||
s = self.__site(rid)
|
||||
await self.init_ws_173(s)
|
||||
self.__s = self.__site(rid)
|
||||
await self.init_ws_173()
|
||||
await asyncio.gather(
|
||||
self.fetch_danmaku_173(s),
|
||||
self.tcphelloreq_173(s),
|
||||
self.roomhelloreq_173(s),
|
||||
self.fetch_danmaku_173(),
|
||||
self.tcphelloreq_173(),
|
||||
self.roomhelloreq_173(),
|
||||
)
|
||||
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:
|
||||
await self.init_ws()
|
||||
|
139
danmu/danmaku/yqs.proto
Normal file
139
danmu/danmaku/yqs.proto
Normal file
@ -0,0 +1,139 @@
|
||||
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;
|
||||
}
|
||||
}
|
137
danmu/danmaku/yqs.py
Normal file
137
danmu/danmaku/yqs.py
Normal file
@ -0,0 +1,137 @@
|
||||
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
|
1141
danmu/danmaku/yqs_pb2.py
Normal file
1141
danmu/danmaku/yqs_pb2.py
Normal file
File diff suppressed because it is too large
Load Diff
32
douyin.py
32
douyin.py
@ -2,28 +2,40 @@
|
||||
# 如果知道该直播间如“6779127643792280332”形式的room_id,则直接传入room_id。
|
||||
# 如果不知道room_id,可以使用手机上打开直播间后,选择“分享--复制链接”,传入如“https://v.douyin.com/qyRqMp/”形式的分享链接。
|
||||
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
class DouYin:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
if 'v.douyin.com' in rid:
|
||||
room_id = re.findall(r'(\d{19})', requests.get(url=rid).url)[0]
|
||||
if 'v.douyin.com' in self.rid:
|
||||
room_id = re.findall(r'(\d{19})', requests.get(url=self.rid).url)[0]
|
||||
else:
|
||||
room_id = rid
|
||||
room_id = self.rid
|
||||
room_url = 'https://webcast-hl.amemv.com/webcast/room/reflow/info/?room_id={}&live_id=1'.format(room_id)
|
||||
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 = '直播间不存在或未开播或参数错误'
|
||||
raise Exception('直播间不存在或未开播或参数错误')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入抖音直播间room_id或分享链接:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
dy = DouYin(rid)
|
||||
return dy.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入抖音直播间room_id或分享链接:\n')
|
||||
print(get_real_url(r))
|
||||
|
39
douyu.py
39
douyu.py
@ -1,9 +1,10 @@
|
||||
# 获取斗鱼直播间的真实流媒体地址,默认最高画质。
|
||||
import requests
|
||||
import re
|
||||
import execjs
|
||||
import time
|
||||
import hashlib
|
||||
import re
|
||||
import time
|
||||
|
||||
import execjs
|
||||
import requests
|
||||
|
||||
|
||||
class DouYu:
|
||||
@ -71,6 +72,35 @@ class DouYu:
|
||||
|
||||
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蓝光4M;0蓝光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):
|
||||
error, key = self.get_pre()
|
||||
if error == 0:
|
||||
@ -81,7 +111,6 @@ class DouYu:
|
||||
raise Exception('房间未开播')
|
||||
else:
|
||||
key = self.get_js()
|
||||
|
||||
return "http://tx2play1.douyucdn.cn/live/{}.flv?uuid=".format(key)
|
||||
|
||||
|
||||
|
35
egame.py
35
egame.py
@ -1,16 +1,20 @@
|
||||
# 获取企鹅电竞的真实流媒体地址。
|
||||
# 默认画质为超清
|
||||
|
||||
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
class EGame:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
room_url = 'https://share.egame.qq.com/cgi-bin/pgg_async_fcgi'
|
||||
post_data = {
|
||||
'param': '''{"0":{"module":"pgg_live_read_svr","method":"get_live_and_profile_info","param":{"anchor_id":''' + str(rid) + ''',"layout_id":"hot","index":1,"other_uid":0}}}'''
|
||||
'param': '''{"0":{"module":"pgg_live_read_svr","method":"get_live_and_profile_info","param":{"anchor_id":'''
|
||||
+ str(self.rid) + ''',"layout_id":"hot","index":1,"other_uid":0}}}'''
|
||||
}
|
||||
try:
|
||||
response = requests.post(url=room_url, data=post_data).json()
|
||||
@ -27,16 +31,25 @@ def get_real_url(rid):
|
||||
0].get('play_url')
|
||||
real_url = re.findall(r'([\w\W]+?)&uid=', play_url)[0]
|
||||
else:
|
||||
real_url = '直播间未开播'
|
||||
raise Exception('直播间未开播')
|
||||
else:
|
||||
real_url = '直播间未启用'
|
||||
raise Exception('直播间未启用')
|
||||
else:
|
||||
real_url = '直播间不存在'
|
||||
raise Exception('直播间不存在')
|
||||
except:
|
||||
real_url = '数据请求错误'
|
||||
raise Exception('数据请求错误')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入企鹅电竞房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:\n' + real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
eg = EGame(rid)
|
||||
return eg.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入企鹅电竞房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
@ -1,5 +1,6 @@
|
||||
# 新浪疯播直播:http://www.fengbolive.com/list?type=hot
|
||||
# 链接样式:http://www.fengbolive.com/live/88057518
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
from urllib.parse import unquote
|
||||
import base64
|
||||
@ -7,9 +8,14 @@ import json
|
||||
import requests
|
||||
|
||||
|
||||
def fengbo(rid):
|
||||
class FengBo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(rid)).json()
|
||||
res = s.get('https://external.fengbolive.com/cgi-bin/get_anchor_info_proxy.fcgi?anchorid=' + str(self.rid)).json()
|
||||
if res['ret'] == 1:
|
||||
info = res['info']
|
||||
info = unquote(info, 'utf-8')
|
||||
@ -33,6 +39,15 @@ def fengbo(rid):
|
||||
raise Exception('房间号错误')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
fb = FengBo(rid)
|
||||
return fb.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入疯播直播房间号:\n')
|
||||
print(fengbo(r))
|
||||
print(get_real_url(r))
|
||||
|
21
hongle.py
21
hongle.py
@ -1,6 +1,7 @@
|
||||
# 红人直播:https://www.hongle.tv/
|
||||
# 该平台需登陆,下面代码中已集成一个账号的登陆方式;
|
||||
# 如登陆信息过期,可用自己的账号登陆后,查找浏览器Local Storage中的hrtk字段,替换代码中的accesstoken
|
||||
|
||||
from urllib.parse import urlencode
|
||||
from urllib.parse import unquote
|
||||
import requests
|
||||
@ -9,7 +10,12 @@ import hashlib
|
||||
import json
|
||||
|
||||
|
||||
def hongle(rid):
|
||||
class HongLe:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
# 模拟登陆
|
||||
with requests.Session() as s:
|
||||
pass
|
||||
@ -43,7 +49,7 @@ def hongle(rid):
|
||||
'_st1': tt,
|
||||
'accessToken': accesstoken,
|
||||
'of': 1,
|
||||
'showid': rid,
|
||||
'showid': self.rid,
|
||||
'tku': 43112608,
|
||||
}
|
||||
data = urlencode(params) + 'yuj1ah5o'
|
||||
@ -69,6 +75,15 @@ def hongle(rid):
|
||||
raise Exception('参数错误')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
hl = HongLe(rid)
|
||||
return hl.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入红人直播房间号:\n')
|
||||
print(hongle(r))
|
||||
print(get_real_url(r))
|
||||
|
27
huajiao.py
27
huajiao.py
@ -1,21 +1,34 @@
|
||||
# 获取花椒直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
import time
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
class HuaJiao:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
tt = str(time.time())
|
||||
try:
|
||||
room_url = 'https://h.huajiao.com/api/getFeedInfo?sid={tt}&liveid={rid}'.format(tt=tt, rid=rid)
|
||||
room_url = 'https://h.huajiao.com/api/getFeedInfo?sid={tt}&liveid={rid}'.format(tt=tt, rid=self.rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
real_url = response.get('data').get('live').get('main')
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入花椒直播间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:\n' + real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
hj = HuaJiao(rid)
|
||||
return hj.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入花椒直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
46
huomao.py
46
huomao.py
@ -3,19 +3,24 @@
|
||||
# 实际上使用http://live-lx-hdl.huomaotv.cn/live/qvCESZ?token=44a7f115f0af496e268bcbb7cdbb63b1,即可播放
|
||||
# 链接中lx可替换cdn(lx,tx,ws,js,jd2等),媒体类型可为.flv或.m3u8,码率可为BL8M,BL4M,TD,BD,HD,SD
|
||||
|
||||
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
import re
|
||||
|
||||
|
||||
def get_time():
|
||||
class HuoMao:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
@staticmethod
|
||||
def get_time():
|
||||
tt = str(int((time.time() * 1000)))
|
||||
return tt
|
||||
|
||||
|
||||
def get_videoids(rid):
|
||||
@staticmethod
|
||||
def get_videoids(rid):
|
||||
room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid)
|
||||
response = requests.get(url=room_url).text
|
||||
try:
|
||||
@ -24,18 +29,17 @@ def get_videoids(rid):
|
||||
videoids = 0
|
||||
return videoids
|
||||
|
||||
|
||||
def get_token(videoids, time):
|
||||
@staticmethod
|
||||
def get_token(videoids, time):
|
||||
token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) +
|
||||
'6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest()
|
||||
return token
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
videoids = get_videoids(rid)
|
||||
def get_real_url(self):
|
||||
videoids = self.get_videoids(self.rid)
|
||||
if videoids:
|
||||
time = get_time()
|
||||
token = get_token(videoids, time)
|
||||
time = self.get_time()
|
||||
token = self.get_token(videoids, time)
|
||||
room_url = 'https://www.huomao.com/swf/live_data'
|
||||
post_data = {
|
||||
'cdns': 1,
|
||||
@ -52,13 +56,21 @@ def get_real_url(rid):
|
||||
real_url_m3u8 = response.get('streamList')[-1].get('list_hls')[0].get('url')
|
||||
real_url = [real_url_flv, real_url_m3u8.replace('_480', '')]
|
||||
else:
|
||||
real_url = '直播间未开播'
|
||||
raise Exception('直播间未开播')
|
||||
else:
|
||||
real_url = '直播间不存在'
|
||||
raise Exception('直播间不存在')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入火猫直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
hm = HuoMao(rid)
|
||||
return hm.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入火猫直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
71
huya.py
71
huya.py
@ -1,5 +1,6 @@
|
||||
# 获取虎牙直播的真实流媒体地址。
|
||||
# 虎牙"一起看"频道的直播间可能会卡顿
|
||||
|
||||
import requests
|
||||
import re
|
||||
import base64
|
||||
@ -8,7 +9,41 @@ import hashlib
|
||||
import time
|
||||
|
||||
|
||||
def live(e):
|
||||
class HuYa:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
room_url = 'https://m.huya.com/' + str(self.rid)
|
||||
header = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 '
|
||||
'(KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36 '
|
||||
}
|
||||
response = requests.get(url=room_url, headers=header).text
|
||||
livelineurl = re.findall(r'liveLineUrl = "([\s\S]*?)";', response)[0]
|
||||
if livelineurl:
|
||||
if 'replay' in livelineurl:
|
||||
real_url = {
|
||||
'replay': "https:" + livelineurl,
|
||||
}
|
||||
else:
|
||||
s_url = self.live(livelineurl)
|
||||
b_url = self.live(livelineurl.replace('_2000', ''))
|
||||
real_url = {
|
||||
'2000p': "https:" + s_url,
|
||||
'BD': "https:" + b_url
|
||||
}
|
||||
else:
|
||||
raise Exception('未开播或直播间不存在')
|
||||
except Exception as e:
|
||||
raise Exception('未开播或直播间不存在')
|
||||
return real_url
|
||||
|
||||
@staticmethod
|
||||
def live(e):
|
||||
i, b = e.split('?')
|
||||
r = i.split('/')
|
||||
s = re.sub(r'.(flv|m3u8)', '', r[-1])
|
||||
@ -28,33 +63,15 @@ def live(e):
|
||||
return url
|
||||
|
||||
|
||||
def huya(room_id):
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
room_url = 'https://m.huya.com/' + str(room_id)
|
||||
header = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 '
|
||||
'(KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36 '
|
||||
}
|
||||
response = requests.get(url=room_url, headers=header).text
|
||||
livelineurl = re.findall(r'liveLineUrl = "([\s\S]*?)";', response)[0]
|
||||
if livelineurl:
|
||||
if 'replay' in livelineurl:
|
||||
return '直播录像:https:' + livelineurl
|
||||
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
|
||||
hy = HuYa(rid)
|
||||
return hy.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
rid = input('输入虎牙直播间号:\n')
|
||||
print(huya(rid))
|
||||
rid = input('输入虎牙直播房间号:\n')
|
||||
print(get_real_url(rid))
|
||||
|
21
imifun.py
21
imifun.py
@ -1,11 +1,17 @@
|
||||
# 艾米直播:https://www.imifun.com/
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def imifun(rid):
|
||||
class IMFun:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://www.imifun.com/' + str(rid)).text
|
||||
res = s.get('https://www.imifun.com/' + str(self.rid)).text
|
||||
roomid = re.search(r"roomId:\s'([\w-]+)'", res)
|
||||
if roomid:
|
||||
status = re.search(r"isLive:(\d),", res).group(1)
|
||||
@ -18,6 +24,15 @@ def imifun(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
imf = IMFun(rid)
|
||||
return imf.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入艾米直播房间号:\n')
|
||||
print(imifun(r))
|
||||
print(get_real_url(r))
|
||||
|
24
immomo.py
24
immomo.py
@ -1,10 +1,14 @@
|
||||
import requests
|
||||
|
||||
|
||||
def immomo(rid):
|
||||
class ImMoMo:
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos'
|
||||
data = {
|
||||
'stid': rid,
|
||||
'stid': self.rid,
|
||||
'src': 'url'
|
||||
}
|
||||
|
||||
@ -24,8 +28,16 @@ def immomo(rid):
|
||||
raise Exception('未开播')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入陌陌直播房间号:\n')
|
||||
print(immomo(r))
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
mm = ImMoMo(rid)
|
||||
return mm.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入陌陌直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
# https://web.immomo.com/live/337033339
|
||||
|
28
inke.py
28
inke.py
@ -1,12 +1,16 @@
|
||||
# 获取映客直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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(rid)
|
||||
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')
|
||||
@ -15,11 +19,19 @@ def get_real_url(rid):
|
||||
'stream_addr': stream_addr
|
||||
}
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入映客直播间uid:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
inke = InKe(rid)
|
||||
return inke.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入映客直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
26
iqiyi.py
26
iqiyi.py
@ -9,9 +9,14 @@ import time
|
||||
import urllib.parse
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
class IQiYi:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.get('https://m-gamelive.iqiyi.com/w/' + rid).text
|
||||
response = requests.get('https://m-gamelive.iqiyi.com/w/' + self.rid).text
|
||||
# 获取直播间的qipuId
|
||||
qipuId = re.findall(r'"qipuId":(\d*?),"roomId', response)[0]
|
||||
callback = 'jsonp_' + str(int((time.time() * 1000))) + '_0000'
|
||||
@ -36,12 +41,19 @@ def get_real_url(rid):
|
||||
real_url = (url_json.get('data').get('streams'))[0].get('url')
|
||||
real_url = real_url.replace('hlslive.video.iqiyi.com', 'm3u8live.video.iqiyi.com')
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
iqiyi = IQiYi(rid)
|
||||
return iqiyi.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
rid = input('请输入爱奇艺直播间id:\n') # 如:19732
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入爱奇艺直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
35
ixigua.py
35
ixigua.py
@ -1,22 +1,37 @@
|
||||
# 获取西瓜直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
import re
|
||||
import json
|
||||
|
||||
def get_real_url(rid):
|
||||
|
||||
class IXiGua:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
room_url = rid
|
||||
response = requests.get(url=room_url).text
|
||||
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:
|
||||
real_url = '直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入西瓜直播URL:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
xg = IXiGua(rid)
|
||||
return xg.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入西瓜直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
23
jd.py
23
jd.py
@ -1,13 +1,19 @@
|
||||
# 京东直播:https://h5.m.jd.com/dev/3pbY8ZuCx4ML99uttZKLHC2QcAMn/live.html?id=1807004&position=0
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def jd(rid):
|
||||
class JD:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://api.m.jd.com/client.action'
|
||||
params = {
|
||||
'functionId': 'liveDetail',
|
||||
'body': json.dumps({'id': rid, 'videoType': 1}, separators=(',', ':')),
|
||||
'body': json.dumps({'id': self.rid, 'videoType': 1}, separators=(',', ':')),
|
||||
'client': 'wh5'
|
||||
}
|
||||
with requests.Session() as s:
|
||||
@ -26,6 +32,15 @@ def jd(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
jd = JD(rid)
|
||||
return jd.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入京东直播间id:\n')
|
||||
print(jd(r))
|
||||
r = input('请输入京东直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
20
kk.py
20
kk.py
@ -2,9 +2,14 @@
|
||||
import requests
|
||||
|
||||
|
||||
def kk(rid):
|
||||
class KK:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
|
||||
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(rid), 'platform': 1, 'a': 1, 'c': 100101}
|
||||
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(self.rid), 'platform': 1, 'a': 1, 'c': 100101}
|
||||
with requests.Session() as s:
|
||||
res = s.get(url.format(parameter)).json()
|
||||
tagcode = res['TagCode']
|
||||
@ -22,6 +27,15 @@ def kk(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
kk = KK(rid)
|
||||
return kk.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入KK直播房间号:\n')
|
||||
print(kk(r))
|
||||
print(get_real_url(r))
|
||||
|
23
kuaishou.py
23
kuaishou.py
@ -2,17 +2,21 @@
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def kuaishou(rid):
|
||||
class KuaiShou:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
headers = {
|
||||
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 '
|
||||
'(KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
|
||||
'cookie': 'did=web_'}
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://m.gifshow.com/fw/live/{}'.format(rid), headers=headers)
|
||||
res = s.get('https://m.gifshow.com/fw/live/{}'.format(self.rid), headers=headers)
|
||||
livestream = re.search(r'liveStream":(.*),"obfuseData', res.text)
|
||||
if livestream:
|
||||
livestream = json.loads(livestream.group(1))
|
||||
@ -24,6 +28,15 @@ def kuaishou(rid):
|
||||
raise Exception('直播间不存在或未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
ks = KuaiShou(rid)
|
||||
return ks.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入快手直播房间号:\n') # 例:jjworld126
|
||||
print(kuaishou(r))
|
||||
r = input('请输入快手直播房间地址:\n')
|
||||
print(get_real_url(r))
|
||||
|
31
kugou.py
31
kugou.py
@ -3,18 +3,31 @@
|
||||
import requests
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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(rid)).json()
|
||||
response2 = requests.get('https://fx1.service.kugou.com/video/mo/live/pull/h5/v3/streamaddr?roomId={}&platform=18&version=1000&streamType=3-6&liveType=1&ch=fx&ua=fx-mobile-h5&kugouId=0&layout=1'.format(rid)).json()
|
||||
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:
|
||||
real_url_flv = real_url_hls = '直播间不存在或未开播'
|
||||
return real_url_flv, real_url_hls
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return {"flv": real_url_flv, "hls": real_url_hls}
|
||||
|
||||
|
||||
rid = input('请输入酷狗直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
kg = KuGou(rid)
|
||||
return kg.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入酷狗直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
22
kuwo.py
22
kuwo.py
@ -1,10 +1,16 @@
|
||||
# 酷我聚星直播:http://jx.kuwo.cn/
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def kuwo(rid):
|
||||
class KuWo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://zhiboserver.kuwo.cn/proxy.p?src=h5&cmd=enterroom&rid={}&videotype=1&auto=1'.format(rid))
|
||||
res = s.get('https://zhiboserver.kuwo.cn/proxy.p?src=h5&cmd=enterroom&rid={}&videotype=1&auto=1'.format(self.rid))
|
||||
res = res.json()
|
||||
try:
|
||||
livestatus = res['room']['livestatus']
|
||||
@ -17,6 +23,16 @@ def kuwo(rid):
|
||||
raise Exception('未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
kw = KuWo(rid)
|
||||
return kw.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入酷我聚星直播房间号:\n')
|
||||
print(kuwo(r))
|
||||
print(get_real_url(r))
|
||||
|
||||
|
27
laifeng.py
27
laifeng.py
@ -6,9 +6,14 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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(rid)).text
|
||||
response_main = requests.get(url='http://v.laifeng.com/{}/m'.format(self.rid)).text
|
||||
stream_name = re.findall(r"initAlias:'(.*)?'", response_main)[0]
|
||||
real_url = {}
|
||||
for stream_format in ['HttpFlv', 'Hls']:
|
||||
@ -16,11 +21,19 @@ def get_real_url(rid):
|
||||
response = requests.get(url=request_url).json()
|
||||
real_url[stream_format] = response.get(stream_format)[0].get('Url')
|
||||
except:
|
||||
real_url = '该直播间不存在或未开播'
|
||||
raise Exception('该直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入来疯直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
lf = LaiFeng(rid)
|
||||
return lf.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入来疯直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
21
lehai.py
21
lehai.py
@ -1,4 +1,5 @@
|
||||
# 乐嗨直播:https://www.lehaitv.com/
|
||||
|
||||
from urllib.parse import urlencode
|
||||
from urllib.parse import unquote
|
||||
import requests
|
||||
@ -6,8 +7,13 @@ import time
|
||||
import hashlib
|
||||
|
||||
|
||||
def lehai(rid):
|
||||
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(rid)
|
||||
class LeHai:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://service.lehaitv.com/v2/room/{}/enter'.format(self.rid)
|
||||
params = {
|
||||
'_st1': int(time.time() * 1e3),
|
||||
'accessToken': 's7FUbTJ%2BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%2Fo4OH9pdSX6w%3D%3D',
|
||||
@ -35,6 +41,15 @@ def lehai(rid):
|
||||
raise Exception('请求错误')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
lh = LeHai(rid)
|
||||
return lh.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入乐嗨直播房间号:\n')
|
||||
print(lehai(r))
|
||||
print(get_real_url(r))
|
||||
|
27
longzhu.py
27
longzhu.py
@ -4,18 +4,31 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
class LongZhu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.get('http://m.longzhu.com/' + str(rid)).text
|
||||
response = requests.get('http://m.longzhu.com/' + str(self.rid)).text
|
||||
roomId = re.findall(r'roomId = (\d*);', response)[0]
|
||||
response = requests.get('http://livestream.longzhu.com/live/getlivePlayurl?roomId={}&hostPullType=2&isAdvanced=true&playUrlsType=1'.format(roomId)).json()
|
||||
real_url = response.get('playLines')[0].get('urls')[-1].get('securityUrl')
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入龙珠直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
lz = LongZhu(rid)
|
||||
return lz.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入龙珠直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
29
look.py
29
look.py
@ -1,21 +1,34 @@
|
||||
# 获取网易云音乐旗下look直播的真实流媒体地址。
|
||||
# look直播间链接形式:https://look.163.com/live?id=73694082
|
||||
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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=' + rid).text
|
||||
response = requests.post(url='https://look.163.com/live?id=' + self.rid).text
|
||||
real_url = re.findall(r'"liveUrl":([\s\S]*),"liveType"', response)[0]
|
||||
except:
|
||||
real_url = '该直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入look直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
look = Look(rid)
|
||||
return look.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入Look直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
28
now.py
28
now.py
@ -1,12 +1,16 @@
|
||||
# 获取NOW直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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(rid)
|
||||
room_url = 'https://now.qq.com/cgi-bin/now/web/room/get_live_room_url?room_id={}&platform=8'.format(self.rid)
|
||||
response = requests.get(url=room_url).json()
|
||||
result = response.get('result')
|
||||
real_url = {
|
||||
@ -15,11 +19,19 @@ def get_real_url(rid):
|
||||
'raw_flv_url': result.get('raw_flv_url', 0)
|
||||
}
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入NOW直播间数字ID:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
now = Now(rid)
|
||||
return now.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入NOW直播间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
27
pps.py
27
pps.py
@ -5,9 +5,14 @@ import re
|
||||
import time
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
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(rid)).text
|
||||
response = requests.get('http://m-x.pps.tv/room/' + str(self.rid)).text
|
||||
anchor_id = re.findall(r'anchor_id":(\d*),"online_uid', response)[0]
|
||||
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)
|
||||
@ -18,11 +23,19 @@ def get_real_url(rid):
|
||||
response = requests.get(url=url, headers=headers).text
|
||||
real_url = re.findall(r'"hls":"(.*)","rate_list', response)[0]
|
||||
except:
|
||||
real_url = '直播间未开播或不存在'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入奇秀直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
pps = PPS(rid)
|
||||
return pps.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入奇秀直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
27
qf.py
27
qf.py
@ -5,17 +5,30 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
class QF:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.post(url='https://qf.56.com/' + rid).text
|
||||
response = requests.post(url='https://qf.56.com/' + self.rid).text
|
||||
real_url = re.findall(r"flvUrl:'(.*)\?wsSecret", response)
|
||||
real_url = real_url[0]
|
||||
except:
|
||||
real_url = '该直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入千帆直播房间号:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
qf = QF(rid)
|
||||
return qf.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入千帆直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
23
qie.py
23
qie.py
@ -1,11 +1,17 @@
|
||||
# 企鹅体育:https://live.qq.com/directory/all
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def qie(rid):
|
||||
class ESport:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://m.live.qq.com/' + str(rid))
|
||||
res = s.get('https://m.live.qq.com/' + str(self.rid))
|
||||
show_status = re.search(r'"show_status":"(\d)"', res.text)
|
||||
if show_status:
|
||||
if show_status.group(1) == '1':
|
||||
@ -17,6 +23,15 @@ def qie(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
es = ESport(rid)
|
||||
return es.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入企鹅体育直播间号:\n')
|
||||
print(qie(r))
|
||||
r = input('请输入企鹅体育直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
23
renren.py
23
renren.py
@ -1,12 +1,18 @@
|
||||
# 人人直播:http://zhibo.renren.com/
|
||||
|
||||
import requests
|
||||
import re
|
||||
import hashlib
|
||||
|
||||
|
||||
def renren(rid):
|
||||
class RenRen:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('http://activity.renren.com/liveroom/' + str(rid))
|
||||
res = s.get('http://activity.renren.com/liveroom/' + str(self.rid))
|
||||
livestate = re.search(r'"liveState":(\d)', res.text)
|
||||
if livestate:
|
||||
try:
|
||||
@ -28,6 +34,15 @@ def renren(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
rr = RenRen(rid)
|
||||
return rr.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入人人直播房间号:\n')
|
||||
print(renren(r))
|
||||
r = input('请输入人人直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
15
requirements.txt
Normal file
15
requirements.txt
Normal file
@ -0,0 +1,15 @@
|
||||
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
|
25
showself.py
25
showself.py
@ -1,11 +1,17 @@
|
||||
# 秀色直播:https://www.showself.com/
|
||||
|
||||
from urllib.parse import urlencode
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
|
||||
|
||||
def showself(rid):
|
||||
class ShowSelf:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://service.showself.com/v2/custuser/visitor').json()
|
||||
uid = res['data']['uid']
|
||||
@ -17,7 +23,7 @@ def showself(rid):
|
||||
}
|
||||
payload = {
|
||||
'groupid': '999',
|
||||
'roomid': rid,
|
||||
'roomid': self.rid,
|
||||
'sessionid': sessionid,
|
||||
'sessionId': sessionid
|
||||
}
|
||||
@ -25,7 +31,7 @@ def showself(rid):
|
||||
data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5'
|
||||
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
|
||||
payload['_ajaxData1'] = _ajaxData1
|
||||
url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(rid, urlencode(params))
|
||||
url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(self.rid, urlencode(params))
|
||||
with requests.Session() as s:
|
||||
res = s.post(url, json=payload)
|
||||
if res.status_code == 200:
|
||||
@ -44,6 +50,15 @@ def showself(rid):
|
||||
raise Exception('参数错误')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
ss = ShowSelf(rid)
|
||||
return ss.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入秀色直播房间号:\n')
|
||||
print(showself(r))
|
||||
rid = input('输入秀色直播房间号:\n')
|
||||
print(get_real_url(rid))
|
||||
|
21
tuho.py
21
tuho.py
@ -1,11 +1,17 @@
|
||||
# 星光直播:https://www.tuho.tv/28545037
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def tuho(rid):
|
||||
class TuHo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://www.tuho.tv/' + str(rid)).text
|
||||
res = s.get('https://www.tuho.tv/' + str(self.rid)).text
|
||||
flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res)
|
||||
if flv:
|
||||
status = re.search(r'isPlaying\s:\s(\w+),', res).group(1)
|
||||
@ -18,6 +24,15 @@ def tuho(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
th = TuHo(rid)
|
||||
return th.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入星光直播房间号:\n')
|
||||
print(tuho(r))
|
||||
print(get_real_url(r))
|
||||
|
28
v6cn.py
28
v6cn.py
@ -4,9 +4,14 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
class V6CN:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
response = requests.get('https://v.6.cn/' + str(rid)).text
|
||||
response = requests.get('https://v.6.cn/' + str(self.rid)).text
|
||||
result = re.findall(r'"flvtitle":"v(\d*?)-(\d*?)"', response)[0]
|
||||
uid = result[0]
|
||||
flvtitle = 'v{}-{}'.format(*result)
|
||||
@ -14,11 +19,20 @@ def get_real_url(rid):
|
||||
hip = 'https://' + re.findall(r'<watchip>(.*\.xiu123\.cn).*</watchip>', response)[0]
|
||||
real_url = [hip + '/' + flvtitle + '/playlist.m3u8', hip + '/httpflv/' + flvtitle]
|
||||
except:
|
||||
real_url = '直播间不存在或未开播'
|
||||
raise Exception('直播间不存在或未开播')
|
||||
return real_url
|
||||
|
||||
|
||||
rid = input('请输入六间房直播ID:\n')
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
v6cn = V6CN(rid)
|
||||
return v6cn.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入六间房直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
25
wali.py
25
wali.py
@ -1,11 +1,17 @@
|
||||
# 小米直播:https://live.wali.com/fe
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def wali(rid):
|
||||
zuid = rid.split('_')[0]
|
||||
class WaLi:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
zuid = self.rid.split('_')[0]
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://s.zb.mi.com/get_liveinfo?lid={}&zuid={}'.format(rid, zuid)).json()
|
||||
res = s.get('https://s.zb.mi.com/get_liveinfo?lid={}&zuid={}'.format(self.rid, zuid)).json()
|
||||
status = res['data']['status']
|
||||
if status == 1:
|
||||
flv = res['data']['video']['flv']
|
||||
@ -14,6 +20,15 @@ def wali(rid):
|
||||
raise Exception('直播间不存在或未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
wali = WaLi(rid)
|
||||
return wali.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入小米直播房间号:\n')
|
||||
print(wali(r))
|
||||
r = input('请输入小米直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
23
woxiu.py
23
woxiu.py
@ -1,13 +1,19 @@
|
||||
# 我秀直播:https://www.woxiu.com/
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def woxiu(rid):
|
||||
class WoXiu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) '
|
||||
'Version/11.0 Mobile/15A372 Safari/604.1'
|
||||
}
|
||||
url = 'https://m.woxiu.com/index.php?action=M/Live&do=LiveInfo&room_id={}'.format(rid)
|
||||
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:
|
||||
@ -22,6 +28,15 @@ def woxiu(rid):
|
||||
raise Exception('未开播')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
wx = WoXiu(rid)
|
||||
return wx.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入我秀直播房间号:\n')
|
||||
print(woxiu(r))
|
||||
r = input('请输入我秀直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
24
xunlei.py
24
xunlei.py
@ -1,11 +1,17 @@
|
||||
# 迅雷直播:https://live.xunlei.com/global/index.html?id=0
|
||||
|
||||
import requests
|
||||
import hashlib
|
||||
import time
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
def xunlei(rid):
|
||||
class XunLei:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
url = 'https://biz-live-ssl.xunlei.com//caller'
|
||||
headers = {
|
||||
'cookie': 'appid=1002'
|
||||
@ -18,7 +24,7 @@ def xunlei(rid):
|
||||
'a': 'play',
|
||||
'c': 'room',
|
||||
'hid': 'h5-e70560ea31cc17099395c15595bdcaa1',
|
||||
'uuid': rid,
|
||||
'uuid': self.rid,
|
||||
}
|
||||
data = urlencode(params)
|
||||
p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest()
|
||||
@ -36,6 +42,16 @@ def xunlei(rid):
|
||||
raise Exception('直播间可能不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
xl = XunLei(rid)
|
||||
return xl.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入迅雷直播房间号:\n')
|
||||
print(xunlei(r))
|
||||
r = input('请输入迅雷直播房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
||||
|
37
yizhibo.py
37
yizhibo.py
@ -1,13 +1,17 @@
|
||||
# 获取一直播的真实流媒体地址。
|
||||
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
|
||||
def get_real_url(room_url):
|
||||
class YiZhiBo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
scid = re.findall(r'/l/(\S*).html', room_url)[0]
|
||||
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)
|
||||
@ -17,25 +21,30 @@ def get_real_url(room_url):
|
||||
'rtmpurl': rtmpurl
|
||||
}
|
||||
except:
|
||||
real_url = '链接错误'
|
||||
raise Exception('链接错误')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_status(room_url):
|
||||
def get_status(self):
|
||||
try:
|
||||
scid = re.findall(r'/l/(\S*).html', room_url)[0]
|
||||
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:
|
||||
status = '链接错误'
|
||||
raise Exception('链接错误')
|
||||
return status
|
||||
|
||||
|
||||
rid = input('请输入一直播房间地址:\n')
|
||||
status = get_status(rid)
|
||||
print('当前直播状态', status)
|
||||
real_url = get_real_url(rid)
|
||||
print('该直播间源地址为:')
|
||||
print(real_url)
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
yzb = YiZhiBo(rid)
|
||||
return yzb.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('请输入一直播房间地址:\n')
|
||||
print(get_real_url(r))
|
||||
|
25
youku.py
25
youku.py
@ -3,16 +3,22 @@
|
||||
# 而且没有平台水印和主播自己贴的乱七八糟的字幕遮挡。
|
||||
# liveId 是如下形式直播间链接:
|
||||
# “https://vku.youku.com/live/ilproom?spm=a2hcb.20025885.m_16249_c_59932.d_11&id=8019610&scm=20140670.rcmd.16249.live_8019610”中的8019610字段。
|
||||
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
|
||||
def youku(liveid):
|
||||
class YouKu:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
try:
|
||||
tt = str(int(time.time() * 1000))
|
||||
data = json.dumps({'liveId': liveid, 'app': 'Pc'}, separators=(',', ':'))
|
||||
data = json.dumps({'liveId': self.rid, 'app': 'Pc'}, separators=(',', ':'))
|
||||
url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788'
|
||||
s = requests.Session()
|
||||
cookies = s.get(url).cookies
|
||||
@ -29,10 +35,19 @@ def youku(liveid):
|
||||
real_url = 'http://lvo-live.youku.com/vod2live/{}_mp4hd2v3.m3u8?&expire=21600&psid=1&ups_ts={}&vkey='.format(
|
||||
streamname, int(time.time()))
|
||||
except:
|
||||
real_url = '请求错误'
|
||||
raise Exception('请求错误')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
yk = YouKu(rid)
|
||||
return yk.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入优酷轮播台liveId:\n')
|
||||
print(youku(r))
|
||||
r = input('请输入优酷轮播台房间号:\n')
|
||||
print(get_real_url(r))
|
||||
|
20
yuanbobo.py
20
yuanbobo.py
@ -3,9 +3,14 @@ import requests
|
||||
import re
|
||||
|
||||
|
||||
def yuanbobo(rid):
|
||||
class YuanBoBo:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://zhibo.yuanbobo.com/' + str(rid)).text
|
||||
res = s.get('https://zhibo.yuanbobo.com/' + str(self.rid)).text
|
||||
stream_id = re.search(r"stream_id:\s+'(\d+)'", res)
|
||||
if stream_id:
|
||||
status = re.search(r"status:\s+'(\d)'", res).group(1)
|
||||
@ -18,6 +23,15 @@ def yuanbobo(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
th = YuanBoBo(rid)
|
||||
return th.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入热猫直播房间号:\n')
|
||||
print(yuanbobo(r))
|
||||
print(get_real_url(r))
|
||||
|
23
yy.py
23
yy.py
@ -1,17 +1,23 @@
|
||||
# 获取YY直播的真实流媒体地址。https://www.yy.com/1349606469
|
||||
# 默认获取最高画质
|
||||
|
||||
import requests
|
||||
import re
|
||||
import json
|
||||
|
||||
|
||||
def yy(rid):
|
||||
class YY:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
headers = {
|
||||
'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=rid),
|
||||
'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=self.rid),
|
||||
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)'
|
||||
' Version/11.0 Mobile/15A372 Safari/604.1'
|
||||
}
|
||||
room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=rid)
|
||||
room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=self.rid)
|
||||
with requests.Session() as s:
|
||||
res = s.get(room_url, headers=headers)
|
||||
if res.status_code == 200:
|
||||
@ -30,6 +36,15 @@ def yy(rid):
|
||||
raise Exception('直播间不存在')
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
yy = YY(rid)
|
||||
return yy.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入YY直播房间号:\n')
|
||||
print(yy(r))
|
||||
print(get_real_url(r))
|
||||
|
24
zhanqi.py
24
zhanqi.py
@ -3,9 +3,14 @@
|
||||
import requests
|
||||
|
||||
|
||||
def zhanqi(rid):
|
||||
class ZhanQi:
|
||||
|
||||
def __init__(self, rid):
|
||||
self.rid = rid
|
||||
|
||||
def get_real_url(self):
|
||||
with requests.Session() as s:
|
||||
res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(rid))
|
||||
res = s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
|
||||
try:
|
||||
res = res.json()
|
||||
videoid = res['data']['videoId']
|
||||
@ -14,12 +19,21 @@ def zhanqi(rid):
|
||||
url = 'https://dlhdl-cdn.zhanqi.tv/zqlive/{}.flv?get_url=1'.format(videoid)
|
||||
real_url = s.get(url).text
|
||||
else:
|
||||
real_url = '未开播'
|
||||
raise Exception('未开播')
|
||||
except:
|
||||
real_url = '直播间不存在'
|
||||
raise Exception('直播间不存在')
|
||||
return real_url
|
||||
|
||||
|
||||
def get_real_url(rid):
|
||||
try:
|
||||
zq = ZhanQi(rid)
|
||||
return zq.get_real_url()
|
||||
except Exception as e:
|
||||
print('Exception:', e)
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = input('输入战旗直播房间号:\n')
|
||||
print(zhanqi(r))
|
||||
print(get_real_url(r))
|
||||
|
Loading…
x
Reference in New Issue
Block a user