fix blocking issue where download_now wouldn't delay

This commit is contained in:
simon 2021-09-17 10:52:59 +07:00
parent 46487d682e
commit 3d2d11ba3a
4 changed files with 4 additions and 5 deletions

View File

@ -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()

View File

@ -44,7 +44,7 @@
{% endif %}
<p>Published: {{ video.published }} | Duration: {{ video.duration }} | {{ video.youtube_id }}</p>
<button data-id="{{ video.youtube_id }}" onclick="toIgnore(this)">Ignore</button>
<button data-id="{{ video.youtube_id }}" onclick="downloadNow(this)">Download now</button>
<button id="{{ video.youtube_id }}" data-id="{{ video.youtube_id }}" onclick="downloadNow(this)">Download now</button>
</div>
</div>
{% endfor %}

View File

@ -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()

View File

@ -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);