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

Compare commits

..

No commits in common. "c0018d0fb1fd497f869100ed6ea24c14c0417344" and "4cb2edc05a2ce0a4f7dc24d3d08c4bf8b0434174" have entirely different histories.

14 changed files with 104 additions and 99 deletions

View File

@ -12,33 +12,34 @@ import re
class HuoMao: class HuoMao:
def __init__(self, rid): def __init__(self, rid):
"""
火猫直播已经倒闭了
Args:
rid: 房间号
"""
self.rid = rid self.rid = rid
@staticmethod
def get_time():
tt = str(int((time.time() * 1000)))
return tt
@staticmethod @staticmethod
def get_videoids(rid): def get_videoids(rid):
room_url = f'https://www.huomao.com/mobile/mob_live/{rid}' room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid)
response = requests.get(url=room_url).text response = requests.get(url=room_url).text
try: try:
videoids = re.findall(r'var stream = "([\w\W]+?)";', response)[0] videoids = re.findall(r'var stream = "([\w\W]+?)";', response)[0]
except IndexError: except:
videoids = 0 videoids = 0
return videoids return videoids
@staticmethod @staticmethod
def get_token(videoids): def get_token(videoids, time):
tt = str(int((time.time() * 1000))) token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) +
token = hashlib.md5(f'{videoids}huomaoh5room{tt}6FE26D855E1AEAE090E243EB1AF73685'.encode('utf-8')).hexdigest() '6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest()
return token return token
def get_real_url(self): def get_real_url(self):
videoids = self.get_videoids(self.rid) videoids = self.get_videoids(self.rid)
if videoids: if videoids:
token = self.get_token(videoids) time = self.get_time()
token = self.get_token(videoids, time)
room_url = 'https://www.huomao.com/swf/live_data' room_url = 'https://www.huomao.com/swf/live_data'
post_data = { post_data = {
'cdns': 1, 'cdns': 1,

View File

@ -11,12 +11,12 @@ class IMFun:
def get_real_url(self): def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get(f'https://www.imifun.com/{self.rid}').text res = s.get('https://www.imifun.com/' + str(self.rid)).text
roomid = re.search(r'mixPkPlayUrl ="rtmp://wsmd.happyia.com/ivp/(\d+-\d+)"', res).group(1) roomid = re.search(r"roomId:\s'([\w-]+)'", res)
if roomid: if roomid:
status = re.search(r"isLive:(\d),", res).group(1) status = re.search(r"isLive:(\d),", res).group(1)
if status == '1': if status == '1':
real_url = f'https://wsmd.happyia.com/ivp/{roomid}.flv' real_url = 'https://wsmd.happyia.com/ivp/{}.flv'.format(roomid.group(1))
return real_url return real_url
else: else:
raise Exception('未开播') raise Exception('未开播')

View File

@ -2,28 +2,36 @@
import requests import requests
import re import re
import hashlib
class RenRen: class RenRen:
def __init__(self, rid): def __init__(self, rid):
"""
直播间地址形式http://activity.renren.com/live/liveroom/970302934_21348
rid即970302934_21348
Args:
rid:房间号
"""
self.rid = rid self.rid = rid
self.s = requests.Session()
def get_real_url(self): def get_real_url(self):
res = self.s.get(f'http://activity.renren.com/live/liveroom/{self.rid}').text with requests.Session() as s:
try: res = s.get('http://activity.renren.com/liveroom/' + str(self.rid))
s = re.search(r'playUrl":"(.*?)"', res) livestate = re.search(r'"liveState":(\d)', res.text)
play_url = s.group(1) if livestate:
return play_url try:
except Exception: s = re.search(r'"playUrl":"([\s\S]*?)"', res.text).group(1)
raise Exception('解析错误') if livestate.group(1) == '0':
# accesskey = re.search(r'accesskey=(\w+)', s).group(1)
# expire = re.search(r'expire=(\d+)', s).group(1)
# live = re.search(r'(/live/\d+)', s).group(1)
# c = accesskey + expire + live
# key = hashlib.md5(c.encode('utf-8')).hexdigest()
# e = s.split('?')[0].split('/')[4]
# t = 'http://ksy-hls.renren.com/live/' + e + '/index.m3u8?key=' + key
return s
elif livestate.group(1) == '1':
return '回放:' + s
except IndexError:
raise Exception('解析错误')
else:
raise Exception('直播间不存在')
def get_real_url(rid): def get_real_url(rid):

View File

@ -10,14 +10,10 @@ class ShowSelf:
def __init__(self, rid): def __init__(self, rid):
self.rid = rid self.rid = rid
self.headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/95.0.4638.69 Safari/537.36 '
}
self.s = requests.Session()
def get_real_url(self): def get_real_url(self):
res = self.s.get('https://service.showself.com/v2/custuser/visitor', headers=self.headers).json() with requests.Session() as s:
res = s.get('https://service.showself.com/v2/custuser/visitor').json()
uid = res['data']['uid'] uid = res['data']['uid']
accesstoken = sessionid = res['data']['sessionid'] accesstoken = sessionid = res['data']['sessionid']
params = { params = {
@ -31,13 +27,13 @@ class ShowSelf:
'sessionid': sessionid, 'sessionid': sessionid,
'sessionId': sessionid 'sessionId': sessionid
} }
# 合并两个字典
data = dict(params, **payload) data = dict(params, **payload)
data = f'{urlencode(sorted(data.items(), key=lambda d: d[0]))}sh0wselfh5' data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5'
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest() _ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
payload['_ajaxData1'] = _ajaxData1 payload['_ajaxData1'] = _ajaxData1
url = f'https://service.showself.com/v2/rooms/{self.rid}/members?{urlencode(params)}' url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(self.rid, urlencode(params))
res = self.s.post(url, json=payload, headers=self.headers) with requests.Session() as s:
res = s.post(url, json=payload)
if res.status_code == 200: if res.status_code == 200:
res = res.json() res = res.json()
statuscode = res['status']['statuscode'] statuscode = res['status']['statuscode']
@ -64,5 +60,5 @@ def get_real_url(rid):
if __name__ == '__main__': if __name__ == '__main__':
r = input('输入秀色直播房间号:\n') rid = input('输入秀色直播房间号:\n')
print(get_real_url(r)) print(get_real_url(rid))

View File

@ -11,7 +11,7 @@ class TuHo:
def get_real_url(self): def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get(f'https://www.tuho.tv/{self.rid}').text res = s.get('https://www.tuho.tv/' + str(self.rid)).text
flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res) flv = re.search(r'videoPlayFlv":"(https[\s\S]+?flv)', res)
if flv: if flv:
status = re.search(r'isPlaying\s:\s(\w+),', res).group(1) status = re.search(r'isPlaying\s:\s(\w+),', res).group(1)

