From 51a1a1e318f4bfd463cb241d8c49346c6cad8e89 Mon Sep 17 00:00:00 2001 From: MaxwellGoblin Date: Wed, 13 Sep 2017 15:00:58 +0800 Subject: [PATCH] [qq] fix regression by 4c116c6; add guard for bad json --- src/you_get/extractors/qq.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/you_get/extractors/qq.py b/src/you_get/extractors/qq.py index 8979b4aa..8ef18b08 100644 --- a/src/you_get/extractors/qq.py +++ b/src/you_get/extractors/qq.py @@ -34,7 +34,10 @@ def qq_download_by_vid(vid, title, output_dir='.', merge=True, info_only=False): part_info = get_content(key_api) key_json = json.loads(match1(part_info, r'QZOutputJson=(.*)')[:-1]) if key_json.get('key') is None: - log.w(key_json['msg']) + if part == 1: + log.wtf(key_json['msg']) + else: + log.w(key_json['msg']) break vkey = key_json['key'] url = '{}{}?vkey={}'.format(host, filename, vkey) @@ -135,7 +138,9 @@ def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs): else: 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 = 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''%vid) title = match1(content, r'title">([^"]+)

') if not title else title title = match1(content, r'"title":"([^"]+)"') if not title else title