1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-07-29 21:00:30 +08:00

Compare commits

...

9 Commits

Author SHA1 Message Date
wbt5
8b7635d2fc
🎨 Improve KK直播
-优化代码
2021-11-21 18:04:44 +08:00
wbt5
58d4d88942
🐛 Fix 酷狗繁星直播
-修复不同频道直播间无法获取的问题
-仅保留HLS格式直播流
-优化代码
2021-11-21 17:57:53 +08:00
wbt5
a81a75fa8c
🎨 Improve 来疯直播
-优化代码
2021-11-21 16:52:39 +08:00
wbt5
8f9141bece
🐛 Fix 龙珠直播
-将获取的流媒体格式改为HLS
-优化代码
2021-11-21 16:45:26 +08:00
wbt5
e7c495a3c3
🎨 Improve 网易LOOK直播
-优化代码
2021-11-21 16:31:48 +08:00
wbt5
73cfbc9125
Improve NOW直播
-优化代码
2021-11-21 15:42:41 +08:00
wbt5
ae088352a6
🐛 Fix 搜狐千帆直播
-修复特殊直播间的获取方法
-优化代码
2021-11-21 15:21:56 +08:00
wbt5
df10de8686
🎨 Improve 搜狐千帆直播
-优化代码
2021-11-21 14:55:09 +08:00
wbt5
ccc5598774
🎨 Improve 企鹅体育直播
-优化代码
2021-11-21 14:48:42 +08:00
8 changed files with 107 additions and 43 deletions

14
kk.py
View File

@ -5,20 +5,24 @@ import requests
class KK:
def __init__(self, rid):
"""
KK直播
Args:
rid: 房间号
"""
self.rid = rid
self.s = requests.Session()
def get_real_url(self):
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(self.rid), 'platform': 1, 'a': 1, 'c': 100101}
with requests.Session() as s:
res = s.get(url.format(parameter)).json()
parameter = {'FuncTag': 10005043, 'userId': f'{self.rid}', 'platform': 1, 'a': 1, 'c': 100101}
res = self.s.get(url.format(parameter)).json()
tagcode = res['TagCode']
if tagcode == '00000000':
if res.get('liveType', 0) == 1:
roomid = res['roomId']
parameter = {'FuncTag': 60001002, 'roomId': roomid, 'platform': 1, 'a': 1, 'c': 100101}
with requests.Session() as s:
res = s.get(url.format(parameter)).json()
res = self.s.get(url.format(parameter)).json()
real_url = res['liveStream']
return real_url
else:

View File

@ -6,17 +6,53 @@ import requests
class KuGou:
def __init__(self, rid):
"""
酷狗繁星直播
Args:
rid: 房间号
"""
self.rid = rid
self.s = requests.Session()
self.BASE_URL = 'https://fx1.service.kugou.com/video/mo/live/pull/h5/v3/streamaddr'
def get_real_url(self):
params = {
'roomId': self.rid,
'platform': 18,
'version': 1000,
'streamType': '3-6',
'liveType': 1,
'ch': 'fx',
'ua': 'fx-mobile-h5',
'kugouId': 0,
'layout': 1
}
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}
res = self.s.get(self.BASE_URL, params=params).json()
if res['code'] == 1:
raise Exception(f'{res["msg"]},可能是房间号输入错误!')
real_url_hls = res.get('data').get('horizontal')[0].get('httpshls')[0]
except IndexError:
try:
url = f'https://fx1.service.kugou.com/biz/ChannelVServices/' \
f'RoomLiveService.RoomLiveService.getCurrentLiveStarForMob/{self.rid}'
res = self.s.get(url).json()
if res['code'] == 1:
raise Exception(f'{res["msg"]},可能是房间号输入错误!')
roomid = res['data']['roomId']
self.BASE_URL = 'https://fx2.service.kugou.com/video/pc/live/pull/mutiline/streamaddr'
params = {
'std_rid': roomid,
'version': '1.0',
'streamType': '1-2-3-5-6',
'targetLiveTypes': '1-4-5-6',
'ua': 'fx-h5'
}
res = self.s.get(self.BASE_URL, params=params).json()
real_url_hls = res.get('data').get('lines')[-1].get('streamProfiles')[-1]['httpsHls'][-1]
except Exception:
raise Exception('未找到')
return real_url_hls
def get_real_url(rid):

View File

@ -9,18 +9,25 @@ import re
class LaiFeng:
def __init__(self, rid):
"""
来疯直播
Args:
rid: 房间号
"""
self.rid = rid
self.s = requests.Session()
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]
response_main = self.s.get(f'http://v.laifeng.com/{self.rid}/m').text
stream_name = re.search(r"initAlias:'(.*)?'", response_main).group(1)
real_url = {}
for stream_format in ['HttpFlv', 'Hls']:
request_url = 'https://lapi.lcloud.laifeng.com/Play?AppId=101&CallerVersion=2.0&StreamName={}&Action=Schedule&Version=2.0&Format={}'.format(stream_name, stream_format)
response = requests.get(url=request_url).json()
request_url = f'https://lapi.lcloud.laifeng.com/Play?AppId=101&CallerVersion=2.0&StreamName' \
f'={stream_name}&Action=Schedule&Version=2.0&Format={stream_format}'
response = self.s.get(request_url).json()
real_url[stream_format] = response.get(stream_format)[0].get('Url')
except:
except Exception:
raise Exception('该直播间不存在或未开播')
return real_url

