[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,16 +111,25 @@ def universal_download(url, output_dir='.', merge=True, info_only=False, **kwarg
for candy in candies: for candy in candies:
try: try:
mime, ext, size = url_info(candy['url'], faker=True) try:
if not size: size = float('Inf') 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: except:
continue continue
else: else:
print_info(site_info, candy['title'], ext, size) print_info(site_info, candy['title'], ext, size)
if not info_only: if not info_only:
download_urls([candy['url']], candy['title'], ext, size, try:
output_dir=output_dir, merge=merge, download_urls([candy['url']], candy['title'], ext, size,
faker=True) 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)
return return
else: else: