summaryrefslogtreecommitdiff
path: root/tidal_dl_ng
diff options
context:
space:
mode:
authorexislow <exislow@users.noreply.github.com>2025-10-20 09:26:22 +0200
committerGitHub <noreply@github.com>2025-10-20 09:26:22 +0200
commit51556f1d80a2e7629d13b3729c5756c6af64d355 (patch)
treee1d8a69799acccee46974336f6eba21d8ed6a3c6 /tidal_dl_ng
parent8c361249ed8b3caa504192dd37bd354ed04b20b7 (diff)
parent9321ac03da2aee9e45cf833f503e3b36060eb9ee (diff)
downloadtidal-dl-ng-51556f1d80a2e7629d13b3729c5756c6af64d355.tar.gz
Merge pull request #590 from Rikrdoga/feature/download-album-from-track
feat: Add 'Download Full Album' from track context menu
Diffstat (limited to 'tidal_dl_ng')
-rw-r--r--tidal_dl_ng/gui.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tidal_dl_ng/gui.py b/tidal_dl_ng/gui.py
index d27f2b6..744cc06 100644
--- a/tidal_dl_ng/gui.py
+++ b/tidal_dl_ng/gui.py
@@ -583,6 +583,11 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
# We build the menu.
menu = QtWidgets.QMenu()
+
+ media = get_results_media_item(index, self.proxy_tr_results, self.model_tr_results)
+ if isinstance(media, Track) and media.album:
+ menu.addAction("Download Full Album", lambda: self.thread_download_album_from_track(point))
+
menu.addAction("Copy Share URL", lambda: self.on_copy_url_share(self.tr_results, point))
menu.exec(self.tr_results.mapToGlobal(point))
@@ -1699,6 +1704,39 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
event.accept()
+ def thread_download_album_from_track(self, point: QtCore.QPoint) -> None:
+ """Starts the download of the full album from a selected track in a new thread.
+
+ Args:
+ point (QPoint): The point in the tree where the user clicked.
+ """
+ self.thread_it(self.on_download_album_from_track, point)
+
+
+ def on_download_album_from_track(self, point: QtCore.QPoint) -> None:
+ """Gets the album from a selected track and adds it to the download queue."""
+ index: QtCore.QModelIndex = self.tr_results.indexAt(point)
+ media_track: Track = get_results_media_item(index, self.proxy_tr_results, self.model_tr_results)
+
+ # Ensure we have a track and an album object with an ID
+ if isinstance(media_track, Track) and media_track.album and media_track.album.id:
+ try:
+ # Use the album ID from the track to fetch the FULL album object from TIDAL
+ full_album_object = self.tidal.session.album(media_track.album.id)
+
+ # Convert the full album object into a queue item
+ queue_dl_item: QueueDownloadItem | None = self.media_to_queue_download_model(full_album_object)
+
+ if queue_dl_item:
+ # Add the item to the download queue
+ self.queue_download_media(queue_dl_item)
+ else:
+ logger_gui.warning(f"Failed to create a queue item for album ID: {full_album_object.id}")
+ except Exception as e:
+ logger_gui.error(f"Could not fetch the full album from TIDAL. Error: {e}")
+ else:
+ logger_gui.warning("Could not retrieve album information from the selected track.")
+
# TODO: Comment with Google Docstrings.
def gui_activate(tidal: Tidal | None = None):