Compare commits

..

1 Commits

Author SHA1 Message Date
Ventilaar
1186d236f2 Rework video queue download
All checks were successful
Update worker server / build-and-publish (release) Successful in 11s
Generate docker image / build-and-publish (release) Successful in 14s
2025-01-18 23:29:12 +01:00
4 changed files with 99 additions and 82 deletions

View File

@@ -209,6 +209,13 @@ def queue():
get_nosql().queue_emptyQueue()
flash(f'Queue has been emptied')
elif task == 'run-download':
get_nosql().queue_emptyQueue()
flash(f'Queue has been emptied')
elif task == 'queue-run-once':
video_queue.delay()
return redirect(url_for('admin.queue'))
endpoints = get_nosql().queue_getEndpoints()
@@ -251,8 +258,6 @@ def workers():
task = request.form.get('task', None)
if task == 'test-sleep':
test_sleep.delay()
elif task == 'queue-single':
video_queue.delay()
celery = current_app.extensions.get('celery')

View File

@@ -430,13 +430,17 @@ class Mango:
def queue_emptyQueue(self):
return self.download_queue.delete_many({})
def queue_getNext(self, newest=False):
sort = []
def queue_getNext(self):
""" Returns a LIST of queue parameters. Function first checks if ID exists, if so deletes and then checks the next queued until queue is empty (None) or queued id does not exist yet."""
while True:
queueItem = self.download_queue.find_one({})
if not queueItem:
return None
elif self.check_exists(self, queueItem['id']):
self.queue_deleteQueue(queueItem['id'])
return queueItem
if newest:
sort = [( 'created_time', pymongo.DESCENDING )]
return self.download_queue.find_one({}, sort=sort)
##########################################
# HELPER FUNCTIONS #

View File

@@ -29,7 +29,11 @@
<br>
<span class="supporting-text">Prunes all deactivated endpoints, but keeps last 3 days</span>
</form>
<form class="mt-4" method="post" onsubmit="return confirm('Are you sure?');">
<button class="btn mb-2 green" type="submit" name="task" value="queue-run-once">Download oldest queued</button>
<br>
<span class="supporting-text">Will download the oldest queued video ID</span>
</form>
</div>
</div>
</div>
@@ -149,6 +153,11 @@
<input type="text" value="{{ id.get('id') }}" name="value" hidden>
<button class="btn-small waves-effect waves-light" type="submit" name="task" value="delete-queue" title="Delete from queue" {% if id.get('status') != 'queued' %}disabled{% endif %}>🗑️</button>
</form>
<form method="post">
<input type="text" value="{{ id.get('id') }}" name="value" hidden>
<button class="btn-small waves-effect waves-light" type="submit" name="task" value="run-download" title="Run download task" disabled}>⏩</button>
<!-- This function fill not work until the download queue and video download process is rewritten -->
</form>
</td>
<td>{{ id.get('id') }}</td>
<td>{{ id.get('endpoint') }}</td>

View File

@@ -16,7 +16,6 @@
</div>
<form method="POST">
<input title="test-sleep" type="submit" value="test-sleep" name="task">
<input title="test-sleep" type="submit" value="queue-single" name="task">
</form>
<div class="divider"></div>
<div class="row">