Skip to content

Commit d47517d

Browse files
committed
✨ All albums of an artist can be downloaded.
1 parent 48fd379 commit d47517d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tidal_dl_ng/gui.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,30 @@ def on_download_results(self):
567567
if len(items) == 0:
568568
logger_gui.error("Please select a row first.")
569569
else:
570+
# If it is an artist resolve it with all available albums of him
571+
if len(items) == 1:
572+
tmp_media: QtWidgets.QTreeWidgetItem = items[0].data(5, QtCore.Qt.ItemDataRole.UserRole)
573+
574+
if isinstance(tmp_media, Artist):
575+
tmp_children: [QtWidgets.QTreeWidgetItem] = []
576+
is_dummy_child = not bool(items[0].child(0).data(5, QtCore.Qt.ItemDataRole.UserRole))
577+
578+
# Use the expand function to retrieve all albums.
579+
if is_dummy_child:
580+
self.on_tr_results_expanded(items[0])
581+
582+
count_children: int = items[0].childCount()
583+
584+
# Get all children.
585+
for idx in range(count_children):
586+
tmp_children.append(items[0].child(idx))
587+
588+
items: [Album] = tmp_children
589+
570590
items_pos_last = len(items) - 1
571591

572592
for item in items:
573-
media: Track | Album | Playlist | Video = item.data(5, QtCore.Qt.ItemDataRole.UserRole)
593+
media: Track | Album | Playlist | Video | Artist = item.data(5, QtCore.Qt.ItemDataRole.UserRole)
574594
# Skip only if Track item, skip option set and the item is not the last in the list.
575595
download_delay: bool = bool(
576596
isinstance(media, Track | Video)
@@ -583,7 +603,9 @@ def on_download_results(self):
583603
self.pb_download.setText("Download")
584604
self.pb_download.setEnabled(True)
585605

586-
def download(self, media: Track | Album | Playlist | Video | Mix, dl: Download, delay_track: bool = False) -> None:
606+
def download(
607+
self, media: Track | Album | Playlist | Video | Mix | Artist, dl: Download, delay_track: bool = False
608+
) -> None:
587609
self.s_pb_reset.emit()
588610
self.s_statusbar_message.emit(StatusbarMessage(message="Download started..."))
589611

0 commit comments

Comments
 (0)