From 7ec9e30ad0ee0cc0bcadfa512f865e77cf0c4ddb Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Mon, 21 Nov 2022 13:45:24 -0800 Subject: [PATCH] [BUGFIX] Set multi-value music tags as a list with single value --- examples/music_audio_from_videos.yaml | 2 ++ src/ytdl_sub/plugins/music_tags.py | 7 ++++++- .../plugins/test_audio_extract_playlist.json | 6 +++--- .../plugins/test_audio_extract_single.json | 2 +- .../plugins/test_audio_extract_playlist.txt | 6 ++++++ .../plugins/test_audio_extract_single.txt | 2 ++ 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/music_audio_from_videos.yaml b/examples/music_audio_from_videos.yaml index 801e018d..153a9034 100644 --- a/examples/music_audio_from_videos.yaml +++ b/examples/music_audio_from_videos.yaml @@ -20,7 +20,9 @@ presets: embed_thumbnail: False # Set to True to embed album art tags: artist: "{custom_artist_name}" + artists: "{custom_artist_name}" albumartist: "{custom_artist_name}" + albumartists: "{custom_artist_name}" title: "{custom_track_name}" album: "{custom_album_name}" track: "{custom_track_number}" diff --git a/src/ytdl_sub/plugins/music_tags.py b/src/ytdl_sub/plugins/music_tags.py index b5387876..b054c30d 100644 --- a/src/ytdl_sub/plugins/music_tags.py +++ b/src/ytdl_sub/plugins/music_tags.py @@ -99,7 +99,12 @@ class MusicTagsPlugin(Plugin[MusicTagsOptions]): if not self.is_dry_run: audio_file = mediafile.MediaFile(entry.get_download_file_path()) for tag_name, tag_value in tags_to_write.items(): - setattr(audio_file, tag_name, tag_value) + # If the attribute is a List-type, set it as the first element of the list + if isinstance(getattr(audio_file, tag_name), list): + setattr(audio_file, tag_name, [tag_value]) + # Otherwise, set as single value + else: + setattr(audio_file, tag_name, tag_value) if self.plugin_options.embed_thumbnail: # convert the entry thumbnail so it is embedded as jpg diff --git a/tests/resources/expected_downloads_summaries/plugins/test_audio_extract_playlist.json b/tests/resources/expected_downloads_summaries/plugins/test_audio_extract_playlist.json index e026e3c7..2676cfc4 100644 --- a/tests/resources/expected_downloads_summaries/plugins/test_audio_extract_playlist.json +++ b/tests/resources/expected_downloads_summaries/plugins/test_audio_extract_playlist.json @@ -1,5 +1,5 @@ { - "Jesse's Minecraft Server [Trailer - Feb.1].ogg": "0d4509c21883fbc46584d25f6ec4fd80", - "Jesse's Minecraft Server [Trailer - Feb.27].ogg": "7ab2863ee0e1c215102c4512085f877d", - "Jesse's Minecraft Server [Trailer - Mar.21].ogg": "ed6a54d5b3ec6303ea6a175e02c69511" + "Jesse's Minecraft Server [Trailer - Feb.1].ogg": "e8802a80b3011ba4ebdb2fdd8da4f84d", + "Jesse's Minecraft Server [Trailer - Feb.27].ogg": "e9a8a0f2aa98a37610b9418333026f58", + "Jesse's Minecraft Server [Trailer - Mar.21].ogg": "87fd3e42e238374ae1411479d35d38b7" } \ No newline at end of file diff --git a/tests/resources/expected_downloads_summaries/plugins/test_audio_extract_single.json b/tests/resources/expected_downloads_summaries/plugins/test_audio_extract_single.json index 7ac29d35..9e8f03fa 100644 --- a/tests/resources/expected_downloads_summaries/plugins/test_audio_extract_single.json +++ b/tests/resources/expected_downloads_summaries/plugins/test_audio_extract_single.json @@ -1,3 +1,3 @@ { - "YouTube Rewind 2019: For the Record | #YouTubeRewind.mp3": "8e531bfb93b144fe652f44950e31b3f7" + "YouTube Rewind 2019: For the Record | #YouTubeRewind.mp3": "5df65e724b3c305195473c42bbc53da9" } \ No newline at end of file diff --git a/tests/resources/transaction_log_summaries/plugins/test_audio_extract_playlist.txt b/tests/resources/transaction_log_summaries/plugins/test_audio_extract_playlist.txt index 8349bc6f..ab4be55f 100644 --- a/tests/resources/transaction_log_summaries/plugins/test_audio_extract_playlist.txt +++ b/tests/resources/transaction_log_summaries/plugins/test_audio_extract_playlist.txt @@ -5,7 +5,9 @@ Files created: Music Tags: album: Singles albumartist: Project Zombie + albumartists: Project Zombie artist: Project Zombie + artists: Project Zombie genre: Unset title: Jesse's Minecraft Server [Trailer - Feb.1] track: 3 @@ -14,7 +16,9 @@ Files created: Music Tags: album: Singles albumartist: Project Zombie + albumartists: Project Zombie artist: Project Zombie + artists: Project Zombie genre: Unset title: Jesse's Minecraft Server [Trailer - Feb.27] track: 2 @@ -23,7 +27,9 @@ Files created: Music Tags: album: Singles albumartist: Project Zombie + albumartists: Project Zombie artist: Project Zombie + artists: Project Zombie genre: Unset title: Jesse's Minecraft Server [Trailer - Mar.21] track: 1 diff --git a/tests/resources/transaction_log_summaries/plugins/test_audio_extract_single.txt b/tests/resources/transaction_log_summaries/plugins/test_audio_extract_single.txt index aa7ec2d8..9f610a07 100644 --- a/tests/resources/transaction_log_summaries/plugins/test_audio_extract_single.txt +++ b/tests/resources/transaction_log_summaries/plugins/test_audio_extract_single.txt @@ -5,7 +5,9 @@ Files created: Embedded Thumbnail, Music Tags: album: Singles albumartist: YouTube + albumartists: YouTube artist: YouTube + artists: YouTube genre: Unset title: YouTube Rewind 2019: For the Record | #YouTubeRewind track: 1