[downloader:ytdl] fix file extensions when merging into mkv
This commit is contained in:
@@ -70,6 +70,10 @@ class YoutubeDLDownloader(DownloaderBase):
|
||||
if "url" in info_dict:
|
||||
text.nameext_from_url(info_dict["url"], pathfmt.kwdict)
|
||||
|
||||
formats = info_dict.get("requested_formats")
|
||||
if formats and not compatible_formats(formats):
|
||||
info_dict["ext"] = "mkv"
|
||||
|
||||
if self.outtmpl:
|
||||
self.ytdl.params["outtmpl"] = self.outtmpl
|
||||
pathfmt.filename = filename = self.ytdl.prepare_filename(info_dict)
|
||||
@@ -105,4 +109,15 @@ class YoutubeDLDownloader(DownloaderBase):
|
||||
return True
|
||||
|
||||
|
||||
def compatible_formats(formats):
|
||||
video_ext = formats[0].get("ext")
|
||||
audio_ext = formats[1].get("ext")
|
||||
|
||||
if video_ext == "webm" and audio_ext == "webm":
|
||||
return True
|
||||
|
||||
exts = ("mp3", "mp4", "m4a", "m4p", "m4b", "m4r", "m4v", "ismv", "isma")
|
||||
return video_ext in exts and audio_ext in exts
|
||||
|
||||
|
||||
__downloader__ = YoutubeDLDownloader
|
||||
|
||||
Reference in New Issue
Block a user