[douyin] fix if there is not title, you-get cannot works well

https://www.douyin.com/share/video/6553248251821165832
This commit is contained in:
yangxiaochen 2018-05-11 18:08:23 +08:00
parent 50bba5527b
commit daf630e9d7

View File

@ -21,7 +21,13 @@ def douyin_download_by_url(url, **kwargs):
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']
# fix: https://www.douyin.com/share/video/6553248251821165832
# if there is no title, use desc
cha_list = video_info['cha_list']
if cha_list:
title = cha_list[0]['cha_name']
else:
title = video_info['desc']
video_format = 'mp4'
size = url_size(video_url, faker=True)
print_info(