From 87259d4c7c426626fa4b11deb5d8ccad3ec17277 Mon Sep 17 00:00:00 2001 From: projectdx Date: Fri, 2 Jan 2026 16:20:28 +0900 Subject: [PATCH] fix: Download status not updating to completed on list page --- info.yaml | 2 +- mod_anilife.py | 20 ++++++------ model_base.py | 32 +++++++++++++++++++ .../anime_downloader_anilife_search.html | 28 ++++++++++++---- 4 files changed, 66 insertions(+), 16 deletions(-) diff --git a/info.yaml b/info.yaml index 98a7f72..f16dd98 100644 --- a/info.yaml +++ b/info.yaml @@ -1,5 +1,5 @@ title: "애니 다운로더" -version: "0.4.4" +version: "0.4.5" package_name: "anime_downloader" developer: "projectdx" description: "anime downloader" diff --git a/mod_anilife.py b/mod_anilife.py index cd86c4d..95e5e88 100644 --- a/mod_anilife.py +++ b/mod_anilife.py @@ -1320,22 +1320,24 @@ class AniLifeQueueEntity(FfmpegQueueEntity): tmp["filename"] = self.filename return tmp - def donwload_completed(self): + def download_completed(self): + """Override to update DB status after download completes.""" + # Call parent's download_completed first (handles file move) + super().download_completed() + + # Update DB status db_entity = ModelAniLifeItem.get_by_anilife_id(self.info["_id"]) if db_entity is not None: db_entity.status = "completed" db_entity.completed_time = datetime.now() # 메타데이터 동기화 db_entity.filename = self.filename - db_entity.save_fullpath = self.save_fullpath - db_entity.filesize = self.filesize - db_entity.duration = self.duration - db_entity.quality = self.quality + db_entity.save_fullpath = getattr(self, 'save_fullpath', None) + db_entity.filesize = getattr(self, 'filesize', None) + db_entity.duration = getattr(self, 'duration', None) + db_entity.quality = getattr(self, 'quality', None) db_entity.save() - - # Discord 알림 (이미 메인에서 처리될 수도 있으나 명시적으로 필요한 경우) - # if self.P.ModelSetting.get_bool('anilife_discord_notification'): - # ... + logger.info(f"[Anilife] DB status updated to 'completed': {self.info.get('title', 'Unknown')}") def prepare_extra(self): """ diff --git a/model_base.py b/model_base.py index 8e4b574..b0a62f9 100644 --- a/model_base.py +++ b/model_base.py @@ -114,6 +114,7 @@ class AnimeQueueEntity(FfmpegQueueEntity): self.ffmpeg_status = 7 self.ffmpeg_status_kor = "완료" self.end_time = datetime.now() + self._update_db_status() return if self.filepath and os.path.exists(self.filepath): @@ -126,11 +127,42 @@ class AnimeQueueEntity(FfmpegQueueEntity): self.ffmpeg_status = 7 self.ffmpeg_status_kor = "완료" self.end_time = datetime.now() + self._update_db_status() except Exception as e: self.P.logger.error(f"Download completed error: {e}") self.ffmpeg_status = 4 self.ffmpeg_status_kor = "이동 실패" + def _update_db_status(self): + """Update DB status to completed - generic method for all sites.""" + try: + # Get the web_list_model from module_logic + model_class = getattr(self.module_logic, 'web_list_model', None) + if model_class is None: + return + + # Try to find the DB entity + db_entity = None + info = getattr(self, 'info', {}) + + # Anilife uses _id + if hasattr(model_class, 'get_by_anilife_id') and info.get('_id'): + db_entity = model_class.get_by_anilife_id(info['_id']) + # Linkkf/Ohli24 might use different identifiers + elif hasattr(model_class, 'get_by_id') and info.get('db_id'): + db_entity = model_class.get_by_id(info['db_id']) + elif hasattr(model_class, 'get_by_content_code') and info.get('content_code'): + db_entity = model_class.query.filter_by(content_code=info['content_code'], episode_no=info.get('episode_no')).first() + + if db_entity is not None: + db_entity.status = "completed" + db_entity.completed_time = datetime.now() + db_entity.filename = getattr(self, 'filename', None) + db_entity.save() + logger.info(f"[{self.module_logic.name}] DB status updated to 'completed': {info.get('title', 'Unknown')}") + except Exception as e: + logger.error(f"Failed to update DB status: {e}") + def info_dict(self, tmp): """Default valid implementation""" return tmp diff --git a/templates/anime_downloader_anilife_search.html b/templates/anime_downloader_anilife_search.html index bcf66e9..77ea29d 100644 --- a/templates/anime_downloader_anilife_search.html +++ b/templates/anime_downloader_anilife_search.html @@ -1229,17 +1229,33 @@ $(document).ready(function(){