From f737fb16d8234408c85bc189ccc926fea000515b Mon Sep 17 00:00:00 2001 From: Chris Caruso Date: Fri, 17 Feb 2023 00:06:15 -0800 Subject: [PATCH] [ExtractAudio] Handle outtmpl without ext (#6005) Authored by: carusocr Closes #5968 --- yt_dlp/__init__.py | 4 ---- yt_dlp/postprocessor/ffmpeg.py | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 255b31735..fb44303a2 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -318,10 +318,6 @@ def validate_outtmpl(tmpl, msg): if outtmpl_default == '': opts.skip_download = None del opts.outtmpl['default'] - if outtmpl_default and not os.path.splitext(outtmpl_default)[1] and opts.extractaudio: - raise ValueError( - 'Cannot download a video and extract audio into the same file! ' - f'Use "{outtmpl_default}.%(ext)s" instead of "{outtmpl_default}" as the output template') def parse_chapters(name, value): chapters, ranges = [], [] diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 5acd75376..123a95a3a 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -508,8 +508,7 @@ def run(self, information): if acodec != 'copy': more_opts = self._quality_args(acodec) - # not os.path.splitext, since the latter does not work on unicode in all setups - temp_path = new_path = f'{path.rpartition(".")[0]}.{extension}' + temp_path = new_path = replace_extension(path, extension, information['ext']) if new_path == path: if acodec == 'copy':