[universal] use faker only if necessary

This commit is contained in:
Mort Yao 2018-04-25 22:59:39 +02:00
parent fe34688d07
commit bcc98c5a5c
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -111,6 +111,10 @@ def universal_download(url, output_dir='.', merge=True, info_only=False, **kwarg
for candy in candies:
try:
try:
mime, ext, size = url_info(candy['url'], faker=False)
assert size
except:
mime, ext, size = url_info(candy['url'], faker=True)
if not size: size = float('Inf')
except:
@ -118,6 +122,11 @@ def universal_download(url, output_dir='.', merge=True, info_only=False, **kwarg
else:
print_info(site_info, candy['title'], ext, size)
if not info_only:
try:
download_urls([candy['url']], candy['title'], ext, size,
output_dir=output_dir, merge=merge,
faker=False)
except:
download_urls([candy['url']], candy['title'], ext, size,
output_dir=output_dir, merge=merge,
faker=True)