diff options
author | Alex <alexta69@gmail.com> | 2023-03-05 11:43:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 11:43:00 +0200 |
commit | f1851bf4aa3b176139183d70841dc7986c02d796 (patch) | |
tree | af0b76527e8430283ccabf22db1862edd13801ac /app/dl_formats.py | |
parent | upgraded yt-dlp (diff) | |
parent | Define the audio formats tuple in python backend (diff) | |
download | metube-f1851bf4aa3b176139183d70841dc7986c02d796.tar.gz metube-f1851bf4aa3b176139183d70841dc7986c02d796.tar.bz2 metube-f1851bf4aa3b176139183d70841dc7986c02d796.zip |
Merge pull request #230 from georgekav2/feature/add_vorbis_opus_wav
Add support for opus and wav
Diffstat (limited to 'app/dl_formats.py')
-rw-r--r-- | app/dl_formats.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/dl_formats.py b/app/dl_formats.py index e2f6591..8de79e9 100644 --- a/app/dl_formats.py +++ b/app/dl_formats.py @@ -1,5 +1,7 @@ import copy +AUDIO_FORMATS = ("m4a", "mp3", "opus", "wav") + def get_format(format: str, quality: str) -> str: """ Returns format for download @@ -23,7 +25,7 @@ def get_format(format: str, quality: str) -> str: # Quality is irrelevant in this case since we skip the download return "bestaudio/best" - if format in ("m4a", "mp3"): + if format in AUDIO_FORMATS: # Audio quality needs to be set post-download, set in opts return "bestaudio/best" @@ -59,17 +61,19 @@ def get_opts(format: str, quality: str, ytdl_opts: dict) -> dict: if "postprocessors" not in opts: opts["postprocessors"] = [] - if format in ("m4a", "mp3"): + if format in AUDIO_FORMATS: opts["postprocessors"].append({ "key": "FFmpegExtractAudio", "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"}) - opts["postprocessors"].append({"key": "EmbedThumbnail"}) + #Audio formats without thumbnail + if format not in ("wav"): + opts["writethumbnail"] = True + opts["postprocessors"].append({"key": "FFmpegThumbnailsConvertor", "format": "jpg", "when": "before_dl"}) + opts["postprocessors"].append({"key": "FFmpegMetadata"}) + opts["postprocessors"].append({"key": "EmbedThumbnail"}) if format == "thumbnail": opts["skip_download"] = True |