11
v6cn.py
View File

@ -11,14 +11,14 @@ class V6CN:
def get_real_url(self): def get_real_url(self):
try: try:
response = requests.get(f'https://v.6.cn/{self.rid}').text response = requests.get('https://v.6.cn/' + str(self.rid)).text
result = re.findall(r'"flvtitle":"v(\d*?)-(\d*?)"', response)[0] result = re.findall(r'"flvtitle":"v(\d*?)-(\d*?)"', response)[0]
uid = result[0] uid = result[0]
flvtitle = 'v{}-{}'.format(*result) flvtitle = 'v{}-{}'.format(*result)
response = requests.get(f'https://rio.6rooms.com/live/?s={uid}').text response = requests.get('https://rio.6rooms.com/live/?s=' + str(uid)).text
hip = 'https://' + re.search(r'<watchip>(.*\.com).*?</watchip>', response).group(1) hip = 'https://' + re.findall(r'<watchip>(.*\.xiu123\.cn).*</watchip>', response)[0]
real_url = [f'{hip}/{flvtitle}/palylist.m3u8', f'{hip}/httpflv/{flvtitle}'] real_url = [hip + '/' + flvtitle + '/playlist.m3u8', hip + '/httpflv/' + flvtitle]
except Exception: except:
raise Exception('直播间不存在或未开播') raise Exception('直播间不存在或未开播')
return real_url return real_url
@ -35,3 +35,4 @@ def get_real_url(rid):
if __name__ == '__main__': if __name__ == '__main__':
r = input('请输入六间房直播房间号:\n') r = input('请输入六间房直播房间号:\n')
print(get_real_url(r)) print(get_real_url(r))

View File

@ -11,7 +11,7 @@ class WaLi:
def get_real_url(self): def get_real_url(self):
zuid = self.rid.split('_')[0] zuid = self.rid.split('_')[0]
with requests.Session() as s: with requests.Session() as s:
res = s.get(f'https://s.zb.mi.com/get_liveinfo?lid={self.rid}&zuid={zuid}').json() res = s.get('https://s.zb.mi.com/get_liveinfo?lid={}&zuid={}'.format(self.rid, zuid)).json()
status = res['data']['status'] status = res['data']['status']
if status == 1: if status == 1:
flv = res['data']['video']['flv'] flv = res['data']['video']['flv']

View File

