diff --git a/backend/appsettings/src/manual.py b/backend/appsettings/src/manual.py index 36c3c62b..4a9b4e47 100644 --- a/backend/appsettings/src/manual.py +++ b/backend/appsettings/src/manual.py @@ -14,6 +14,7 @@ import subprocess from appsettings.src.config import AppConfig from common.src.env_settings import EnvironmentSettings from common.src.helper import ignore_filelist +from download.src.queue_interact import PendingInteract from download.src.thumbnails import ThumbManager from PIL import Image from video.src.comments import Comments @@ -517,7 +518,7 @@ class ManualImport: shutil.move(old_path, new_path, copy_function=shutil.copyfile) def _cleanup(self): - """cleanup leftover files""" + """cleanup leftover files, clean up from queue""" meta_data = self.current_video["metadata"] if meta_data and os.path.exists(meta_data): os.remove(meta_data) @@ -529,3 +530,6 @@ class ManualImport: for subtitle_file in self.current_video["subtitle"]: if os.path.exists(subtitle_file): os.remove(subtitle_file) + + video_id = self.current_video["video_id"] + PendingInteract(youtube_id=video_id).delete_item(print_error=False) diff --git a/backend/common/src/es_connect.py b/backend/common/src/es_connect.py index 3ef6f9a6..a546f75b 100644 --- a/backend/common/src/es_connect.py +++ b/backend/common/src/es_connect.py @@ -118,6 +118,7 @@ class ElasticWrap: self, data: bool | dict = False, refresh: bool = False, + print_error: bool = True, ) -> tuple[dict, Any]: """delete document from es""" @@ -134,7 +135,7 @@ class ElasticWrap: response = requests.delete(self.url, **kwargs) - if not response.ok: + if print_error and not response.ok: print(response.text) return response.json(), response.status_code diff --git a/backend/download/src/queue_interact.py b/backend/download/src/queue_interact.py index 22f0f039..90c3d1b9 100644 --- a/backend/download/src/queue_interact.py +++ b/backend/download/src/queue_interact.py @@ -10,10 +10,10 @@ class PendingInteract: self.youtube_id = youtube_id self.status = status - def delete_item(self): + def delete_item(self, print_error: bool = True) -> None: """delete single item from pending""" path = f"ta_download/_doc/{self.youtube_id}" - _, _ = ElasticWrap(path).delete(refresh=True) + _, _ = ElasticWrap(path).delete(refresh=True, print_error=print_error) def delete_bulk(self, channel_id: str | None, vid_type: str | None): """delete all matching item by status"""