Slight hack: allow pre-given filenames in threaded_dl.
This commit is contained in:
parent
0c481f454f
commit
9e65971829
1 changed files with 22 additions and 10 deletions
|
@ -12,6 +12,10 @@ from voussoirkit import downloady
|
||||||
|
|
||||||
def clean_url_list(urls):
|
def clean_url_list(urls):
|
||||||
for url in urls:
|
for url in urls:
|
||||||
|
if isinstance(url, (tuple, list)):
|
||||||
|
(url, filename) = url
|
||||||
|
else:
|
||||||
|
filename = None
|
||||||
url = url.strip()
|
url = url.strip()
|
||||||
|
|
||||||
if not url:
|
if not url:
|
||||||
|
@ -20,6 +24,9 @@ def clean_url_list(urls):
|
||||||
if url.startswith('#'):
|
if url.startswith('#'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if filename:
|
||||||
|
yield (url, filename)
|
||||||
|
else:
|
||||||
yield url
|
yield url
|
||||||
|
|
||||||
def download_thread(url, filename, *, bytespersecond=None, headers=None, timeout=None):
|
def download_thread(url, filename, *, bytespersecond=None, headers=None, timeout=None):
|
||||||
|
@ -61,6 +68,9 @@ def threaded_dl(
|
||||||
threads = remove_finished(threads)
|
threads = remove_finished(threads)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
if isinstance(url, (tuple, list)):
|
||||||
|
(url, filename) = url
|
||||||
|
else:
|
||||||
basename = downloady.basename_from_url(url)
|
basename = downloady.basename_from_url(url)
|
||||||
extension = os.path.splitext(basename)[1]
|
extension = os.path.splitext(basename)[1]
|
||||||
filename = filename_format.format(
|
filename = filename_format.format(
|
||||||
|
@ -100,6 +110,8 @@ def threaded_dl_argparse(args):
|
||||||
urls = clipext.resolve(args.url_file)
|
urls = clipext.resolve(args.url_file)
|
||||||
urls = urls.replace('\r', '').split('\n')
|
urls = urls.replace('\r', '').split('\n')
|
||||||
|
|
||||||
|
urls = [u.split(' ', 1) if ' ' in u else u for u in urls]
|
||||||
|
|
||||||
headers = args.headers
|
headers = args.headers
|
||||||
if headers is not None:
|
if headers is not None:
|
||||||
if len(headers) == 1 and headers[0].startswith('{'):
|
if len(headers) == 1 and headers[0].startswith('{'):
|
||||||
|
|
Loading…
Reference in a new issue