more compatible

This commit is contained in:
Jesse Bannon 2023-07-24 17:21:14 -07:00
parent caf68380e8
commit a5c5cb0d40
4 changed files with 23 additions and 14 deletions

View file

@ -1,7 +1,8 @@
import copy
from collections import defaultdict from collections import defaultdict
from typing import Any
from typing import Dict from typing import Dict
from typing import List from typing import List
from typing import Optional
import mediafile import mediafile
@ -80,20 +81,21 @@ class MusicTagsOptions(OptionsDictValidator):
def __init__(self, name, value): def __init__(self, name, value):
super().__init__(name, value) super().__init__(name, value)
tags_validator: Optional[MusicTagsValidator] = self._validate_key_if_present( old_tags_validator = self._validate_key(
key="tags", validator=MusicTagsValidator key="tags", validator=MusicTagsValidator, default={}
) )
self._embed_thumbnail = self._validate_key_if_present( self._embed_thumbnail = self._validate_key_if_present(
key="embed_thumbnail", validator=BoolValidator 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 new_tags_dict: Dict[str, Any] = copy.deepcopy(value)
if tags_validator is None and self._embed_thumbnail is None: new_tags_dict.pop("tags", None)
self._tags = MusicTagsValidator(name=name, value=value) new_tags_dict.pop("embed_thumbnail", None)
self._is_old_format = False
else: self._tags = MusicTagsValidator(
self._is_old_format = True name=name, value=dict(old_tags_validator._dict, **new_tags_dict)
self._tags = tags_validator or MusicTagsValidator(name=name, value={}) )
@property @property
def tags(self) -> MusicTagsValidator: def tags(self) -> MusicTagsValidator:

View file

@ -11,8 +11,6 @@ def single_song_preset_dict_old_format(output_directory):
"preset": "single", "preset": "single",
# test multi-tags # test multi-tags
"music_tags": {"embed_thumbnail": True, "tags": {"genres": ["multi_tag_1", "multi_tag_2"]}}, "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 # download the worst format so it is fast
"ytdl_options": { "ytdl_options": {
"format": "worst[ext=mp4]", "format": "worst[ext=mp4]",

View file

@ -1,5 +1,5 @@
{ {
".ytdl-sub-single_song_test-download-archive.json": "c8ff22ec3304c9f8dab18cedaed4e8b4", ".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" "YouTube/[2019] YouTube Rewind 2019 For the Record #YouTubeRewind/folder.jpg": "50ee47c80f679029f5d3503bb91b045a"
} }

View file

@ -5,8 +5,17 @@ Files created:
{output_directory}/YouTube/[2019] YouTube Rewind 2019 For the Record #YouTubeRewind {output_directory}/YouTube/[2019] YouTube Rewind 2019 For the Record #YouTubeRewind
01 - YouTube Rewind 2019 For the Record #YouTubeRewind.mp3 01 - YouTube Rewind 2019 For the Record #YouTubeRewind.mp3
Embedded Thumbnail, Music Tags: Embedded Thumbnail, Music Tags:
album: YouTube Rewind 2019: For the Record | #YouTubeRewind
albumartist: YouTube
albumartists: YouTube
artist: YouTube
artists: YouTube
genre: Unset
genres: genres:
- multi_tag_1 - multi_tag_1
- multi_tag_2 - multi_tag_2
Embedded thumbnail title: YouTube Rewind 2019: For the Record | #YouTubeRewind
track: 1
tracktotal: 1
year: 2019
folder.jpg folder.jpg