diff options
| author | Robert Honz <exislow+github@gmail.com> | 2024-05-22 06:33:40 +0200 |
|---|---|---|
| committer | Robert Honz <exislow+github@gmail.com> | 2024-05-22 06:33:40 +0200 |
| commit | 776542de5c61d207f502d6f4a961b6f3fb12e4cd (patch) | |
| tree | d07fbc30b036cbbde9e644938ba842e40b6ee349 /tidal_dl_ng/cli.py | |
| parent | 3a6bf023d772ccf32c5bd15486a13f5645bfc5f8 (diff) | |
| download | tidal-dl-ng-776542de5c61d207f502d6f4a961b6f3fb12e4cd.tar.gz | |
✨ Can download artists. Fixes #102
Diffstat (limited to 'tidal_dl_ng/cli.py')
| -rw-r--r-- | tidal_dl_ng/cli.py | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/tidal_dl_ng/cli.py b/tidal_dl_ng/cli.py index c4f8b31..5abda11 100644 --- a/tidal_dl_ng/cli.py +++ b/tidal_dl_ng/cli.py @@ -13,7 +13,12 @@ from tidal_dl_ng.config import Settings, Tidal from tidal_dl_ng.constants import CTX_TIDAL, MediaType from tidal_dl_ng.download import Download from tidal_dl_ng.helper.path import get_format_template, path_file_settings -from tidal_dl_ng.helper.tidal import get_tidal_media_id, get_tidal_media_type +from tidal_dl_ng.helper.tidal import ( + all_artist_album_ids, + get_tidal_media_id, + get_tidal_media_type, + instantiate_media, +) from tidal_dl_ng.helper.wrapper import LoggerWrapped from tidal_dl_ng.model.cfg import HelpSettings @@ -192,14 +197,24 @@ def download( dl.item( media_id=item_id, media_type=media_type, file_template=file_template, download_delay=download_delay ) - elif media_type in [MediaType.ALBUM, MediaType.PLAYLIST, MediaType.MIX]: - dl.items( - media_id=item_id, - media_type=media_type, - file_template=file_template, - video_download=ctx.obj[CTX_TIDAL].settings.data.video_download, - download_delay=settings.data.download_delay, - ) + elif media_type in [MediaType.ALBUM, MediaType.PLAYLIST, MediaType.MIX, MediaType.ARTIST]: + item_ids: [int] = [] + + if media_type == MediaType.ARTIST: + media = instantiate_media(ctx.obj[CTX_TIDAL].session, media_type, item_id) + media_type = MediaType.ALBUM + item_ids = item_ids + all_artist_album_ids(media) + else: + item_ids.append(item_id) + + for item_id in item_ids: + dl.items( + media_id=item_id, + media_type=media_type, + file_template=file_template, + video_download=ctx.obj[CTX_TIDAL].settings.data.video_download, + download_delay=settings.data.download_delay, + ) # Stop Progress display. progress.stop() |
