Skip to content

Commit

Permalink
Fix web ui progress indicator and improve restart workers.
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Jan 14, 2025
1 parent 501e1ee commit 633fa5a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/onthespot/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,11 @@ def run(self):
downloaded += len(data)
data_chunks += data

if self.gui and downloaded != total_size:
if downloaded != total_size:
if item['item_status'] == 'Cancelled':
raise Exception("Download cancelled by user.")
self.progress.emit(item, self.tr("Downloading"), int((downloaded / total_size) * 100))
if self.gui:
self.progress.emit(item, self.tr("Downloading"), int((downloaded / total_size) * 100))

key = calcbfkey(song["SNG_ID"])

Expand Down
8 changes: 7 additions & 1 deletion src/onthespot/resources/web/download_queue.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
copyButton = createButton('icons/link.png', 'Copy Link', `copyToClipboard('${item.item_url}')`);
}

if (item.item_status === 'Waiting') {
if (!['Failed', 'Cancelled', 'Deleted', 'Already Exists', 'Downloaded'].includes(item.item_status)) {
cancelButton = createButton('icons/stop.png', 'Stop Download', `handleCancel('${item.local_id}')`);
}

Expand Down Expand Up @@ -186,7 +186,13 @@
let cancelledCount = 0;

for (let row of tableBody.rows) {

{% if config.show_download_thumbnails %}
const statusCell = row.cells[5];
{% else %}
const statusCell = row.cells[4];
{% endif %}

if (statusCell) {
const statusText = statusCell.textContent.trim();

Expand Down
10 changes: 10 additions & 0 deletions src/onthespot/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ def restart_workers():

download_workers.clear()

item_urls = []
for key, value in download_queue.items():
item_urls.append(value.get('item_url'))

with download_queue_lock:
download_queue.clear()

for url in item_urls:
parse_url(url)

for i in range(config.get('maximum_download_workers')):
download_worker = DownloadWorker()
download_worker.start()
Expand Down

0 comments on commit 633fa5a

Please sign in to comment.