mirror of
https://github.com/soimort/you-get.git
synced 2025-01-24 05:55:02 +03:00
[douyin] send the request without fake headers, the douyin website will return fake body or the 403 response!
This commit is contained in:
parent
351173ba79
commit
50bba5527b
@ -7,6 +7,7 @@ from ..common import (
|
||||
url_size,
|
||||
print_info,
|
||||
get_content,
|
||||
fake_headers,
|
||||
download_urls,
|
||||
playlist_not_supported,
|
||||
)
|
||||
@ -16,13 +17,13 @@ __all__ = ['douyin_download_by_url']
|
||||
|
||||
|
||||
def douyin_download_by_url(url, **kwargs):
|
||||
page_content = get_content(url)
|
||||
page_content = get_content(url, headers=fake_headers)
|
||||
match_rule = re.compile(r'var data = \[(.*?)\];')
|
||||
video_info = json.loads(match_rule.findall(page_content)[0])
|
||||
video_url = video_info['video']['play_addr']['url_list'][0]
|
||||
title = video_info['cha_list'][0]['cha_name']
|
||||
video_format = 'mp4'
|
||||
size = url_size(video_url)
|
||||
size = url_size(video_url, faker=True)
|
||||
print_info(
|
||||
site_info='douyin.com', title=title,
|
||||
type=video_format, size=size
|
||||
@ -30,6 +31,7 @@ def douyin_download_by_url(url, **kwargs):
|
||||
if not kwargs['info_only']:
|
||||
download_urls(
|
||||
urls=[video_url], title=title, ext=video_format, total_size=size,
|
||||
faker=True,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user