mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-09 01:16:50 +08:00
fix(media): add support for custom words in media recognition
This commit is contained in:
@@ -26,13 +26,17 @@ router = APIRouter()
|
|||||||
async def recognize(
|
async def recognize(
|
||||||
title: str,
|
title: str,
|
||||||
subtitle: Optional[str] = None,
|
subtitle: Optional[str] = None,
|
||||||
|
custom_words: Optional[str] = None,
|
||||||
_: schemas.TokenPayload = Depends(verify_token),
|
_: schemas.TokenPayload = Depends(verify_token),
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""
|
"""
|
||||||
根据标题、副标题识别媒体信息
|
根据标题、副标题识别媒体信息
|
||||||
|
:param custom_words: 临时识别词(每行一条规则),传入时仅在本次识别中生效,不会保存到系统配置
|
||||||
"""
|
"""
|
||||||
# 识别媒体信息
|
# 识别媒体信息,传入临时识别词时优先于系统配置的识别词生效
|
||||||
metainfo = MetaInfo(title, subtitle)
|
metainfo = MetaInfo(
|
||||||
|
title, subtitle, custom_words=custom_words.split("\n") if custom_words else None
|
||||||
|
)
|
||||||
mediainfo = await MediaChain().async_recognize_by_meta(metainfo)
|
mediainfo = await MediaChain().async_recognize_by_meta(metainfo)
|
||||||
if mediainfo:
|
if mediainfo:
|
||||||
return Context(meta_info=metainfo, media_info=mediainfo).to_dict()
|
return Context(meta_info=metainfo, media_info=mediainfo).to_dict()
|
||||||
@@ -48,12 +52,13 @@ async def recognize2(
|
|||||||
_: Annotated[str, Depends(verify_apitoken)],
|
_: Annotated[str, Depends(verify_apitoken)],
|
||||||
title: str,
|
title: str,
|
||||||
subtitle: Optional[str] = None,
|
subtitle: Optional[str] = None,
|
||||||
|
custom_words: Optional[str] = None,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""
|
"""
|
||||||
根据标题、副标题识别媒体信息 API_TOKEN认证(?token=xxx)
|
根据标题、副标题识别媒体信息 API_TOKEN认证(?token=xxx)
|
||||||
"""
|
"""
|
||||||
# 识别媒体信息
|
# 识别媒体信息
|
||||||
return await recognize(title, subtitle)
|
return await recognize(title, subtitle, custom_words)
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
|
|||||||
Reference in New Issue
Block a user