From e1dfc9ae0b86601e950387882533ab7ea6684f22 Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Tue, 19 Mar 2024 14:44:16 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Adds=20'album=5Fartist'=20to=20the?= =?UTF-8?q?=20folder=20names.=20Fixes=20#51?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tidal_dl_ng/helper/path.py | 4 +++- tidal_dl_ng/helper/tidal.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tidal_dl_ng/helper/path.py b/tidal_dl_ng/helper/path.py index cda8663..2fc7d16 100644 --- a/tidal_dl_ng/helper/path.py +++ b/tidal_dl_ng/helper/path.py @@ -10,7 +10,7 @@ from tidalapi import Album, Mix, Playlist, Track, UserPlaylist, Video from tidal_dl_ng import __name_display__ from tidal_dl_ng.constants import FILENAME_SANITIZE_PLACEHOLDER, UNIQUIFY_THRESHOLD, AudioExtensions, MediaType -from tidal_dl_ng.helper.tidal import name_builder_artist, name_builder_title +from tidal_dl_ng.helper.tidal import name_builder_artist, name_builder_title, name_builder_album_artist def path_home() -> str: @@ -88,6 +88,8 @@ def format_str_media(name: str, media: Track | Album | Playlist | UserPlaylist | result = name_builder_artist(media) elif hasattr(media, "artist"): result = media.artist.name + elif name == "album_artist": + result = name_builder_album_artist(media) elif name == "track_title": if isinstance(media, Track | Video): result = name_builder_title(media) diff --git a/tidal_dl_ng/helper/tidal.py b/tidal_dl_ng/helper/tidal.py index 2a61bd6..77dd72d 100644 --- a/tidal_dl_ng/helper/tidal.py +++ b/tidal_dl_ng/helper/tidal.py @@ -1,5 +1,5 @@ from tidalapi import Album, Mix, Playlist, Session, Track, UserPlaylist, Video -from tidalapi.artist import Role +from tidalapi.artist import Role, Artist from tidalapi.session import SearchTypes from tidal_dl_ng.constants import MediaType @@ -12,8 +12,9 @@ def name_builder_artist(media: Track | Video | Album) -> str: def name_builder_album_artist(media: Track | Album) -> str: artists_tmp: [str] = [] + artists: [Artist] = media.album.artists if isinstance(media, Track) else media.artists - for artist in media.album.artists: + for artist in artists: if Role.main in artist.roles: artists_tmp.append(artist.name)