-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking change no allowing saving output with no extension #32838
Comments
Thanks for finding this, which follows from a difference in the way the back-ported mitigation is applied because of slightly different core processing. Specifically, in yt-dlp the expected extension is maintained while downloading to-be-merged streams but discarded on merging, so the mitigation sees A patch is being prepared to allow the problem command to run without work-arounds. However, the previous and patched behaviour both result in a file with If you want a file named just If this had been more carefully designed many years ago, the program might have respected an output template with no extension even when merging but I don't think we can change the behaviour now. |
Also, yt-dlp (2024.07.02) behaves the same wrt |
Patch as mentioned: --- old/youtube-dl/youtube_dl/YoutubeDL.py
+++ new/youtube-dl/youtube_dl/YoutubeDL.py
@@ -139,8 +139,8 @@
except _UnsafeExtensionError as error:
self.report_error(
'{0} found; to avoid damaging your system, this value is disallowed.'
- ' If you believe this is an error{1}').format(
- error.message, bug_reports_message(','))
+ ' If you believe this is an error{1}'.format(
+ error_to_compat_str(error), bug_reports_message(',')))
return wrapper
@@ -2114,18 +2114,26 @@
# TODO: Check acodec/vcodec
return False
- filename_real_ext = os.path.splitext(filename)[1][1:]
- filename_wo_ext = (
- os.path.splitext(filename)[0]
- if filename_real_ext == info_dict['ext']
- else filename)
+ exts = [info_dict['ext']]
requested_formats = info_dict['requested_formats']
if self.params.get('merge_output_format') is None and not compatible_formats(requested_formats):
info_dict['ext'] = 'mkv'
self.report_warning(
'Requested formats are incompatible for merge and will be merged into mkv.')
+ exts.append(info_dict['ext'])
+
# Ensure filename always has a correct extension for successful merge
- filename = '%s.%s' % (filename_wo_ext, info_dict['ext'])
+ def correct_ext(filename, ext=exts[1]):
+ if filename == '-':
+ return filename
+ f_name, f_real_ext = os.path.splitext(filename)
+ f_real_ext = f_real_ext[1:]
+ filename_wo_ext = f_name if f_real_ext in exts else filename
+ if ext is None:
+ ext = f_real_ext or None
+ return join_nonempty(filename_wo_ext, ext, delim='.')
+
+ filename = correct_ext(filename)
if os.path.exists(encodeFilename(filename)):
self.to_screen(
'[download] %s has already been downloaded and '
@@ -2135,8 +2143,9 @@
new_info = dict(info_dict)
new_info.update(f)
fname = prepend_extension(
- self.prepare_filename(new_info),
- 'f%s' % f['format_id'], new_info['ext'])
+ correct_ext(
+ self.prepare_filename(new_info), new_info['ext']),
+ 'f%s' % (f['format_id'],), new_info['ext'])
if not ensure_dir_exists(fname):
return
downloaded.append(fname) |
I am running master (e.g commit 37cea84) due to #31530, in google colab
Code to recreate:
youtube-dl "https://www.youtube.com/watch?v=OziXYniB5x4" --merge-output-format mp4 -o /content/video
Due to #32830 this results in
You may also notice that the error message is confusing and seems to be malformatted.
Verbose log:
Description:
Saving a video file without an extension is a practice which may be used for having a format-agnostic filename. This change breaks multiple scripts with this behavior. Please consider reverting the behavior to allow saving without file extension.
In my case I had to fix ~15 colabs. While there are easy fixes as
--exec
or--no-check-extensions
or just doingmv
after download, this issue addresses the breaking change aspect. Please consider whether specifically the extensionless case constitutes a security risk which justifies the breaking change.The text was updated successfully, but these errors were encountered: