summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/helper
diff options
context:
space:
mode:
authorexislow <exislow@users.noreply.github.com>2024-03-22 18:19:49 +0100
committerGitHub <noreply@github.com>2024-03-22 18:19:49 +0100
commitefba6df1c541d51fe4478d66b98f6e24ce4d2295 (patch)
tree60d929efa5569affd7a7f77170975f3d1c2da2c1 /tidal_dl_ng/helper
parent6c3ed1030876e1670f13c96c1beb036020203be7 (diff)
parentd47517dd4b8aebadaf941b55d0421d390588813c (diff)
downloadtidal-dl-ng-efba6df1c541d51fe4478d66b98f6e24ce4d2295.tar.gz
Merge pull request #68 from exislow/45-support-for-artist-download
45 support for artist download
Diffstat (limited to 'tidal_dl_ng/helper')
-rw-r--r--tidal_dl_ng/helper/tidal.py20
1 files changed, 13 insertions, 7 deletions
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