[douyin] send the request without fake headers, the douyin website will return fake body or the 403 response!

This commit is contained in:
yangxiaochen 2018-05-11 17:12:01 +08:00
parent 351173ba79
commit 50bba5527b

View File

@ -7,6 +7,7 @@ from ..common import (
url_size, url_size,
print_info, print_info,
get_content, get_content,
fake_headers,
download_urls, download_urls,
playlist_not_supported, playlist_not_supported,
) )
@ -16,13 +17,13 @@ __all__ = ['douyin_download_by_url']
def douyin_download_by_url(url, **kwargs): 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 = \[(.*?)\];') match_rule = re.compile(r'var data = \[(.*?)\];')
video_info = json.loads(match_rule.findall(page_content)[0]) video_info = json.loads(match_rule.findall(page_content)[0])
video_url = video_info['video']['play_addr']['url_list'][0] video_url = video_info['video']['play_addr']['url_list'][0]
title = video_info['cha_list'][0]['cha_name'] title = video_info['cha_list'][0]['cha_name']
video_format = 'mp4' video_format = 'mp4'
size = url_size(video_url) size = url_size(video_url, faker=True)
print_info( print_info(
site_info='douyin.com', title=title, site_info='douyin.com', title=title,
type=video_format, size=size type=video_format, size=size
@ -30,6 +31,7 @@ def douyin_download_by_url(url, **kwargs):
if not kwargs['info_only']: if not kwargs['info_only']:
download_urls( download_urls(
urls=[video_url], title=title, ext=video_format, total_size=size, urls=[video_url], title=title, ext=video_format, total_size=size,
faker=True,
**kwargs **kwargs
) )