@ -10,15 +10,15 @@ class WoXiu:
def get_real_url(self): def get_real_url(self):
headers = { headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, ' 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) '
'like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 ' 'Version/11.0 Mobile/15A372 Safari/604.1'
} }
url = f'https://m.woxiu.com/index.php?action=M/Live&do=LiveInfo&room_id={self.rid}' url = 'https://m.woxiu.com/index.php?action=M/Live&do=LiveInfo&room_id={}'.format(self.rid)
with requests.Session() as s: with requests.Session() as s:
res = s.get(url, headers=headers) res = s.get(url, headers=headers)
try: try:
res = res.json() res = res.json()
except Exception: except:
raise Exception('直播间不存在') raise Exception('直播间不存在')
status = res['online'] status = res['online']
if status: if status:

View File

@ -27,7 +27,7 @@ class XunLei:
'uuid': self.rid, 'uuid': self.rid,
} }
data = urlencode(params) data = urlencode(params)
p = hashlib.md5(f'{u}{data}{f}'.encode('utf-8')).hexdigest() p = hashlib.md5((u + data + f).encode('utf-8')).hexdigest()
params['sign'] = p params['sign'] = p
with requests.Session() as s: with requests.Session() as s:
res = s.get(url, params=params, headers=headers).json() res = s.get(url, params=params, headers=headers).json()
@ -54,3 +54,4 @@ def get_real_url(rid):
if __name__ == '__main__': if __name__ == '__main__':
r = input('请输入迅雷直播房间号:\n') r = input('请输入迅雷直播房间号:\n')
print(get_real_url(r)) print(get_real_url(r))

View File

@ -7,24 +7,33 @@ import re
class YiZhiBo: class YiZhiBo:
def __init__(self, rid): def __init__(self, rid):
"""
一直播需要传入直播间的完整地址
Args:
rid:完整地址
"""
self.rid = rid self.rid = rid
self.s = requests.Session()
def get_real_url(self): def get_real_url(self):
try: try:
res = self.s.get(self.rid).text scid = re.findall(r'/l/(\S*).html', self.rid)[0]
play_url, status_code = re.findall(r'play_url:"(.*?)"[\s\S]*status:(\d+),', res)[0] flvurl = 'http://alcdn.f01.xiaoka.tv/live/{}.flv'.format(scid)
if status_code == '10': m3u8url = 'http://al01.alcdn.hls.xiaoka.tv/live/{}.m3u8'.format(scid)
return play_url rtmpurl = 'rtmp://alcdn.r01.xiaoka.tv/live/live/{}'.format(scid)
else: real_url = {
raise Exception('未开播') 'flvurl': flvurl,
except Exception: 'm3u8url': m3u8url,
raise Exception('获取错误') '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): def get_real_url(rid):

View File

@ -13,32 +13,28 @@ import json
class YouKu: class YouKu:
def __init__(self, rid): def __init__(self, rid):
"""
获取优酷轮播台的流媒体地址
Args:
rid: 直播间url中id=8019610其中id即为房间号
"""
self.rid = rid self.rid = rid
self.s = requests.Session()
def get_real_url(self): def get_real_url(self):
try: try:
tt = str(int(time.time() * 1000)) tt = str(int(time.time() * 1000))
data = json.dumps({'liveId': self.rid, 'app': 'Pc'}, separators=(',', ':')) data = json.dumps({'liveId': self.rid, 'app': 'Pc'}, separators=(',', ':'))
url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788' url = 'https://acs.youku.com/h5/mtop.youku.live.com.livefullinfo/1.0/?appKey=24679788'
cookies = self.s.get(url).cookies s = requests.Session()
token = cookies.get_dict().get('_m_h5_tk')[0:32] cookies = s.get(url).cookies
sign = hashlib.md5(f'{token}&{tt}&24679788&{data}'.encode('utf-8')).hexdigest() 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 = { params = {
't': tt, 't': tt,
'sign': sign, 'sign': sign,
'data': data 'data': data
} }
response = self.s.get(url, params=params).json() 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') streamname = response.get('data').get('data').get('stream')[0].get('streamName')
real_url = f'https://lvo-live.youku.com/vod2live/{streamname}_mp4hd2v3.m3u8?&expire=21600&psid=1&ups_ts=' \ real_url = 'http://lvo-live.youku.com/vod2live/{}_mp4hd2v3.m3u8?&expire=21600&psid=1&ups_ts={}&vkey='.format(
f'{int(time.time())}&vkey= ' streamname, int(time.time()))
except Exception: except:
raise Exception('请求错误') raise Exception('请求错误')
return real_url return real_url

View File

@ -10,12 +10,12 @@ class YuanBoBo:
def get_real_url(self): def get_real_url(self):
with requests.Session() as s: with requests.Session() as s:
res = s.get(f'https://zhibo.yuanbobo.com/{self.rid}').text res = s.get('https://zhibo.yuanbobo.com/' + str(self.rid)).text
stream_id = re.search(r"stream_id:\s+'(\d+)'", res) stream_id = re.search(r"stream_id:\s+'(\d+)'", res)
if stream_id: if stream_id:
status = re.search(r"status:\s+'(\d)'", res).group(1) status = re.search(r"status:\s+'(\d)'", res).group(1)
if status == '1': if status == '1':
real_url = f'https://tliveplay.yuanbobo.com/live/{stream_id.group(1)}.m3u8' real_url = 'http://ks-hlslive.yuanbobo.com/live/{}/index.m3u8'.format(stream_id.group(1))
return real_url return real_url
else: else:
raise Exception('未开播') raise Exception('未开播')

10
yy.py
View File

@ -13,11 +13,11 @@ class YY:
def get_real_url(self): def get_real_url(self):
headers = { headers = {
'referer': f'https://wap.yy.com/mobileweb/{self.rid}', 'referer': 'http://wap.yy.com/mobileweb/{rid}'.format(rid=self.rid),
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko)'
'Chrome/95.0.4638.69 Safari/537.36 ' ' Version/11.0 Mobile/15A372 Safari/604.1'
} }
room_url = f'https://interface.yy.com/hls/new/get/{self.rid}/{self.rid}/1200?source=wapyy&callback=' room_url = 'http://interface.yy.com/hls/new/get/{rid}/{rid}/1200?source=wapyy&callback='.format(rid=self.rid)
with requests.Session() as s: with requests.Session() as s:
res = s.get(room_url, headers=headers) res = s.get(room_url, headers=headers)
if res.status_code == 200: if res.status_code == 200:
@ -26,7 +26,7 @@ class YY:
xa = data['audio'] xa = data['audio']
xv = data['video'] xv = data['video']
xv = re.sub(r'_0_\d+_0', '_0_0_0', xv) xv = re.sub(r'_0_\d+_0', '_0_0_0', xv)
url = f'https://interface.yy.com/hls/get/stream/15013/{xv}/15013/{xa}?source=h5player&type=m3u8' url = 'https://interface.yy.com/hls/get/stream/15013/{}/15013/{}?source=h5player&type=m3u8'.format(xv, xa)
res = s.get(url).json() res = s.get(url).json()
real_url = res['hls'] real_url = res['hls']
return real_url return real_url

