aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasuyou <asuyou@users.noreply.github.com>2021-11-14 23:17:07 +0000
committerasuyou <asuyou@users.noreply.github.com>2021-11-14 23:17:07 +0000
commiteadf8239e968d3ffd2e1da344ba9d8bc8fd78a1c (patch)
tree21f6b4c9373866465310f976fe46b0bc37323d71
parentFixed "any" format to act like original (diff)
downloadmetube-eadf8239e968d3ffd2e1da344ba9d8bc8fd78a1c.tar.gz
metube-eadf8239e968d3ffd2e1da344ba9d8bc8fd78a1c.tar.bz2
metube-eadf8239e968d3ffd2e1da344ba9d8bc8fd78a1c.zip
Changed to "any" to work like original (backend)
-rw-r--r--app/dl_formats.py17
1 files 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:
bgstack15