aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/YoutubeDL.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-05-02 22:52:21 +0600
committerSergey M․ <dstftw@gmail.com>2015-05-02 22:52:21 +0600
commit38c6902b9051fa7e1dbda79808a90dbf2aac37ca (patch)
tree2ad46b8cd936cafe12f89728334c9326e439d6df /youtube_dl/YoutubeDL.py
parent2ddcd88129e633ead8c5faee6c930b66dddb1b32 (diff)
downloadyoutube-dl-38c6902b9051fa7e1dbda79808a90dbf2aac37ca.tar.xz
[YoutubeDL] Ensure correct extension is always present for a merged file (Closes #5535)
Diffstat (limited to 'youtube_dl/YoutubeDL.py')
-rwxr-xr-xyoutube_dl/YoutubeDL.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 55b429f31..eaa436bf9 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -1382,11 +1382,18 @@ class YoutubeDL(object):
# TODO: Check acodec/vcodec
return False
+ filename_real_ext = os.path.splitext(filename)[1][1:]
+ filename_wo_ext = (
+ os.path.splitext(filename)[0]
+ if filename_real_ext == info_dict['ext']
+ else filename)
requested_formats = info_dict['requested_formats']
if self.params.get('merge_output_format') is None and not compatible_formats(requested_formats):
- filename = os.path.splitext(filename)[0] + '.mkv'
+ info_dict['ext'] = 'mkv'
self.report_warning('You have requested formats incompatible for merge. '
'The formats will be merged into mkv')
+ # Ensure filename always has a correct extension for successful merge
+ filename = '%s.%s' % (filename_wo_ext, info_dict['ext'])
if os.path.exists(encodeFilename(filename)):
self.to_screen(
'[download] %s has already been downloaded and '