From 3d2d11ba3a6226678b3679334667556dc76ef119 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 17 Sep 2021 10:52:59 +0700 Subject: [PATCH] fix blocking issue where download_now wouldn't delay --- tubearchivist/home/tasks.py | 3 +-- tubearchivist/home/templates/home/downloads.html | 2 +- tubearchivist/home/views.py | 2 +- tubearchivist/static/script.js | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tubearchivist/home/tasks.py b/tubearchivist/home/tasks.py index 321b5b5..ed6a6f3 100644 --- a/tubearchivist/home/tasks.py +++ b/tubearchivist/home/tasks.py @@ -55,8 +55,7 @@ def download_pending(): @shared_task def download_single(youtube_id): """ start download single video now """ - to_download = [youtube_id] - download_handler = VideoDownloader(to_download) + download_handler = VideoDownloader([youtube_id]) download_handler.download_list() diff --git a/tubearchivist/home/templates/home/downloads.html b/tubearchivist/home/templates/home/downloads.html index 6d8f491..cd96bfb 100644 --- a/tubearchivist/home/templates/home/downloads.html +++ b/tubearchivist/home/templates/home/downloads.html @@ -44,7 +44,7 @@ {% endif %}

Published: {{ video.published }} | Duration: {{ video.duration }} | {{ video.youtube_id }}

- + {% endfor %} diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index c8f5fb2..e00ddbf 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -542,7 +542,7 @@ class PostData: elif task == 'dlnow': youtube_id = item['status'] print('downloading: ' + youtube_id) - download_single(youtube_id) + download_single.delay(youtube_id=youtube_id) elif task == 'manual-import': print('starting manual import') run_manual_import.delay() diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 3d4b0fe..94b5172 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -72,8 +72,8 @@ function toIgnore(button) { function downloadNow(button) { var youtube_id = button.getAttribute('data-id'); var payload = JSON.stringify({'dlnow': youtube_id}); - animate('download-icon', 'bounce-img'); sendPost(payload); + document.getElementById(youtube_id).remove(); setTimeout(function(){ handleInterval(); }, 500);