diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-02-01 06:18:25 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-02-01 06:26:01 +0530 |
commit | 6a0546e313fbd7f731c6c99e23d2f2be4b0cf588 (patch) | |
tree | 626158ab8e75e8a4e4f1f92968f925b84ec79ead | |
parent | dbcea0585f2fef39b394fe0a9654a77cc5774f33 (diff) | |
download | hypervideo-pre-6a0546e313fbd7f731c6c99e23d2f2be4b0cf588.tar.lz hypervideo-pre-6a0546e313fbd7f731c6c99e23d2f2be4b0cf588.tar.xz hypervideo-pre-6a0546e313fbd7f731c6c99e23d2f2be4b0cf588.zip |
[outtmpl] Handle hard-coded file extension better
When we know that the user-provided extension is the correct final one,
replace it with intermediate extension during download
-rw-r--r-- | yt_dlp/YoutubeDL.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 24843c775..e31edf50a 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -1222,10 +1222,17 @@ class YoutubeDL(object): try: outtmpl = self._outtmpl_expandpath(self.outtmpl_dict.get(tmpl_type, self.outtmpl_dict['default'])) filename = self.evaluate_outtmpl(outtmpl, info_dict, True) + if not filename: + return None - force_ext = OUTTMPL_TYPES.get(tmpl_type) - if filename and force_ext is not None: - filename = replace_extension(filename, force_ext, info_dict.get('ext')) + if tmpl_type in ('default', 'temp'): + final_ext, ext = self.params.get('final_ext'), info_dict.get('ext') + if final_ext and ext and final_ext != ext and filename.endswith(f'.{final_ext}'): + filename = replace_extension(filename, ext, final_ext) + else: + force_ext = OUTTMPL_TYPES[tmpl_type] + if force_ext: + filename = replace_extension(filename, force_ext, info_dict.get('ext')) # https://github.com/blackjack4494/youtube-dlc/issues/85 trim_file_name = self.params.get('trim_file_name', False) |