You've already forked amazing-ytdlp-archive
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5a4726ac10 | ||
![]() |
46bde82d32 |
@@ -4,4 +4,4 @@ COPY requirements.txt /app
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY . /app
|
||||
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 ..dlp import checkChannelId, getChannelInfo
|
||||
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 secrets import token_urlsafe
|
||||
|
||||
@@ -251,6 +251,8 @@ 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')
|
||||
|
||||
|
@@ -429,7 +429,15 @@ class Mango:
|
||||
|
||||
def queue_emptyQueue(self):
|
||||
return self.download_queue.delete_many({})
|
||||
|
||||
|
||||
def queue_getNext(self, newest=False):
|
||||
sort = []
|
||||
|
||||
if newest:
|
||||
sort = [( 'created_time', pymongo.DESCENDING )]
|
||||
|
||||
return self.download_queue.find_one({}, sort=sort)
|
||||
|
||||
##########################################
|
||||
# HELPER FUNCTIONS #
|
||||
##########################################
|
||||
@@ -453,7 +461,4 @@ def clean_info_json(originalInfo, format='dict'):
|
||||
return json.dumps(originalInfo)
|
||||
else:
|
||||
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 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()
|
||||
def websub_subscribe_callback(channelId):
|
||||
|
@@ -16,6 +16,7 @@
|
||||
</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">
|
||||
|
Reference in New Issue
Block a user