mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-10 15:14:57 +00:00
[YoutubeDL] Ensure correct extension is always present for a merged file (Closes #5535)
This commit is contained in:
parent
2ddcd88129
commit
38c6902b90
1 changed files with 8 additions and 1 deletions
|
@ -1382,11 +1382,18 @@ class YoutubeDL(object):
|
||||||
# TODO: Check acodec/vcodec
|
# TODO: Check acodec/vcodec
|
||||||
return False
|
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']
|
requested_formats = info_dict['requested_formats']
|
||||||
if self.params.get('merge_output_format') is None and not compatible_formats(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. '
|
self.report_warning('You have requested formats incompatible for merge. '
|
||||||
'The formats will be merged into mkv')
|
'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)):
|
if os.path.exists(encodeFilename(filename)):
|
||||||
self.to_screen(
|
self.to_screen(
|
||||||
'[download] %s has already been downloaded and '
|
'[download] %s has already been downloaded and '
|
||||||
|
|
Loading…
Reference in a new issue