From 91d7d0b333d2fe09121c7328cf519c1b5331adef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Marqui=CC=81nez=20Ferra=CC=81ndiz?= Date: Fri, 3 Jan 2014 12:52:27 +0100 Subject: [PATCH] FFmpegMetadataPP; Write temporary file to `something.temp.{ext}` (fixes #2079) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ffmpeg correctly recognize the formats of extensions like m4a, but it doesn’t works if it’s passed with the `—format` option. --- youtube_dl/PostProcessor.py | 5 ++--- youtube_dl/utils.py | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/youtube_dl/PostProcessor.py b/youtube_dl/PostProcessor.py index 69aedf87a..097e1a9e4 100644 --- a/youtube_dl/PostProcessor.py +++ b/youtube_dl/PostProcessor.py @@ -10,6 +10,7 @@ from .utils import ( PostProcessingError, shell_quote, subtitles_filename, + prepend_extension, ) @@ -496,13 +497,11 @@ class FFmpegMetadataPP(FFmpegPostProcessor): return True, info filename = info['filepath'] - ext = os.path.splitext(filename)[1][1:] - temp_filename = filename + u'.temp' + temp_filename = prepend_extension(filename, 'temp') options = ['-c', 'copy'] for (name, value) in metadata.items(): options.extend(['-metadata', '%s=%s' % (name, value)]) - options.extend(['-f', ext]) self._downloader.to_screen(u'[ffmpeg] Adding metadata to \'%s\'' % filename) self.run_ffmpeg(filename, temp_filename, options) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index da5143c8e..fc10fba63 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1119,3 +1119,8 @@ def parse_duration(s): if m.group('hours'): res += int(m.group('hours')) * 60 * 60 return res + + +def prepend_extension(filename, ext): + name, real_ext = os.path.splitext(filename) + return u'{0}.{1}{2}'.format(name, ext, real_ext)