fix: Download status not updating to completed on list page

This commit is contained in:
2026-01-02 16:20:28 +09:00
parent a58ae36a3f
commit 87259d4c7c
4 changed files with 66 additions and 16 deletions

View File

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