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:
def __init__(self, rid):
"""
火猫直播已经倒闭了
Args:
rid: 房间号
"""
self.rid = rid
@staticmethod
def get_time():
tt = str(int((time.time() * 1000)))
return tt
@staticmethod
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
try:
videoids = re.findall(r'var stream = "([\w\W]+?)";', response)[0]
except IndexError:
except:
videoids = 0
return videoids
@staticmethod
def get_token(videoids):
tt = str(int((time.time() * 1000)))
token = hashlib.md5(f'{videoids}huomaoh5room{tt}6FE26D855E1AEAE090E243EB1AF73685'.encode('utf-8')).hexdigest()
def get_token(videoids, time):
token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) +
'6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest()
return token
def get_real_url(self):
videoids = self.get_videoids(self.rid)
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'
post_data = {
'cdns': 1,

View File

@ -11,12 +11,12 @@ class IMFun:
def get_real_url(self):
with requests.Session() as s:
res = s.get(f'https://www.imifun.com/{self.rid}').text
roomid = re.search(r'mixPkPlayUrl ="rtmp://wsmd.happyia.com/ivp/(\d+-\d+)"', res).group(1)
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)
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
else:
raise Exception('未开播')

View File

@ -2,28 +2,36 @@
import requests
import re
import hashlib
class RenRen:
def __init__(self, rid):
"""
直播间地址形式http://activity.renren.com/live/liveroom/970302934_21348
rid即970302934_21348
Args:
rid:房间号
"""
self.rid = rid
self.s = requests.Session()
def get_real_url(self):
res = self.s.get(f'http://activity.renren.com/live/liveroom/{self.rid}').text
with requests.Session() as s:
res = s.get('http://activity.renren.com/liveroom/' + str(self.rid))
livestate = re.search(r'"liveState":(\d)', res.text)
if livestate:
try:
s = re.search(r'playUrl":"(.*?)"', res)
play_url = s.group(1)
return play_url
except Exception:
s = re.search(r'"playUrl":"([\s\S]*?)"', res.text).group(1)
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):

View File

@ -10,14 +10,10 @@ class ShowSelf:
def __init__(self, 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):
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']
accesstoken = sessionid = res['data']['sessionid']
params = {
@ -31,13 +27,13 @@ class ShowSelf:
'sessionid': sessionid,
'sessionId': sessionid
}
# 合并两个字典
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()
payload['_ajaxData1'] = _ajaxData1
url = f'https://service.showself.com/v2/rooms/{self.rid}/members?{urlencode(params)}'
res = self.s.post(url, json=payload, headers=self.headers)
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:
res = res.json()
statuscode = res['status']['statuscode']
@ -64,5 +60,5 @@ def get_real_url(rid):
if __name__ == '__main__':
r = input('输入秀色直播房间号:\n')
print(get_real_url(r))
rid = input('输入秀色直播房间号:\n')
print(get_real_url(rid))

View File

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

View File

@ -11,7 +11,7 @@ class WaLi:
def get_real_url(self):
zuid = self.rid.split('_')[0]
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']
if status == 1:
flv = res['data']['video']['flv']

View File

@ -10,15 +10,15 @@ class WoXiu:
def get_real_url(self):
headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, '
'like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 '
'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 = 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:
res = s.get(url, headers=headers)
try:
res = res.json()
except Exception:
except:
raise Exception('直播间不存在')
status = res['online']
if status:

View File

@ -27,7 +27,7 @@ class XunLei:
'uuid': self.rid,
}
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
with requests.Session() as s:
res = s.get(url, params=params, headers=headers).json()
@ -54,3 +54,4 @@ def get_real_url(rid):
if __name__ == '__main__':
r = input('请输入迅雷直播房间号:\n')
print(get_real_url(r))

View File

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

View File

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

View File

@ -10,12 +10,12 @@ class YuanBoBo:
def get_real_url(self):
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)
if stream_id:
status = re.search(r"status:\s+'(\d)'", res).group(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
else:
raise Exception('未开播')

10
yy.py
View File

@ -13,11 +13,11 @@ class YY:
def get_real_url(self):
headers = {
'referer': f'https://wap.yy.com/mobileweb/{self.rid}',
'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 '
'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 = 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:
res = s.get(room_url, headers=headers)
if res.status_code == 200:
@ -26,7 +26,7 @@ class YY:
xa = data['audio']
xv = data['video']
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()
real_url = res['hls']
return real_url

View File

@ -2,7 +2,6 @@
# 默认最高画质
import json
import re
import requests
@ -10,18 +9,12 @@ import requests
class ZhanQi:
def __init__(self, rid):
"""
战旗直播间有两种一种是普通直播间号为数字或字幕另一种是官方的主题直播间链接带topic
所以先判断一次后从网页源代码里获取数字直播间号
Args:
rid:直播间链接从网页源码里获取真实数字rid
"""
self.rid = rid
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):
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:
res = res.json()
videoid = res['data']['videoId']
@ -55,6 +48,7 @@ class ZhanQi:
chain_key = res['data']['key']
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 '
return url
else:
raise Exception('No streaming')
@ -70,6 +64,5 @@ def get_real_url(rid):
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))