From 3a8aed1741428d718a258e2d70e544fdaba8a2bf Mon Sep 17 00:00:00 2001 From: BassThatHertz Date: Sat, 25 Jul 2020 16:16:44 +0100 Subject: [PATCH 1/5] 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 From 799938536f57afcfa60208147d9ae1e679c656f5 Mon Sep 17 00:00:00 2001 From: BassThatHertz Date: Sat, 25 Jul 2020 16:28:35 +0100 Subject: [PATCH 2/5] Fix indentation length. --- youtube_dl/YoutubeDL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 2d769415e..b87ad4edd 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -717,7 +717,7 @@ class YoutubeDL(object): 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') + 'but the final file will have the .mp3 extension') # Temporary fix for #4787 # 'Treat' all problem characters by passing filename through preferredencoding From dbf4af5244e9cd7ad08361e01641d2a11be54f0a Mon Sep 17 00:00:00 2001 From: BassThatHertz Date: Sat, 25 Jul 2020 19:17:57 +0100 Subject: [PATCH 3/5] Make the fix for #6724 apply to all audio formats. --- youtube_dl/YoutubeDL.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index b87ad4edd..e98985e24 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -710,14 +710,13 @@ 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) + # Fix for #6724 (https://github.com/ytdl-org/youtube-dl/issues/6724) 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') + 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 .%s extension' % (ext)) # Temporary fix for #4787 # 'Treat' all problem characters by passing filename through preferredencoding @@ -2076,7 +2075,7 @@ class YoutubeDL(object): self.report_error(e.msg) if files_to_delete and not self.params.get('keepvideo', False): for old_filename in files_to_delete: - self.to_screen('Deleting original file %s (pass -k to keep)' % old_filename) + self.to_screen('Deleting original file: %s (pass -k to keep)' % old_filename) try: os.remove(encodeFilename(old_filename)) except (IOError, OSError): From 10a9f184c0dfacda18fb8b38ca7ccfcca4607c1c Mon Sep 17 00:00:00 2001 From: BassThatHertz Date: Sun, 26 Jul 2020 02:08:16 +0100 Subject: [PATCH 4/5] Only use the Matroska container if an audio extension is specified. --- .travis.yml | 50 ----------------------------------------- youtube_dl/YoutubeDL.py | 15 ++++++++----- 2 files changed, 9 insertions(+), 56 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 51afd469a..000000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: python -python: - - "2.6" - - "2.7" - - "3.2" - - "3.3" - - "3.4" - - "3.5" - - "3.6" - - "pypy" - - "pypy3" -dist: trusty -env: - - YTDL_TEST_SET=core - - YTDL_TEST_SET=download -jobs: - include: - - python: 3.7 - dist: xenial - env: YTDL_TEST_SET=core - - python: 3.7 - dist: xenial - env: YTDL_TEST_SET=download - - python: 3.8 - dist: xenial - env: YTDL_TEST_SET=core - - python: 3.8 - dist: xenial - env: YTDL_TEST_SET=download - - python: 3.8-dev - dist: xenial - env: YTDL_TEST_SET=core - - python: 3.8-dev - dist: xenial - env: YTDL_TEST_SET=download - - env: JYTHON=true; YTDL_TEST_SET=core - - env: JYTHON=true; YTDL_TEST_SET=download - - name: flake8 - python: 3.8 - dist: xenial - install: pip install flake8 - script: flake8 . - fast_finish: true - allow_failures: - - env: YTDL_TEST_SET=download - - env: JYTHON=true; YTDL_TEST_SET=core - - env: JYTHON=true; YTDL_TEST_SET=download -before_install: - - if [ "$JYTHON" == "true" ]; then ./devscripts/install_jython.sh; export PATH="$HOME/jython/bin:$PATH"; fi -script: ./devscripts/run_tests.sh diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index e98985e24..f85838da3 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -710,13 +710,16 @@ class YoutubeDL(object): # title "Hello $PATH", we don't want `$PATH` to be expanded. filename = expand_path(outtmpl).replace(sep, '') % template_dict - # Fix for #6724 (https://github.com/ytdl-org/youtube-dl/issues/6724) + # Fixes the issue of the audio not being converted to the desired format when using --audio-format and + # specifying an audio extension with -o, e.g. --audio-format mp3 -o test.mp3 prefix, dot, ext = filename.rpartition('.') - 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 .%s extension' % (ext)) + audio_extensions = ['mp3', 'm4a', 'aac' 'opus', 'ogg', 'wav', 'flac'] + if ext in audio_extensions: + prefix = prefix.replace('../', '').replace('..\\', '') + filename = prefix + '.mka' + self.to_screen( + '[download] The Matroska container (.mka) will be used for the download, ' + 'but the final file will have the .%s extension' % (ext)) # Temporary fix for #4787 # 'Treat' all problem characters by passing filename through preferredencoding From 00897f32f884c116a38bd6d1b697ed2d655f8923 Mon Sep 17 00:00:00 2001 From: BassThatHertz Date: Sun, 26 Jul 2020 02:16:58 +0100 Subject: [PATCH 5/5] Re-created .travis.yml which was accidently deleted. --- .travis.yml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..51afd469a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,50 @@ +language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + - "3.6" + - "pypy" + - "pypy3" +dist: trusty +env: + - YTDL_TEST_SET=core + - YTDL_TEST_SET=download +jobs: + include: + - python: 3.7 + dist: xenial + env: YTDL_TEST_SET=core + - python: 3.7 + dist: xenial + env: YTDL_TEST_SET=download + - python: 3.8 + dist: xenial + env: YTDL_TEST_SET=core + - python: 3.8 + dist: xenial + env: YTDL_TEST_SET=download + - python: 3.8-dev + dist: xenial + env: YTDL_TEST_SET=core + - python: 3.8-dev + dist: xenial + env: YTDL_TEST_SET=download + - env: JYTHON=true; YTDL_TEST_SET=core + - env: JYTHON=true; YTDL_TEST_SET=download + - name: flake8 + python: 3.8 + dist: xenial + install: pip install flake8 + script: flake8 . + fast_finish: true + allow_failures: + - env: YTDL_TEST_SET=download + - env: JYTHON=true; YTDL_TEST_SET=core + - env: JYTHON=true; YTDL_TEST_SET=download +before_install: + - if [ "$JYTHON" == "true" ]; then ./devscripts/install_jython.sh; export PATH="$HOME/jython/bin:$PATH"; fi +script: ./devscripts/run_tests.sh