From 821451b301e9e64678e03022cd4c53fc744c948f Mon Sep 17 00:00:00 2001 From: georgekav2 <> Date: Mon, 13 Jun 2022 02:07:48 +0200 Subject: Add M4A backend support. --- app/dl_formats.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/dl_formats.py') diff --git a/app/dl_formats.py b/app/dl_formats.py index 5936b35..e2f6591 100644 --- a/app/dl_formats.py +++ b/app/dl_formats.py @@ -23,14 +23,13 @@ def get_format(format: str, quality: str) -> str: # Quality is irrelevant in this case since we skip the download return "bestaudio/best" - if format == "mp3": + if format in ("m4a", "mp3"): # Audio quality needs to be set post-download, set in opts return "bestaudio/best" if format in ("mp4", "any"): if quality == "audio": return "bestaudio/best" - # video {res} {vfmt} + audio {afmt} {res} {vfmt} vfmt, afmt = ("[ext=mp4]", "[ext=m4a]") if format == "mp4" else ("", "") vres = f"[height<={quality}]" if quality != "best" else "" @@ -60,12 +59,13 @@ def get_opts(format: str, quality: str, ytdl_opts: dict) -> dict: if "postprocessors" not in opts: opts["postprocessors"] = [] - if format == "mp3": + if format in ("m4a", "mp3"): opts["postprocessors"].append({ "key": "FFmpegExtractAudio", - "preferredcodec": "mp3", + "preferredcodec": format, "preferredquality": 0 if quality == "best" else quality, }) + opts["writethumbnail"] = True opts["postprocessors"].append({"key": "FFmpegThumbnailsConvertor", "format": "jpg", "when": "before_dl"}) opts["postprocessors"].append({"key": "FFmpegMetadata"}) -- cgit