diff --git a/tubearchivist/home/src/download/queue.py b/tubearchivist/home/src/download/queue.py index 72c7d25b..5a453ecc 100644 --- a/tubearchivist/home/src/download/queue.py +++ b/tubearchivist/home/src/download/queue.py @@ -242,6 +242,9 @@ class PendingList(PendingIndex): total = len(self.missing_videos) for idx, (youtube_id, vid_type) in enumerate(self.missing_videos): + if self.task and self.task.is_stopped(): + break + print(f"{youtube_id}: [{idx + 1}/{total}]: add to queue") self._notify_add(idx, total) video_details = self.get_youtube_details(youtube_id, vid_type) diff --git a/tubearchivist/home/src/index/comments.py b/tubearchivist/home/src/index/comments.py index cbc011a3..1cbe75a1 100644 --- a/tubearchivist/home/src/index/comments.py +++ b/tubearchivist/home/src/index/comments.py @@ -206,5 +206,4 @@ class CommentList: """send notification on task""" message = [f"Add comments for new videos {idx + 1}/{total_videos}"] progress = (idx + 1) / total_videos - title = "Index Comments" - self.task.send_progress(message, progress=progress, title=title) + self.task.send_progress(message, progress=progress) diff --git a/tubearchivist/home/src/ta/task_manager.py b/tubearchivist/home/src/ta/task_manager.py index 7c3d124c..3771fdd6 100644 --- a/tubearchivist/home/src/ta/task_manager.py +++ b/tubearchivist/home/src/ta/task_manager.py @@ -72,6 +72,9 @@ class TaskManager: run at startup to recover from hard reset """ all_results = self.get_all_results() + if not all_results: + return + for result in all_results: if result.get("status") == "PENDING": result["status"] = "FAILED" diff --git a/tubearchivist/home/tasks.py b/tubearchivist/home/tasks.py index d61f9b47..f2c5341e 100644 --- a/tubearchivist/home/tasks.py +++ b/tubearchivist/home/tasks.py @@ -63,6 +63,7 @@ class BaseTask(Task): "extract_download": { "title": "Add to download queue", "group": "download:add", + "api-stop": True, }, "check_reindex": { "title": "Reindex Documents", @@ -195,6 +196,7 @@ def download_pending(self, from_queue=True): @shared_task(name="extract_download", bind=True, base=BaseTask) def extrac_dl(self, youtube_ids): """parse list passed and add to pending""" + TaskManager().init(self) pending_handler = PendingList(youtube_ids=youtube_ids, task=self) pending_handler.parse_url_list() pending_handler.add_to_pending()