mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 13:46:53 +01:00
[YoutubeDL] Ensure dir existence for each requested format (closes #14116)
This commit is contained in:
parent
880fa66f4f
commit
c5c9bf0c12
@ -1710,12 +1710,17 @@ def process_info(self, info_dict):
|
|||||||
if filename is None:
|
if filename is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
def ensure_dir_exists(path):
|
||||||
dn = os.path.dirname(sanitize_path(encodeFilename(filename)))
|
try:
|
||||||
if dn and not os.path.exists(dn):
|
dn = os.path.dirname(path)
|
||||||
os.makedirs(dn)
|
if dn and not os.path.exists(dn):
|
||||||
except (OSError, IOError) as err:
|
os.makedirs(dn)
|
||||||
self.report_error('unable to create directory ' + error_to_compat_str(err))
|
return True
|
||||||
|
except (OSError, IOError) as err:
|
||||||
|
self.report_error('unable to create directory ' + error_to_compat_str(err))
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not ensure_dir_exists(sanitize_path(encodeFilename(filename))):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.params.get('writedescription', False):
|
if self.params.get('writedescription', False):
|
||||||
@ -1853,8 +1858,11 @@ def compatible_formats(formats):
|
|||||||
for f in requested_formats:
|
for f in requested_formats:
|
||||||
new_info = dict(info_dict)
|
new_info = dict(info_dict)
|
||||||
new_info.update(f)
|
new_info.update(f)
|
||||||
fname = self.prepare_filename(new_info)
|
fname = prepend_extension(
|
||||||
fname = prepend_extension(fname, 'f%s' % f['format_id'], new_info['ext'])
|
self.prepare_filename(new_info),
|
||||||
|
'f%s' % f['format_id'], new_info['ext'])
|
||||||
|
if not ensure_dir_exists(fname):
|
||||||
|
return
|
||||||
downloaded.append(fname)
|
downloaded.append(fname)
|
||||||
partial_success = dl(fname, new_info)
|
partial_success = dl(fname, new_info)
|
||||||
success = success and partial_success
|
success = success and partial_success
|
||||||
|
Loading…
Reference in New Issue
Block a user