add to queue notification, #714

This commit is contained in:
Simon 2024-05-11 11:10:26 +02:00
parent 320ead0bd2
commit fd039de53d
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
4 changed files with 24 additions and 7 deletions

View File

@ -245,6 +245,7 @@ class PendingList(PendingIndex):
bulk_list = []
total = len(self.missing_videos)
videos_added = []
for idx, (youtube_id, vid_type) in enumerate(self.missing_videos):
if self.task and self.task.is_stopped():
break
@ -268,6 +269,7 @@ class PendingList(PendingIndex):
url = video_details["vid_thumb_url"]
ThumbManager(youtube_id).download_video_thumb(url)
videos_added.append(youtube_id)
if len(bulk_list) >= 20:
self._ingest_bulk(bulk_list)
@ -275,6 +277,8 @@ class PendingList(PendingIndex):
self._ingest_bulk(bulk_list)
return videos_added
def _ingest_bulk(self, bulk_list):
"""add items to queue in bulk"""
if not bulk_list:

View File

@ -90,7 +90,7 @@ class DownloadPostProcess:
vids = [{"type": "video", "url": i["youtube_id"]} for i in to_delete]
pending = PendingList(youtube_ids=vids)
pending.parse_url_list()
pending.add_to_pending(status="ignore")
_ = pending.add_to_pending(status="ignore")
def validate_playlists(self):
"""look for playlist needing to update"""

View File

@ -6,6 +6,7 @@ Functionality:
from celery.schedules import crontab
from django import forms
from home.src.ta.task_config import TASK_CONFIG
class CrontabValidator:
@ -78,12 +79,17 @@ class SchedulerSettingsForm(forms.Form):
class NotificationSettingsForm(forms.Form):
"""add notification URL"""
TASK_CHOICES = [
("", "-- select task --"),
("update_subscribed", "Rescan your Subscriptions"),
("download_pending", "Downloading"),
("check_reindex", "Reindex Documents"),
SUPPORTED_TASKS = [
"update_subscribed",
"extract_download",
"download_pending",
"check_reindex",
]
TASK_LIST = [(i, TASK_CONFIG[i]["title"]) for i in SUPPORTED_TASKS]
TASK_CHOICES = [("", "-- select task --")]
TASK_CHOICES.extend(TASK_LIST)
PLACEHOLDER = "Apprise notification URL"
task = forms.ChoiceField(

View File

@ -144,11 +144,18 @@ def extrac_dl(self, youtube_ids, auto_start=False, status="pending"):
pending_handler = PendingList(youtube_ids=to_add, task=self)
pending_handler.parse_url_list()
pending_handler.add_to_pending(status=status, auto_start=auto_start)
videos_added = pending_handler.add_to_pending(
status=status, auto_start=auto_start
)
if auto_start:
download_pending.delay(auto_only=True)
if videos_added:
return f"added {len(videos_added)} Videos to Queue"
return None
@shared_task(bind=True, name="check_reindex", base=BaseTask)
def check_reindex(self, data=False, extract_videos=False):