1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-07-31 13:44:48 +08:00

Update douyin.py

This commit is contained in:
ӘAЯY 2021-05-09 09:13:18 +08:00 committed by GitHub
parent b53230552f
commit 5032f637d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,13 +12,17 @@ class DouYin:
self.rid = rid
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).text
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]