View File

@ -7,15 +7,22 @@ import re
class LongZhu:
def __init__(self, rid):
"""
龙珠直播获取hls格式的播放地址
Args:
rid: 直播房间号
"""
self.rid = rid
self.s = requests.Session()
def get_real_url(self):
try:
response = requests.get('http://star.longzhu.com/' + str(self.rid)).text
roomId = re.findall(r'roomid":(\d+)', response)[0]
response = requests.get('http://livestream.longzhu.com/live/getlivePlayurl?roomId={}&utmSr=&platform=h5&device=ios'.format(roomId)).json()
real_url = response.get('playLines')[0].get('urls')[0].get('securityUrl')
except:
res = self.s.get(f'http://star.longzhu.com/{self.rid}').text
roomId = re.search(r'roomid":(\d+)', res).group(1)
res = self.s.get(f'http://livestream.longzhu.com/live/getlivePlayurl?roomId={roomId}&utmSr=&platform=h5'
f'&device=ios').json()
real_url = res.get('playLines')[0].get('urls')[-1].get('securityUrl')
except Exception:
raise Exception('直播间不存在或未开播')
return real_url

26
look.py
View File

@ -17,12 +17,14 @@ import random
import requests
from Crypto.Cipher import AES
modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee34' \
'1f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e' \
'82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
nonce = b'0CoJUm6Qyw8W8jud'
pubKey = '010001'
def aes_encrypt(text, secKey):
def aes_encrypt(text, seckey):
pad = 16 - len(text) % 16
# aes加密需要byte类型。
@ -31,16 +33,16 @@ def aes_encrypt(text, secKey):
try:
text = text.decode()
except:
pass
except Exception as e:
print(e)
text = text + pad * chr(pad)
try:
text = text.encode()
except:
pass
except Exception as e:
print(e)
encryptor = AES.new(secKey, 2, bytes('0102030405060708', 'utf-8'))
encryptor = AES.new(seckey, 2, bytes('0102030405060708', 'utf-8'))
ciphertext = encryptor.encrypt(text)
ciphertext = base64.b64encode(ciphertext)
return ciphertext
@ -56,10 +58,10 @@ def create_secret_key(size):
return bytes(''.join(random.sample('1234567890qwertyuipasdfghjklzxcvbnm', size)), 'utf-8')
def rsa_encrypt(text, pub_key, modulus):
def rsa_encrypt(text, pub_key, mod):
text = text[::-1]
# 3中将字符串转成hex的函数变成了binascii.hexlify, 2中可以直接 str.encode('hex')
rs = int(binascii.hexlify(text), 16) ** int(pub_key, 16) % int(modulus, 16)
rs = int(binascii.hexlify(text), 16) ** int(pub_key, 16) % int(mod, 16)
return format(rs, 'x').zfill(256)
@ -82,11 +84,9 @@ class Look:
def get_real_url(self):
try:
request_data = encrypted_request({"liveRoomNo": self.rid})
response = requests.post(url='https://api.look.163.com/weapi/livestream/room/get/v3',
data=request_data)
response = requests.post(url='https://api.look.163.com/weapi/livestream/room/get/v3', data=request_data)
real_url = response.json()['data']['roomInfo']['liveUrl']
except:
except Exception:
raise Exception('直播间不存在或未开播')
return real_url

4
now.py
View File

@ -10,7 +10,7 @@ class Now:
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)
room_url = f'https://now.qq.com/cgi-bin/now/web/room/get_live_room_url?room_id={self.rid}&platform=8'
response = requests.get(url=room_url).json()
result = response.get('result')
real_url = {
@ -18,7 +18,7 @@ class Now:
'raw_rtmp_url': result.get('raw_rtmp_url', 0),
'raw_flv_url': result.get('raw_flv_url', 0)
}
except:
except Exception:
raise Exception('直播间不存在或未开播')
return real_url

18
qf.py
View File

@ -8,14 +8,24 @@ import re
class QF:
def __init__(self, rid):
"""
搜狐千帆直播可以直接在网页源码里找到播放地址
Args:
rid: 数字直播间号
"""
self.rid = rid
self.s = requests.Session()
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:
res = self.s.get(f'https://qf.56.com/{self.rid}').text
flvurl = re.search(r"flvUrl:'(.*)?'", res).group(1)
if 'flv' in flvurl:
real_url = flvurl
else:
res = self.s.get(flvurl).json()
real_url = res['url']
except Exception:
raise Exception('直播间不存在或未开播')
return real_url

2
qie.py
View File

@ -11,7 +11,7 @@ class ESport:
def get_real_url(self):
with requests.Session() as s:
res = s.get('https://m.live.qq.com/' + str(self.rid))
res = s.get(f'https://m.live.qq.com/{self.rid}')
show_status = re.search(r'"show_status":"(\d)"', res.text)
if show_status:
if show_status.group(1) == '1':