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 @shared_task
def download_single(youtube_id): def download_single(youtube_id):
""" start download single video now """ """ start download single video now """
to_download = [youtube_id] download_handler = VideoDownloader([youtube_id])
download_handler = VideoDownloader(to_download)
download_handler.download_list() download_handler.download_list()

View File

@ -44,7 +44,7 @@
{% endif %} {% endif %}
<p>Published: {{ video.published }} | Duration: {{ video.duration }} | {{ video.youtube_id }}</p> <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="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>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -542,7 +542,7 @@ class PostData:
elif task == 'dlnow': elif task == 'dlnow':
youtube_id = item['status'] youtube_id = item['status']
print('downloading: ' + youtube_id) print('downloading: ' + youtube_id)
download_single(youtube_id) download_single.delay(youtube_id=youtube_id)
elif task == 'manual-import': elif task == 'manual-import':
print('starting manual import') print('starting manual import')
run_manual_import.delay() run_manual_import.delay()

View File

@ -72,8 +72,8 @@ function toIgnore(button) {
function downloadNow(button) { function downloadNow(button) {
var youtube_id = button.getAttribute('data-id'); var youtube_id = button.getAttribute('data-id');
var payload = JSON.stringify({'dlnow': youtube_id}); var payload = JSON.stringify({'dlnow': youtube_id});
animate('download-icon', 'bounce-img');
sendPost(payload); sendPost(payload);
document.getElementById(youtube_id).remove();
setTimeout(function(){ setTimeout(function(){
handleInterval(); handleInterval();
}, 500); }, 500);