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.
This commit is contained in:
Daniel Kempkens 2021-09-21 05:12:33 +02:00 committed by GitHub
parent 1c3ca8364c
commit 69e6e490f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View File

@ -14,7 +14,8 @@
"limit_count": 5, "limit_count": 5,
"limit_speed": false, "limit_speed": false,
"sleep_interval": 3, "sleep_interval": 3,
"format": false "format": false,
"add_metadata": false
}, },
"application": { "application": {
"cache_dir": "/cache", "cache_dir": "/cache",

View File

@ -454,6 +454,19 @@ class VideoDownloader:
external = False external = False
if external: if external:
obs['external_downloader'] = 'aria2c' 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 # check if already in cache to continue from there
cache_dir = self.config['application']['cache_dir'] cache_dir = self.config['application']['cache_dir']
all_cached = os.listdir(cache_dir + '/download/') all_cached = os.listdir(cache_dir + '/download/')

View File

@ -106,6 +106,15 @@
<input type="text" name="downloads.format" id="downloads.format"> <input type="text" name="downloads.format" id="downloads.format">
<br> <br>
</div> </div>
<div class="settings-item">
<p>Current metadata embed setting: <span class="settings-current">{{ config.downloads.add_metadata }}</span></p>
<i>Metadata is not embedded into the downloaded files by default.</i><br>
<select name="downloads.add_metadata" id="downloads.add_metadata"">
<option value="" disabled selected> -- change metadata embed -- </option>
<option value="0">don't embed metadata</option>
<option value="1">embed metadata</option>
</select>
</div>
</div> </div>
<button type="submit">Update Settings</button> <button type="submit">Update Settings</button>
</form> </form>