Skip to content

Commit 5032f63

Browse files
authored
Update douyin.py
1 parent b532305 commit 5032f63

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

douyin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ def __init__(self, rid):
1212
self.rid = rid
1313

1414
def get_real_url(self):
15+
headers = {
16+
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, '
17+
'like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
18+
}
1519
try:
1620
if 'v.douyin.com' in self.rid:
1721
room_id = re.findall(r'(\d{19})', requests.get(url=self.rid).url)[0]
1822
else:
1923
room_id = self.rid
2024
room_url = 'https://webcast.amemv.com/webcast/reflow/{}'.format(room_id)
21-
response = requests.get(url=room_url).text
25+
response = requests.get(url=room_url, headers= headers).text
2226
rtmp_pull_url = re.search(r'"rtmp_pull_url":"(.*?flv)"', response).group(1)
2327
hls_pull_url = re.search(r'"hls_pull_url":"(.*?m3u8)"', response).group(1)
2428
real_url = [rtmp_pull_url, hls_pull_url]

0 commit comments

Comments
 (0)