more compatible
This commit is contained in:
parent
caf68380e8
commit
a5c5cb0d40
4 changed files with 23 additions and 14 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import copy
|
||||
from collections import defaultdict
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
|
||||
import mediafile
|
||||
|
||||
|
|
@ -80,20 +81,21 @@ class MusicTagsOptions(OptionsDictValidator):
|
|||
def __init__(self, name, value):
|
||||
super().__init__(name, value)
|
||||
|
||||
tags_validator: Optional[MusicTagsValidator] = self._validate_key_if_present(
|
||||
key="tags", validator=MusicTagsValidator
|
||||
old_tags_validator = self._validate_key(
|
||||
key="tags", validator=MusicTagsValidator, default={}
|
||||
)
|
||||
self._embed_thumbnail = self._validate_key_if_present(
|
||||
key="embed_thumbnail", validator=BoolValidator
|
||||
)
|
||||
self._is_old_format = old_tags_validator is not None or self._embed_thumbnail is not None
|
||||
|
||||
# New format where tags are the keys, no "tags" or "embed_thumbnail" present
|
||||
if tags_validator is None and self._embed_thumbnail is None:
|
||||
self._tags = MusicTagsValidator(name=name, value=value)
|
||||
self._is_old_format = False
|
||||
else:
|
||||
self._is_old_format = True
|
||||
self._tags = tags_validator or MusicTagsValidator(name=name, value={})
|
||||
new_tags_dict: Dict[str, Any] = copy.deepcopy(value)
|
||||
new_tags_dict.pop("tags", None)
|
||||
new_tags_dict.pop("embed_thumbnail", None)
|
||||
|
||||
self._tags = MusicTagsValidator(
|
||||
name=name, value=dict(old_tags_validator._dict, **new_tags_dict)
|
||||
)
|
||||
|
||||
@property
|
||||
def tags(self) -> MusicTagsValidator:
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ def single_song_preset_dict_old_format(output_directory):
|
|||
"preset": "single",
|
||||
# test multi-tags
|
||||
"music_tags": {"embed_thumbnail": True, "tags": {"genres": ["multi_tag_1", "multi_tag_2"]}},
|
||||
# test the new embed_thumbnail plugin
|
||||
"embed_thumbnail": True,
|
||||
# download the worst format so it is fast
|
||||
"ytdl_options": {
|
||||
"format": "worst[ext=mp4]",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
".ytdl-sub-single_song_test-download-archive.json": "c8ff22ec3304c9f8dab18cedaed4e8b4",
|
||||
"YouTube/[2019] YouTube Rewind 2019: For the Record | #YouTubeRewind/01 - YouTube Rewind 2019: For the Record | #YouTubeRewind.mp3": "7dcad720d29f5036eb6f75e533757f80",
|
||||
"YouTube/[2019] YouTube Rewind 2019: For the Record | #YouTubeRewind/01 - YouTube Rewind 2019: For the Record | #YouTubeRewind.mp3": "37b38834eda1293ad503e00dcff7c4dc",
|
||||
"YouTube/[2019] YouTube Rewind 2019: For the Record | #YouTubeRewind/folder.jpg": "50ee47c80f679029f5d3503bb91b045a"
|
||||
}
|
||||
|
|
@ -5,8 +5,17 @@ Files created:
|
|||
{output_directory}/YouTube/[2019] YouTube Rewind 2019: For the Record | #YouTubeRewind
|
||||
01 - YouTube Rewind 2019: For the Record | #YouTubeRewind.mp3
|
||||
Embedded Thumbnail, Music Tags:
|
||||
album: YouTube Rewind 2019: For the Record | #YouTubeRewind
|
||||
albumartist: YouTube
|
||||
albumartists: YouTube
|
||||
artist: YouTube
|
||||
artists: YouTube
|
||||
genre: Unset
|
||||
genres:
|
||||
- multi_tag_1
|
||||
- multi_tag_2
|
||||
Embedded thumbnail
|
||||
title: YouTube Rewind 2019: For the Record | #YouTubeRewind
|
||||
track: 1
|
||||
tracktotal: 1
|
||||
year: 2019
|
||||
folder.jpg
|
||||
Loading…
Reference in a new issue