From 69e6e490f4a27bf3cc62019e5807135847889973 Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Tue, 21 Sep 2021 05:12:33 +0200 Subject: [PATCH] Optionally embed metadata into video files (#21) This adds basic `postprocessors` support and adds a setting to optionally enable `FFmpegMetadata`. It's the same as passing `--add-metadata` and `--add-chapters` via the `yt-dlp` CLI. --- tubearchivist/home/config.json | 5 +++-- tubearchivist/home/src/download.py | 13 +++++++++++++ tubearchivist/home/templates/home/settings.html | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/config.json b/tubearchivist/home/config.json index 97c6ea7..8b4bb3b 100644 --- a/tubearchivist/home/config.json +++ b/tubearchivist/home/config.json @@ -14,7 +14,8 @@ "limit_count": 5, "limit_speed": false, "sleep_interval": 3, - "format": false + "format": false, + "add_metadata": false }, "application": { "cache_dir": "/cache", @@ -22,4 +23,4 @@ "file_template": "%(id)s_%(title)s.mp4", "colors": "dark" } -} \ No newline at end of file +} diff --git a/tubearchivist/home/src/download.py b/tubearchivist/home/src/download.py index 0387953..f035f94 100644 --- a/tubearchivist/home/src/download.py +++ b/tubearchivist/home/src/download.py @@ -454,6 +454,19 @@ class VideoDownloader: external = False if external: obs['external_downloader'] = 'aria2c' + + + postprocessors = [] + + if self.config['downloads']['add_metadata']: + postprocessors.append({ + 'key': 'FFmpegMetadata', + 'add_chapters': True, + 'add_metadata': True, + }) + + obs['postprocessors'] = postprocessors + # check if already in cache to continue from there cache_dir = self.config['application']['cache_dir'] all_cached = os.listdir(cache_dir + '/download/') diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html index 8199656..243cf4a 100644 --- a/tubearchivist/home/templates/home/settings.html +++ b/tubearchivist/home/templates/home/settings.html @@ -106,6 +106,15 @@
+
+

Current metadata embed setting: {{ config.downloads.add_metadata }}

+ Metadata is not embedded into the downloaded files by default.
+ +