|
|
@ -126,6 +126,7 @@ from .extractor import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
from .extractor.openload import PhantomJSwrapper
|
|
|
|
from .extractor.openload import PhantomJSwrapper
|
|
|
|
from .downloader import (
|
|
|
|
from .downloader import (
|
|
|
|
|
|
|
|
FFmpegFD,
|
|
|
|
get_suitable_downloader,
|
|
|
|
get_suitable_downloader,
|
|
|
|
shorten_protocol_name
|
|
|
|
shorten_protocol_name
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -2690,20 +2691,15 @@ class YoutubeDL(object):
|
|
|
|
info_dict['__real_download'] = False
|
|
|
|
info_dict['__real_download'] = False
|
|
|
|
|
|
|
|
|
|
|
|
_protocols = set(determine_protocol(f) for f in requested_formats)
|
|
|
|
_protocols = set(determine_protocol(f) for f in requested_formats)
|
|
|
|
if len(_protocols) == 1:
|
|
|
|
if len(_protocols) == 1: # All requested formats have same protocol
|
|
|
|
info_dict['protocol'] = _protocols.pop()
|
|
|
|
info_dict['protocol'] = _protocols.pop()
|
|
|
|
directly_mergable = (
|
|
|
|
directly_mergable = FFmpegFD.can_merge_formats(info_dict)
|
|
|
|
'no-direct-merge' not in self.params.get('compat_opts', [])
|
|
|
|
if dl_filename is not None:
|
|
|
|
and info_dict.get('protocol') is not None # All requested formats have same protocol
|
|
|
|
pass
|
|
|
|
and not self.params.get('allow_unplayable_formats')
|
|
|
|
elif (directly_mergable and get_suitable_downloader(info_dict, self.params) == FFmpegFD):
|
|
|
|
and get_suitable_downloader(info_dict, self.params).__name__ == 'FFmpegFD')
|
|
|
|
info_dict['url'] = '\n'.join(f['url'] for f in requested_formats)
|
|
|
|
if directly_mergable:
|
|
|
|
success, real_download = self.dl(temp_filename, info_dict)
|
|
|
|
info_dict['url'] = requested_formats[0]['url']
|
|
|
|
info_dict['__real_download'] = real_download
|
|
|
|
# Treat it as a single download
|
|
|
|
|
|
|
|
dl_filename = existing_file(full_filename, temp_filename)
|
|
|
|
|
|
|
|
if dl_filename is None:
|
|
|
|
|
|
|
|
success, real_download = self.dl(temp_filename, info_dict)
|
|
|
|
|
|
|
|
info_dict['__real_download'] = real_download
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
downloaded = []
|
|
|
|
downloaded = []
|
|
|
|
merger = FFmpegMergerPP(self)
|
|
|
|
merger = FFmpegMergerPP(self)
|
|
|
@ -2717,28 +2713,25 @@ class YoutubeDL(object):
|
|
|
|
'You have requested merging of multiple formats but ffmpeg is not installed. '
|
|
|
|
'You have requested merging of multiple formats but ffmpeg is not installed. '
|
|
|
|
'The formats won\'t be merged.')
|
|
|
|
'The formats won\'t be merged.')
|
|
|
|
|
|
|
|
|
|
|
|
if dl_filename is None:
|
|
|
|
for f in requested_formats:
|
|
|
|
for f in requested_formats:
|
|
|
|
new_info = dict(info_dict)
|
|
|
|
new_info = dict(info_dict)
|
|
|
|
del new_info['requested_formats']
|
|
|
|
del new_info['requested_formats']
|
|
|
|
new_info.update(f)
|
|
|
|
new_info.update(f)
|
|
|
|
fname = prepend_extension(temp_filename, 'f%s' % f['format_id'], new_info['ext'])
|
|
|
|
fname = prepend_extension(
|
|
|
|
if not self._ensure_dir_exists(fname):
|
|
|
|
self.prepare_filename(new_info, 'temp'),
|
|
|
|
return
|
|
|
|
'f%s' % f['format_id'], new_info['ext'])
|
|
|
|
downloaded.append(fname)
|
|
|
|
if not self._ensure_dir_exists(fname):
|
|
|
|
partial_success, real_download = self.dl(fname, new_info)
|
|
|
|
return
|
|
|
|
info_dict['__real_download'] = info_dict['__real_download'] or real_download
|
|
|
|
downloaded.append(fname)
|
|
|
|
success = success and partial_success
|
|
|
|
partial_success, real_download = self.dl(fname, new_info)
|
|
|
|
if merger.available and not self.params.get('allow_unplayable_formats'):
|
|
|
|
info_dict['__real_download'] = info_dict['__real_download'] or real_download
|
|
|
|
info_dict['__postprocessors'].append(merger)
|
|
|
|
success = success and partial_success
|
|
|
|
info_dict['__files_to_merge'] = downloaded
|
|
|
|
if merger.available and not self.params.get('allow_unplayable_formats'):
|
|
|
|
# Even if there were no downloads, it is being merged only now
|
|
|
|
info_dict['__postprocessors'].append(merger)
|
|
|
|
info_dict['__real_download'] = True
|
|
|
|
info_dict['__files_to_merge'] = downloaded
|
|
|
|
else:
|
|
|
|
# Even if there were no downloads, it is being merged only now
|
|
|
|
for file in downloaded:
|
|
|
|
info_dict['__real_download'] = True
|
|
|
|
files_to_move[file] = None
|
|
|
|
else:
|
|
|
|
|
|
|
|
for file in downloaded:
|
|
|
|
|
|
|
|
files_to_move[file] = None
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# Just a single file
|
|
|
|
# Just a single file
|
|
|
|
dl_filename = existing_file(full_filename, temp_filename)
|
|
|
|
dl_filename = existing_file(full_filename, temp_filename)
|
|
|
|