aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex <alexta69@gmail.com>2021-12-06 20:14:09 +0200
committerGitHub <noreply@github.com>2021-12-06 20:14:09 +0200
commit656827c588d901e8742218b0f8bff8e709452d3f (patch)
tree1b851f8f26a95cdd0638cd93f38b0aa4cb955375
parentupgraded yt-dlp (diff)
parentthumbs (diff)
downloadmetube-656827c588d901e8742218b0f8bff8e709452d3f.tar.gz
metube-656827c588d901e8742218b0f8bff8e709452d3f.tar.bz2
metube-656827c588d901e8742218b0f8bff8e709452d3f.zip
Merge pull request #86 from omeryagmurlu/master
Try downloading metadata/thumbnails for mp3 files automatically
-rw-r--r--app/dl_formats.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/app/dl_formats.py b/app/dl_formats.py
index 4593af3..121ce6b 100644
--- a/app/dl_formats.py
+++ b/app/dl_formats.py
@@ -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
bgstack15