Merge pull request #86 from omeryagmurlu/master

Try downloading metadata/thumbnails for mp3 files automatically
This commit is contained in:
Alex 2021-12-06 20:14:09 +02:00 committed by GitHub
commit 656827c588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -1,3 +1,5 @@
import copy
def get_format(format: str, quality: str) -> str:
"""
Returns format for download
@ -48,15 +50,22 @@ def get_opts(format: str, quality: str, ytdl_opts: dict) -> dict:
Returns:
ytdl_opts: Extra options
"""
if "postprocessors" not in ytdl_opts:
ytdl_opts["postprocessors"] = []
opts = copy.deepcopy(ytdl_opts)
if "postprocessors" not in opts:
opts["postprocessors"] = []
if format == "mp3":
extra_args = {}
if quality != "best":
extra_args = {"preferredquality": quality}
ytdl_opts["postprocessors"].append(
opts["postprocessors"].append(
{"key": "FFmpegExtractAudio", "preferredcodec": "mp3", **extra_args},
)
return ytdl_opts
opts["writethumbnail"] = True
opts["postprocessors"].append({"key": "FFmpegMetadata"})
opts["postprocessors"].append({"key": "EmbedThumbnail"})
return opts