From 50bba5527b52121a1f41b75d763a38fe2432e73e Mon Sep 17 00:00:00 2001 From: yangxiaochen Date: Fri, 11 May 2018 17:12:01 +0800 Subject: [PATCH] [douyin] send the request without fake headers, the douyin website will return fake body or the 403 response! --- src/you_get/extractors/douyin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/you_get/extractors/douyin.py b/src/you_get/extractors/douyin.py index 213837e7..20ce0e26 100644 --- a/src/you_get/extractors/douyin.py +++ b/src/you_get/extractors/douyin.py @@ -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 )