diff --git a/src/onthespot/cli.py b/src/onthespot/cli.py
index 54aefaf..029585a 100644
--- a/src/onthespot/cli.py
+++ b/src/onthespot/cli.py
@@ -36,6 +36,7 @@ def run(self):
with download_queue_lock:
download_queue[local_id] = {
'local_id': local_id,
+ 'available': True,
"item_service": item["item_service"],
"item_type": item["item_type"],
'item_id': item['item_id'],
@@ -68,8 +69,9 @@ def main():
queue_worker = QueueWorker()
queue_worker.start()
- download_worker = DownloadWorker()
- download_worker.start()
+ for i in range(config.get('maximum_download_workers')):
+ downloadworker = DownloadWorker(gui=True)
+ downloadworker.start()
fill_account_pool.wait()
diff --git a/src/onthespot/downloader.py b/src/onthespot/downloader.py
index 8e3adcc..d3d71d9 100644
--- a/src/onthespot/downloader.py
+++ b/src/onthespot/downloader.py
@@ -36,8 +36,10 @@ def start(self):
def readd_item_to_download_queue(self, item):
with download_queue_lock:
try:
- del download_queue[item['local_id']]
- download_queue[item['local_id']] = item
+ local_id = item['local_id']
+ del download_queue[local_id]
+ download_queue[local_id] = item
+ download_queue[local_id]['available'] = True
except (KeyError):
# Item likely cleared from queue
return
@@ -47,7 +49,21 @@ def run(self):
if download_queue:
try:
try:
- item = download_queue[next(iter(download_queue))]
+ # Mark item as unavailable for other download workers
+ iterator = iter(download_queue)
+ while True:
+ try:
+ local_id = next(iterator)
+ if download_queue[local_id]['available'] is False:
+ continue
+ with download_queue_lock:
+ download_queue[local_id]['available'] = False
+ item = download_queue[local_id]
+ break
+ except StopIteration:
+ # Queue is empty
+ break
+
item_service = item['item_service']
item_type = item['item_type']
item_id = item['item_id']
@@ -313,7 +329,7 @@ def yt_dlp_progress_hook(self, item, d):
except (RuntimeError):
# Likely Ratelimit
- logger.info("Download failed: {item}")
+ logger.info(f"Download failed: {item}")
item['item_status'] = 'Failed'
if self.gui:
self.progress.emit(item, self.tr("Failed"), 0)
@@ -345,7 +361,7 @@ def yt_dlp_progress_hook(self, item, d):
if self.gui:
self.progress.emit(item, self.tr("Converting"), 99)
- convert_audio_format(file_path, item_metadata, default_format)
+ convert_audio_format(file_path, default_format)
embed_metadata(item, item_metadata)
diff --git a/src/onthespot/gui/dl_progressbtn.py b/src/onthespot/gui/dl_progressbtn.py
index 12f496d..1a633de 100644
--- a/src/onthespot/gui/dl_progressbtn.py
+++ b/src/onthespot/gui/dl_progressbtn.py
@@ -73,7 +73,9 @@ def delete_file(self):
file_path = download_queue[self.local_id]['file_path']
file = os.path.abspath(file_path)
os.remove(file)
+ download_queue[self.local_id]["item_status"] = 'Deleted'
download_queue[self.local_id]["gui"]["status_label"].setText(self.tr("Deleted"))
self.open_btn.hide()
self.locate_btn.hide()
self.delete_btn.hide()
+ self.retry_btn.show()
diff --git a/src/onthespot/gui/mainui.py b/src/onthespot/gui/mainui.py
index f7b96ea..629c7ba 100644
--- a/src/onthespot/gui/mainui.py
+++ b/src/onthespot/gui/mainui.py
@@ -88,12 +88,13 @@ def __init__(self, _dialog, start_url=''):
fillaccountpool.start()
queueworker = QueueWorker()
- queueworker.add_item_to_download_list.connect(self.add_item_to_download_list) # Connect signal to update_table method
+ queueworker.add_item_to_download_list.connect(self.add_item_to_download_list)
queueworker.start()
- downloadworker = DownloadWorker(gui=True)
- downloadworker.progress.connect(self.update_item_in_download_list) # Connect the signal to the update method
- downloadworker.start() # Start the download worker thread
+ for i in range(config.get('maximum_download_workers')):
+ downloadworker = DownloadWorker(gui=True)
+ downloadworker.progress.connect(self.update_item_in_download_list)
+ downloadworker.start()
self.mirrorplayback = MirrorSpotifyPlayback()
if config.get('mirror_spotify_playback'):
@@ -414,6 +415,7 @@ def add_item_to_download_list(self, item, item_metadata):
with download_queue_lock:
download_queue[item['local_id']] = {
'local_id': item['local_id'],
+ 'available': True,
"item_service": item["item_service"],
"item_type": item["item_type"],
'item_id': item['item_id'],
@@ -449,7 +451,7 @@ def update_item_in_download_list(self, item, status, progress):
item['gui']['btn']['copy'].show()
item['gui']["btn"]['retry'].hide()
return
- if progress == 0:
+ elif progress == 0:
item['gui']["btn"]['cancel'].hide()
if config.get("download_copy_btn"):
item['gui']['btn']['copy'].show()
@@ -460,12 +462,6 @@ def update_item_in_download_list(self, item, status, progress):
item['gui']['btn']['retry'].hide()
if config.get("download_copy_btn"):
item['gui']['btn']['copy'].show()
- if config.get("download_play_btn"):
- item['gui']['btn']['play'].show()
- if config.get("download_save_btn"):
- item['gui']['btn']['save'].show()
- if config.get("download_queue_btn"):
- item['gui']['btn']['queue'].show()
if config.get("download_open_btn"):
item['gui']['btn']['open'].show()
if config.get("download_locate_btn"):
diff --git a/src/onthespot/gui/qtui/main.ui b/src/onthespot/gui/qtui/main.ui
index bcc9ad3..d651c81 100644
--- a/src/onthespot/gui/qtui/main.ui
+++ b/src/onthespot/gui/qtui/main.ui
@@ -656,9 +656,9 @@
its a music downloader