From 48fd379ebaed9398791bd1dab819a6351b3763df Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Fri, 22 Mar 2024 17:31:33 +0100 Subject: ✨ Search for artists is possible. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tidal_dl_ng/helper/tidal.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'tidal_dl_ng/helper') diff --git a/tidal_dl_ng/helper/tidal.py b/tidal_dl_ng/helper/tidal.py index 2dde6b2..93c9f76 100644 --- a/tidal_dl_ng/helper/tidal.py +++ b/tidal_dl_ng/helper/tidal.py @@ -1,3 +1,5 @@ +from collections.abc import Callable + from tidalapi import Album, Mix, Playlist, Session, Track, UserPlaylist, Video from tidalapi.artist import Artist, Role from tidalapi.session import SearchTypes @@ -87,21 +89,25 @@ def search_results_all(session: Session, needle: str, types_media: SearchTypes = return result -def items_results_all(media_list: [Mix | Playlist | Album], videos_include: bool = True) -> [Track | Video]: +def items_results_all(media_list: [Mix | Playlist | Album], videos_include: bool = True) -> [Track | Video | Album]: limit: int = 100 offset: int = 0 done: bool = False - result: [Track | Video] = [] + result: [Track | Video | Album] = [] if isinstance(media_list, Mix): result = media_list.items() else: + if isinstance(media_list, Playlist | Album): + if videos_include: + func_get_items_media: Callable = media_list.items + else: + func_get_items_media: Callable = media_list.tracks + else: + func_get_items_media: Callable = media_list.get_albums + while not done: - tmp_result: [Track | Video] = ( - media_list.items(limit=limit, offset=offset) - if videos_include - else media_list.tracks(limit=limit, offset=offset) - ) + tmp_result: [Track | Video] = func_get_items_media(limit=limit, offset=offset) if bool(tmp_result): result += tmp_result -- cgit v1.3.1