mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-19 22:14:28 +08:00
feat: expand metadata sources and media server sync (#6129)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
from functools import lru_cache
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from app.core.config import settings
|
||||
@@ -214,6 +215,29 @@ def find_metainfo(title: str) -> Optional[dict]:
|
||||
return None
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def supports_extended_media_ids() -> bool:
|
||||
"""
|
||||
判断当前 Rust 扩展是否支持 Bangumi 与 AniList 显式媒体标签。
|
||||
|
||||
:return: 是否支持扩展数据源ID字段
|
||||
"""
|
||||
if not is_enabled():
|
||||
return False
|
||||
try:
|
||||
result = _moviepilot_rust.find_metainfo_fast("test [anilist=1]")
|
||||
except BaseException as err:
|
||||
_raise_non_rust_panic(err)
|
||||
logger.debug(f"检测 Rust 扩展数据源ID能力失败:{err}")
|
||||
return False
|
||||
metainfo = result.get("metainfo") if isinstance(result, dict) else None
|
||||
return bool(
|
||||
metainfo
|
||||
and metainfo.get("media_source") == "anilist"
|
||||
and metainfo.get("media_id") == "1"
|
||||
)
|
||||
|
||||
|
||||
def _raise_non_rust_panic(err: BaseException) -> None:
|
||||
"""
|
||||
只吞掉 Rust 扩展 panic/异常,保留用户中断和进程退出语义。
|
||||
|
||||
Reference in New Issue
Block a user