delete from queue on manual import

This commit is contained in:
Simon 2026-08-07 11:46:47 +07:00
parent e5b802e2f2
commit 7dcb43f436
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 9 additions and 4 deletions

View File

@ -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)

View File

@ -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

View File

@ -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"""