From eadf8239e968d3ffd2e1da344ba9d8bc8fd78a1c Mon Sep 17 00:00:00 2001 From: asuyou Date: Sun, 14 Nov 2021 23:17:07 +0000 Subject: Changed to "any" to work like original (backend) --- app/dl_formats.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/dl_formats.py b/app/dl_formats.py index 84be68e..b47ae5c 100644 --- a/app/dl_formats.py +++ b/app/dl_formats.py @@ -60,7 +60,7 @@ def _get_audio_fmt(quality: str) -> str: def _get_video_res(quality: str) -> str: - if quality == "best": + if quality in ("best", "audio"): video_fmt = "" elif quality in ("1440", "1080", "720", "480"): video_fmt = f"[height<={quality}]" @@ -73,12 +73,17 @@ def _get_video_res(quality: str) -> str: def _get_final_fmt(format: str, quality: str) -> str: vfmt, afmt, vres = "", "", "" - if format == "mp4": + if format in ("mp4", "any"): # video {res} {vfmt} + audio {afmt} {res} {vfmt} - vfmt, afmt = "[ext=mp4]", "[ext=m4a]" - vres = _get_video_res(quality) - combo = vres + vfmt - final_fmt = f"bestvideo{combo}+bestaudio{afmt}/best{combo}" + if format == "mp4": + vfmt, afmt = "[ext=mp4]", "[ext=m4a]" + + if quality == "audio": + final_fmt = "bestaudio/best" + else: + vres = _get_video_res(quality) + combo = vres + vfmt + final_fmt = f"bestvideo{combo}+bestaudio{afmt}/best{combo}" elif format == "mp3": final_fmt = _get_audio_fmt(quality) else: -- cgit