refactor: streamline media recognition by removing MetaInfoPath usage

This commit is contained in:
jxxghp
2026-05-10 09:26:13 +08:00
parent 4d132c424a
commit 79eb128196
6 changed files with 45 additions and 48 deletions

View File

@@ -10,7 +10,6 @@ from app.chain.media import MediaChain
from app.chain.storage import StorageChain
from app.chain.transfer import TransferChain
from app.core.config import settings
from app.core.metainfo import MetaInfoPath
from app.core.security import verify_token
from app.db.models import User
from app.db.user_oper import get_current_active_superuser, get_current_active_superuser_async
@@ -199,15 +198,17 @@ def rename(fileitem: schemas.FileItem,
if f".{sub_file.extension.lower()}" not in media_exts:
continue
sub_path = Path(f"{fileitem.path}{sub_file.name}")
meta = MetaInfoPath(sub_path)
mediainfo = MediaChain().recognize_by_meta(
meta,
context = MediaChain().recognize_by_path(
sub_path,
obtain_images=False,
)
if not mediainfo:
if not context or not context.media_info:
progress.end()
return schemas.Response(success=False, message=f"{sub_path.name} 未识别到媒体信息")
new_path = transferchain.recommend_name(meta=meta, mediainfo=mediainfo)
new_path = transferchain.recommend_name(
meta=context.meta_info,
mediainfo=context.media_info
)
if not new_path:
progress.end()
return schemas.Response(success=False, message=f"{sub_path.name} 未识别到新名称")