mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
This commit is contained in:
parent
3926c0ea02
commit
6648e007e3
@ -878,13 +878,16 @@ class DummyProgressBar:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_output_filename(urls, title, ext, output_dir, merge):
|
def get_output_filename(urls, title, ext, output_dir, merge, **kwargs):
|
||||||
# lame hack for the --output-filename option
|
# lame hack for the --output-filename option
|
||||||
global output_filename
|
global output_filename
|
||||||
if output_filename:
|
if output_filename:
|
||||||
|
result = output_filename
|
||||||
|
if kwargs.get('part', -1) >= 0:
|
||||||
|
result = '%s[%02d]' % (result, kwargs.get('part'))
|
||||||
if ext:
|
if ext:
|
||||||
return output_filename + '.' + ext
|
result = result + '.' + ext
|
||||||
return output_filename
|
return result
|
||||||
|
|
||||||
merged_ext = ext
|
merged_ext = ext
|
||||||
if (len(urls) > 1) and merge:
|
if (len(urls) > 1) and merge:
|
||||||
@ -964,16 +967,16 @@ def download_urls(
|
|||||||
bar.done()
|
bar.done()
|
||||||
else:
|
else:
|
||||||
parts = []
|
parts = []
|
||||||
print('Downloading %s.%s ...' % (tr(title), ext))
|
print('Downloading %s ...' % tr(output_filename))
|
||||||
bar.update()
|
bar.update()
|
||||||
for i, url in enumerate(urls):
|
for i, url in enumerate(urls):
|
||||||
filename = '%s[%02d].%s' % (title, i, ext)
|
output_filename_i = get_output_filename(urls, title, ext, output_dir, merge, part=i)
|
||||||
filepath = os.path.join(output_dir, filename)
|
output_filepath_i = os.path.join(output_dir, output_filename_i)
|
||||||
parts.append(filepath)
|
parts.append(output_filepath_i)
|
||||||
# print 'Downloading %s [%s/%s]...' % (tr(filename), i + 1, len(urls))
|
# print 'Downloading %s [%s/%s]...' % (tr(filename), i + 1, len(urls))
|
||||||
bar.update_piece(i + 1)
|
bar.update_piece(i + 1)
|
||||||
url_save(
|
url_save(
|
||||||
url, filepath, bar, refer=refer, is_part=True, faker=faker,
|
url, output_filepath_i, bar, refer=refer, is_part=True, faker=faker,
|
||||||
headers=headers, **kwargs
|
headers=headers, **kwargs
|
||||||
)
|
)
|
||||||
bar.done()
|
bar.done()
|
||||||
|
Loading…
Reference in New Issue
Block a user