mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
refactor(media): unify media identity and chain responsibilities
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union
|
||||
|
||||
from app.chain import ChainBase
|
||||
|
||||
|
||||
class AcoustIdChain(ChainBase):
|
||||
"""AcoustID 音频指纹识别来源链。"""
|
||||
|
||||
def identify_music_by_fingerprint(
|
||||
self,
|
||||
path: Union[str, Path],
|
||||
) -> Optional[str]:
|
||||
"""根据本地音频指纹返回 MusicBrainz Recording ID。"""
|
||||
result = self.run_module(
|
||||
"identify_music_by_fingerprint",
|
||||
path=Path(path),
|
||||
)
|
||||
return str(result).strip() if result else None
|
||||
|
||||
async def async_identify_music_by_fingerprint(
|
||||
self,
|
||||
path: Union[str, Path],
|
||||
) -> Optional[str]:
|
||||
"""异步根据本地音频指纹返回 MusicBrainz Recording ID。"""
|
||||
result = await self.async_run_module(
|
||||
"async_identify_music_by_fingerprint",
|
||||
path=Path(path),
|
||||
)
|
||||
return str(result).strip() if result else None
|
||||
Reference in New Issue
Block a user