You've already forked amazing-ytdlp-archive
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5530179558 | ||
![]() |
1186d236f2 | ||
![]() |
5a4726ac10 | ||
![]() |
46bde82d32 |
@@ -4,4 +4,4 @@ COPY requirements.txt /app
|
|||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
COPY . /app
|
COPY . /app
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "ayta:create_app()"]
|
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "ayta:create_app()"]
|
@@ -2,7 +2,7 @@ from flask import Blueprint, render_template, request, redirect, url_for, flash,
|
|||||||
from ..nosql import get_nosql
|
from ..nosql import get_nosql
|
||||||
from ..dlp import checkChannelId, getChannelInfo
|
from ..dlp import checkChannelId, getChannelInfo
|
||||||
from ..decorators import login_required
|
from ..decorators import login_required
|
||||||
from ..tasks import test_sleep, websub_subscribe_callback, websub_unsubscribe_callback, video_download
|
from ..tasks import test_sleep, websub_subscribe_callback, websub_unsubscribe_callback, video_download, video_queue
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from secrets import token_urlsafe
|
from secrets import token_urlsafe
|
||||||
|
|
||||||
@@ -209,6 +209,10 @@ def queue():
|
|||||||
get_nosql().queue_emptyQueue()
|
get_nosql().queue_emptyQueue()
|
||||||
flash(f'Queue has been emptied')
|
flash(f'Queue has been emptied')
|
||||||
|
|
||||||
|
elif task == 'queue-run-once':
|
||||||
|
task = video_queue.delay()
|
||||||
|
flash(f'Task has been started on the oldest queued item: {task.id}')
|
||||||
|
|
||||||
return redirect(url_for('admin.queue'))
|
return redirect(url_for('admin.queue'))
|
||||||
|
|
||||||
endpoints = get_nosql().queue_getEndpoints()
|
endpoints = get_nosql().queue_getEndpoints()
|
||||||
|
@@ -430,6 +430,18 @@ class Mango:
|
|||||||
def queue_emptyQueue(self):
|
def queue_emptyQueue(self):
|
||||||
return self.download_queue.delete_many({})
|
return self.download_queue.delete_many({})
|
||||||
|
|
||||||
|
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(queueItem['id']):
|
||||||
|
self.queue_deleteQueue(queueItem['id'])
|
||||||
|
return queueItem
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
# HELPER FUNCTIONS #
|
# HELPER FUNCTIONS #
|
||||||
##########################################
|
##########################################
|
||||||
@@ -454,6 +466,3 @@ def clean_info_json(originalInfo, format='dict'):
|
|||||||
else:
|
else:
|
||||||
print('The requested output format is not supported!')
|
print('The requested output format is not supported!')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
mango = Mango('mongodb://root:example@192.168.66.140:27017')
|
|
@@ -24,6 +24,25 @@ def video_download(videoId):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@shared_task()
|
||||||
|
def video_queue():
|
||||||
|
"""
|
||||||
|
Gets the oldest video ID from the queue and runs video_download() on it.
|
||||||
|
"""
|
||||||
|
from .nosql import get_nosql
|
||||||
|
|
||||||
|
videoId = get_nosql().queue_getNext()
|
||||||
|
|
||||||
|
if videoId:
|
||||||
|
videoId = videoId['id']
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if video_download(videoId):
|
||||||
|
get_nosql().queue_deleteQueue(videoId)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
@shared_task()
|
@shared_task()
|
||||||
def websub_subscribe_callback(channelId):
|
def websub_subscribe_callback(channelId):
|
||||||
|
@@ -29,7 +29,11 @@
|
|||||||
<br>
|
<br>
|
||||||
<span class="supporting-text">Prunes all deactivated endpoints, but keeps last 3 days</span>
|
<span class="supporting-text">Prunes all deactivated endpoints, but keeps last 3 days</span>
|
||||||
</form>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -149,6 +153,11 @@
|
|||||||
<input type="text" value="{{ id.get('id') }}" name="value" hidden>
|
<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>
|
<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>
|
||||||
|
<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>
|
||||||
<td>{{ id.get('id') }}</td>
|
<td>{{ id.get('id') }}</td>
|
||||||
<td>{{ id.get('endpoint') }}</td>
|
<td>{{ id.get('endpoint') }}</td>
|
||||||
|
Reference in New Issue
Block a user