View File

@ -2,7 +2,6 @@
# 默认最高画质 # 默认最高画质
import json import json
import re
import requests import requests
@ -10,18 +9,12 @@ import requests
class ZhanQi: class ZhanQi:
def __init__(self, rid): def __init__(self, rid):
""" self.rid = rid
战旗直播间有两种一种是普通直播间号为数字或字幕另一种是官方的主题直播间链接带topic
所以先判断一次后从网页源代码里获取数字直播间号
Args:
rid:直播间链接从网页源码里获取真实数字rid
"""
self.s = requests.Session() self.s = requests.Session()
res = self.s.get(rid).text
self.rid = re.search(r'"code":"(\d+)"', res).group(1)
def get_real_url(self): def get_real_url(self):
res = self.s.get(f'https://m.zhanqi.tv/api/static/v2.1/room/domain/{self.rid}.json')
res = self.s.get('https://m.zhanqi.tv/api/static/v2.1/room/domain/{}.json'.format(self.rid))
try: try:
res = res.json() res = res.json()
videoid = res['data']['videoId'] videoid = res['data']['videoId']
@ -54,7 +47,8 @@ class ZhanQi:
res = self.s.post('https://www.zhanqi.tv/api/public/burglar/chain', data=data, headers=headers).json() res = self.s.post('https://www.zhanqi.tv/api/public/burglar/chain', data=data, headers=headers).json()
chain_key = res['data']['key'] chain_key = res['data']['key']
url = f'https://{cdn_host}/alhdl-cdn.zhanqi.tv/zqlive/{videoid}.flv?{chain_key}&playNum=68072487067' \ url = f'https://{cdn_host}/alhdl-cdn.zhanqi.tv/zqlive/{videoid}.flv?{chain_key}&playNum=68072487067' \
f'&gId={gid}&ipFrom=1&clientIp=&fhost=h5&platform=128' f'&gId={gid}&ipFrom=1&clientIp=&fhost=h5&platform=128 '
return url return url
else: else:
raise Exception('No streaming') raise Exception('No streaming')
@ -70,6 +64,5 @@ def get_real_url(rid):
if __name__ == '__main__': if __name__ == '__main__':
# 直播间链接类似https://www.zhanqi.tv/topic/owl 或 https://www.zhanqi.tv/152600919 r = input('输入战旗直播房间号:\n')
r = input('输入战旗直播间的链接:\n')
print(get_real_url(r)) print(get_real_url(r))