From 84c8036bddf9c613e6a13095b918ba0dcc5ae3ef Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Sat, 23 Mar 2024 12:29:14 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20List=20EPs=20and=20singles=20while?= =?UTF-8?q?=20expanding=20artists=20in=20result=20pane.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tidal_dl_ng/helper/tidal.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tidal_dl_ng/helper/tidal.py b/tidal_dl_ng/helper/tidal.py index 93c9f76..101ab5a 100644 --- a/tidal_dl_ng/helper/tidal.py +++ b/tidal_dl_ng/helper/tidal.py @@ -90,31 +90,36 @@ def search_results_all(session: Session, needle: str, types_media: SearchTypes = 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 | Album] = [] if isinstance(media_list, Mix): result = media_list.items() else: + func_get_items_media: [Callable] = [] + if isinstance(media_list, Playlist | Album): if videos_include: - func_get_items_media: Callable = media_list.items + func_get_items_media.append(media_list.items) else: - func_get_items_media: Callable = media_list.tracks + func_get_items_media.append(media_list.tracks) else: - func_get_items_media: Callable = media_list.get_albums + func_get_items_media.append(media_list.get_albums) + func_get_items_media.append(media_list.get_albums_ep_singles) - while not done: - tmp_result: [Track | Video] = func_get_items_media(limit=limit, offset=offset) + for func_media in func_get_items_media: + limit: int = 100 + offset: int = 0 + done: bool = False - if bool(tmp_result): - result += tmp_result - # Get the next page in the next iteration. - offset += limit - else: - done = True + while not done: + tmp_result: [Track | Video | Album] = func_media(limit=limit, offset=offset) + + if bool(tmp_result): + result += tmp_result + # Get the next page in the next iteration. + offset += limit + else: + done = True return result