summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2024-04-01 13:28:59 +0200
committerRobert Honz <exislow+github@gmail.com>2024-04-01 13:28:59 +0200
commit140664afca106090314c50d9e29f10303f145395 (patch)
tree0718a0fa74e57e19d8c26ad99f7d328de97df2f4
parent0e91d7cea276faa10675b2ea764bf54f22575b15 (diff)
downloadtidal-dl-ng-140664afca106090314c50d9e29f10303f145395.tar.gz
✨ Download items will now be taken from the queue.
-rw-r--r--tidal_dl_ng/gui.py74
1 files changed, 28 insertions, 46 deletions
diff --git a/tidal_dl_ng/gui.py b/tidal_dl_ng/gui.py
index 4a7d1e6..c7cbb88 100644
--- a/tidal_dl_ng/gui.py
+++ b/tidal_dl_ng/gui.py
@@ -556,6 +556,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
# Download Queue
self.tr_queue_download.itemClicked.connect(self.on_queue_download_item_clicked)
self.s_queue_download_item_downloading.connect(self.on_queue_download_item_downloading)
+ self.s_queue_download_item_finished.connect(self.on_queue_download_item_finished)
+ self.s_queue_download_item_failed.connect(self.on_queue_download_item_failed)
def on_logout(self):
result: bool = self.tidal.logout()
@@ -708,12 +710,16 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
QueueDownloadStatus.Waiting.value, QtCore.Qt.MatchFlag.MatchExactly, column=0
)
- for item in items:
- self.s_queue_download_item_downloading.emit(item)
+ if len(items) > 0:
+ item: QtWidgets.QTreeWidgetItem = items[0]
+ media: Track | Album | Playlist | Video | Mix | Artist = get_queue_download_media(item)
+ # TODO: Try catch and set FAILED status
+ self.s_queue_download_item_downloading.emit(item)
+ self.on_queue_download(media)
self.s_queue_download_item_finished.emit(item)
-
- time.sleep(2)
+ else:
+ time.sleep(2)
def on_queue_download_item_downloading(self, item: QtWidgets.QTreeWidgetItem) -> None:
self.queue_download_item_status(item, QueueDownloadStatus.Downloading.value)
@@ -727,50 +733,26 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def queue_download_item_status(self, item: QtWidgets.QTreeWidgetItem, status: str) -> None:
item.setText(0, status)
- def on_download_queue(self, media):
- self.pb_download.setEnabled(False)
- self.pb_download.setText("Downloading...")
-
- items: [QtWidgets.QTreeWidgetItem] = self.tr_results.selectedItems()
-
- if len(items) == 0:
- logger_gui.error("Please select a row first.")
- else:
- # If it is an artist resolve it with all available albums of him
- if len(items) == 1:
- tmp_media: Track | Video | Album | Artist = get_results_media_item(items[0])
-
- if isinstance(tmp_media, Artist):
- tmp_children: [QtWidgets.QTreeWidgetItem] = []
- is_dummy_child = not bool(get_results_media_item(items[0].child(0)))
-
- # Use the expand function to retrieve all albums.
- if is_dummy_child:
- self.on_tr_results_expanded(items[0])
-
- count_children: int = items[0].childCount()
-
- # Get all children.
- for idx in range(count_children):
- tmp_children.append(items[0].child(idx))
-
- items: [Album] = tmp_children
-
- items_pos_last = len(items) - 1
+ def on_queue_download(self, media: Track | Album | Playlist | Video | Mix | Artist) -> None:
+ # if isinstance(media, Artist):
+ # tmp_children: [QtWidgets.QTreeWidgetItem] = []
+ # is_dummy_child = not bool(get_results_media_item(items[0].child(0)))
+ #
+ # # Use the expand function to retrieve all albums.
+ # if is_dummy_child:
+ # self.on_tr_results_expanded(items[0])
+ #
+ # count_children: int = items[0].childCount()
+ #
+ # # Get all children.
+ # for idx in range(count_children):
+ # tmp_children.append(items[0].child(idx))
+ #
+ # items: [Album] = tmp_children
- for item in items:
- media: Track | Album | Playlist | Video | Artist = get_results_media_item(item)
- # Skip only if Track item, skip option set and the item is not the last in the list.
- download_delay: bool = bool(
- isinstance(media, Track | Video)
- and self.settings.data.download_delay
- and items.index(item) < items_pos_last
- )
+ download_delay: bool = bool(isinstance(media, Track | Video) and self.settings.data.download_delay)
- self.download(media, self.dl, delay_track=download_delay)
-
- self.pb_download.setText("Download")
- self.pb_download.setEnabled(True)
+ self.download(media, self.dl, delay_track=download_delay)
def download(
self, media: Track | Album | Playlist | Video | Mix | Artist, dl: Download, delay_track: bool = False