From 3a8aed1741428d718a258e2d70e544fdaba8a2bf Mon Sep 17 00:00:00 2001 From: BassThatHertz Date: Sat, 25 Jul 2020 16:16:44 +0100 Subject: [PATCH] Fix for #6724 (error when specifying mp3 extension for output filename) --- youtube_dl/YoutubeDL.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 19370f62b..2d769415e 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -710,6 +710,15 @@ class YoutubeDL(object): # title "Hello $PATH", we don't want `$PATH` to be expanded. filename = expand_path(outtmpl).replace(sep, '') % template_dict + # Fix for 'ERROR: Stream #1:0 -> #0:1 (copy)' when specifying an output filename with the extension '.mp3' + # (Mentioned in https://github.com/ytdl-org/youtube-dl/pull/25717#issuecomment-658729806) + prefix, dot, ext = filename.rpartition('.') + if ext == 'mp3': + prefix = prefix.replace('../', '').replace('..\\', '') + filename = prefix + '.mka' + self.to_screen('The Matroska container (.mka) will be used for the download, ' + 'but the final file will have the .mp3 extension') + # Temporary fix for #4787 # 'Treat' all problem characters by passing filename through preferredencoding # to workaround encoding issues with subprocess on python2 @ Windows