mirror of
https://github.com/wbt5/real-url.git
synced 2026-03-25 02:26:55 +08:00
Compare commits
No commits in common. "b6daf0abcd445b6ede76221a7d2aac383bc87a2e" and "8b7635d2fcb0e104f97f64a4927ad537d6520ff0" have entirely different histories.
b6daf0abcd
...
8b7635d2fc
5
bigo.py
5
bigo.py
@ -3,12 +3,11 @@
|
|||||||
# @Project: my-spiders
|
# @Project: my-spiders
|
||||||
# @Author: wbt5
|
# @Author: wbt5
|
||||||
# @Blog: https://wbt5.com
|
# @Blog: https://wbt5.com
|
||||||
# BIGO LIVE:https://www.bigo.tv/cn/
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class Bigo:
|
class bigo:
|
||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
self.rid = rid
|
self.rid = rid
|
||||||
@ -24,7 +23,7 @@ class Bigo:
|
|||||||
|
|
||||||
def get_real_url(rid):
|
def get_real_url(rid):
|
||||||
try:
|
try:
|
||||||
url = Bigo(rid)
|
url = bigo(rid)
|
||||||
return url.get_real_url()
|
return url.get_real_url()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Exception:', e)
|
print('Exception:', e)
|
||||||
|
|||||||
80
douyin.py
80
douyin.py
@ -1,51 +1,45 @@
|
|||||||
import re
|
# 获取抖音直播的真实流媒体地址,默认最高画质。
|
||||||
import sys
|
# 如果知道该直播间如“6779127643792280332”形式的room_id,则直接传入room_id。
|
||||||
|
# 如果不知道room_id,可以使用手机上打开直播间后,选择“分享--复制链接”,传入如“https://v.douyin.com/qyRqMp/”形式的分享链接。
|
||||||
|
#
|
||||||
import requests
|
import requests
|
||||||
|
import re
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
headers = {
|
class DouYin:
|
||||||
'authority': 'v.douyin.com',
|
|
||||||
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1',
|
|
||||||
}
|
|
||||||
|
|
||||||
url = input('请输入抖音直播链接或19位room_id:')
|
def __init__(self, rid):
|
||||||
if re.match(r'\d{19}', url):
|
self.rid = rid
|
||||||
room_id = url
|
|
||||||
else:
|
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',
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
if 'v.douyin.com' in self.rid:
|
||||||
|
room_id = re.findall(r'(\d{19})', requests.get(url=self.rid).url)[0]
|
||||||
|
else:
|
||||||
|
room_id = self.rid
|
||||||
|
room_url = 'https://webcast.amemv.com/webcast/reflow/{}'.format(room_id)
|
||||||
|
response = requests.get(url=room_url, headers= headers).text
|
||||||
|
rtmp_pull_url = re.search(r'"rtmp_pull_url":"(.*?flv)"', response).group(1)
|
||||||
|
hls_pull_url = re.search(r'"hls_pull_url":"(.*?m3u8)"', response).group(1)
|
||||||
|
real_url = [rtmp_pull_url, hls_pull_url]
|
||||||
|
except:
|
||||||
|
raise Exception('直播间不存在或未开播或参数错误')
|
||||||
|
return real_url
|
||||||
|
|
||||||
|
|
||||||
|
def get_real_url(rid):
|
||||||
try:
|
try:
|
||||||
url = re.search(r'(https.*)', url).group(1)
|
dy = DouYin(rid)
|
||||||
response = requests.head(url, headers=headers)
|
return dy.get_real_url()
|
||||||
url = response.headers['location']
|
|
||||||
room_id = re.search(r'\d{19}', url).group(0)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if DEBUG:
|
print('Exception:', e)
|
||||||
print(e)
|
return False
|
||||||
print('获取room_id失败')
|
|
||||||
sys.exit(1)
|
|
||||||
print('room_id', room_id)
|
|
||||||
|
|
||||||
try:
|
|
||||||
headers.update({
|
|
||||||
'authority': 'webcast.amemv.com',
|
|
||||||
'cookie': '_tea_utm_cache_1128={%22utm_source%22:%22copy%22%2C%22utm_medium%22:%22android%22%2C%22utm_campaign%22:%22client_share%22}',
|
|
||||||
})
|
|
||||||
|
|
||||||
params = (
|
if __name__ == '__main__':
|
||||||
('type_id', '0'),
|
r = input('请输入抖音直播间room_id或分享链接:\n')
|
||||||
('live_id', '1'),
|
print(get_real_url(r))
|
||||||
('room_id', room_id),
|
|
||||||
('app_id', '1128'),
|
|
||||||
)
|
|
||||||
|
|
||||||
response = requests.get('https://webcast.amemv.com/webcast/room/reflow/info/', headers=headers, params=params).json()
|
|
||||||
|
|
||||||
rtmp_pull_url = response['data']['room']['stream_url']['rtmp_pull_url']
|
|
||||||
hls_pull_url = response['data']['room']['stream_url']['hls_pull_url']
|
|
||||||
print(rtmp_pull_url)
|
|
||||||
print(hls_pull_url)
|
|
||||||
except Exception as e:
|
|
||||||
if DEBUG:
|
|
||||||
print(e)
|
|
||||||
print('获取real url失败')
|
|
||||||
|
|||||||
2
douyu.py
2
douyu.py
@ -127,7 +127,7 @@ class DouYu:
|
|||||||
else:
|
else:
|
||||||
key = self.get_js()
|
key = self.get_js()
|
||||||
real_url = {}
|
real_url = {}
|
||||||
real_url["flv"] = "http://vplay1a.douyucdn.cn/live/{}.flv?uuid=".format(key)
|
real_url["flv"] = "http://dyscdnali1.douyucdn.cn/live/{}.flv?uuid=".format(key)
|
||||||
real_url["x-p2p"] = "http://tx2play1.douyucdn.cn/live/{}.xs?uuid=".format(key)
|
real_url["x-p2p"] = "http://tx2play1.douyucdn.cn/live/{}.xs?uuid=".format(key)
|
||||||
return real_url
|
return real_url
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class Twitch:
|
|||||||
def get_client_id(self):
|
def get_client_id(self):
|
||||||
try:
|
try:
|
||||||
res = self.s.get(f'https://www.twitch.tv/{self.rid}').text
|
res = self.s.get(f'https://www.twitch.tv/{self.rid}').text
|
||||||
client_id = re.search(r'clientId="(.*?)"', res).group(1)
|
client_id = re.search(r'"Client-ID":"(.*?)"', res).group(1)
|
||||||
return client_id
|
return client_id
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
raise Exception('ConnectionError')
|
raise Exception('ConnectionError')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user