mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2024-12-22 18:00:13 +00:00
add to queue notification, #714
This commit is contained in:
parent
320ead0bd2
commit
fd039de53d
@ -245,6 +245,7 @@ class PendingList(PendingIndex):
|
|||||||
bulk_list = []
|
bulk_list = []
|
||||||
|
|
||||||
total = len(self.missing_videos)
|
total = len(self.missing_videos)
|
||||||
|
videos_added = []
|
||||||
for idx, (youtube_id, vid_type) in enumerate(self.missing_videos):
|
for idx, (youtube_id, vid_type) in enumerate(self.missing_videos):
|
||||||
if self.task and self.task.is_stopped():
|
if self.task and self.task.is_stopped():
|
||||||
break
|
break
|
||||||
@ -268,6 +269,7 @@ class PendingList(PendingIndex):
|
|||||||
|
|
||||||
url = video_details["vid_thumb_url"]
|
url = video_details["vid_thumb_url"]
|
||||||
ThumbManager(youtube_id).download_video_thumb(url)
|
ThumbManager(youtube_id).download_video_thumb(url)
|
||||||
|
videos_added.append(youtube_id)
|
||||||
|
|
||||||
if len(bulk_list) >= 20:
|
if len(bulk_list) >= 20:
|
||||||
self._ingest_bulk(bulk_list)
|
self._ingest_bulk(bulk_list)
|
||||||
@ -275,6 +277,8 @@ class PendingList(PendingIndex):
|
|||||||
|
|
||||||
self._ingest_bulk(bulk_list)
|
self._ingest_bulk(bulk_list)
|
||||||
|
|
||||||
|
return videos_added
|
||||||
|
|
||||||
def _ingest_bulk(self, bulk_list):
|
def _ingest_bulk(self, bulk_list):
|
||||||
"""add items to queue in bulk"""
|
"""add items to queue in bulk"""
|
||||||
if not bulk_list:
|
if not bulk_list:
|
||||||
|
@ -90,7 +90,7 @@ class DownloadPostProcess:
|
|||||||
vids = [{"type": "video", "url": i["youtube_id"]} for i in to_delete]
|
vids = [{"type": "video", "url": i["youtube_id"]} for i in to_delete]
|
||||||
pending = PendingList(youtube_ids=vids)
|
pending = PendingList(youtube_ids=vids)
|
||||||
pending.parse_url_list()
|
pending.parse_url_list()
|
||||||
pending.add_to_pending(status="ignore")
|
_ = pending.add_to_pending(status="ignore")
|
||||||
|
|
||||||
def validate_playlists(self):
|
def validate_playlists(self):
|
||||||
"""look for playlist needing to update"""
|
"""look for playlist needing to update"""
|
||||||
|
@ -6,6 +6,7 @@ Functionality:
|
|||||||
|
|
||||||
from celery.schedules import crontab
|
from celery.schedules import crontab
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from home.src.ta.task_config import TASK_CONFIG
|
||||||
|
|
||||||
|
|
||||||
class CrontabValidator:
|
class CrontabValidator:
|
||||||
@ -78,12 +79,17 @@ class SchedulerSettingsForm(forms.Form):
|
|||||||
class NotificationSettingsForm(forms.Form):
|
class NotificationSettingsForm(forms.Form):
|
||||||
"""add notification URL"""
|
"""add notification URL"""
|
||||||
|
|
||||||
TASK_CHOICES = [
|
SUPPORTED_TASKS = [
|
||||||
("", "-- select task --"),
|
"update_subscribed",
|
||||||
("update_subscribed", "Rescan your Subscriptions"),
|
"extract_download",
|
||||||
("download_pending", "Downloading"),
|
"download_pending",
|
||||||
("check_reindex", "Reindex Documents"),
|
"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"
|
PLACEHOLDER = "Apprise notification URL"
|
||||||
|
|
||||||
task = forms.ChoiceField(
|
task = forms.ChoiceField(
|
||||||
|
@ -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 = PendingList(youtube_ids=to_add, task=self)
|
||||||
pending_handler.parse_url_list()
|
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:
|
if auto_start:
|
||||||
download_pending.delay(auto_only=True)
|
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)
|
@shared_task(bind=True, name="check_reindex", base=BaseTask)
|
||||||
def check_reindex(self, data=False, extract_videos=False):
|
def check_reindex(self, data=False, extract_videos=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user