mirror of
https://github.com/soimort/you-get.git
synced 2025-01-24 05:55:02 +03:00
[qq] fix regression by 4c116c6; add guard for bad json
This commit is contained in:
parent
2a250cbcb4
commit
51a1a1e318
@ -34,6 +34,9 @@ def qq_download_by_vid(vid, title, output_dir='.', merge=True, info_only=False):
|
|||||||
part_info = get_content(key_api)
|
part_info = get_content(key_api)
|
||||||
key_json = json.loads(match1(part_info, r'QZOutputJson=(.*)')[:-1])
|
key_json = json.loads(match1(part_info, r'QZOutputJson=(.*)')[:-1])
|
||||||
if key_json.get('key') is None:
|
if key_json.get('key') is None:
|
||||||
|
if part == 1:
|
||||||
|
log.wtf(key_json['msg'])
|
||||||
|
else:
|
||||||
log.w(key_json['msg'])
|
log.w(key_json['msg'])
|
||||||
break
|
break
|
||||||
vkey = key_json['key']
|
vkey = key_json['key']
|
||||||
@ -135,7 +138,9 @@ def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
|||||||
else:
|
else:
|
||||||
content = get_content(url)
|
content = get_content(url)
|
||||||
vid = parse_qs(urlparse(url).query).get('vid') #for links specified vid like http://v.qq.com/cover/p/ps6mnfqyrfo7es3.html?vid=q0181hpdvo5
|
vid = parse_qs(urlparse(url).query).get('vid') #for links specified vid like http://v.qq.com/cover/p/ps6mnfqyrfo7es3.html?vid=q0181hpdvo5
|
||||||
vid = vid[0] if vid else match1(content, r'v?id"*\s*:\s*"\s*([^"]+)"') #general fallback
|
vid = vid[0] if vid else match1(content, r'vid"*\s*:\s*"\s*([^"]+)"') #general fallback
|
||||||
|
if vid is None:
|
||||||
|
vid = match1(content, r'id"*\s*:\s*"(.+?)"')
|
||||||
title = match1(content,r'<a.*?id\s*=\s*"%s".*?title\s*=\s*"(.+?)".*?>'%vid)
|
title = match1(content,r'<a.*?id\s*=\s*"%s".*?title\s*=\s*"(.+?)".*?>'%vid)
|
||||||
title = match1(content, r'title">([^"]+)</p>') if not title else title
|
title = match1(content, r'title">([^"]+)</p>') if not title else title
|
||||||
title = match1(content, r'"title":"([^"]+)"') if not title else title
|
title = match1(content, r'"title":"([^"]+)"') if not title else title
|
||||||
|
Loading…
Reference in New Issue
Block a user