mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix(meta): satisfy parser type ratchet
This commit is contained in:
@@ -94,8 +94,8 @@ class MetaInfoSnapshot:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_meta(cls, meta: "MetaBase") -> "MetaInfoSnapshot":
|
def from_meta(cls, meta: "MetaBase") -> "MetaInfoSnapshot":
|
||||||
"""从兼容的可变 MetaBase 对象提取不包含临时状态的完整契约。"""
|
"""从兼容的可变 MetaBase 对象提取不包含临时状态的完整契约。"""
|
||||||
media_type = getattr(meta.type, "value", meta.type)
|
media_type = meta.type.value if meta.type else ""
|
||||||
media_source = getattr(meta.media_source, "value", meta.media_source)
|
media_source = meta.media_source.value if meta.media_source else None
|
||||||
return cls(
|
return cls(
|
||||||
kind="anime" if type(meta).__name__ == "MetaAnime" else "video",
|
kind="anime" if type(meta).__name__ == "MetaAnime" else "video",
|
||||||
isfile=bool(meta.isfile),
|
isfile=bool(meta.isfile),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import logging
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import Mapping, Tuple, List, Optional
|
from typing import Any, Mapping, Tuple, List, Optional
|
||||||
|
|
||||||
import regex as re
|
import regex as re
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class _PreparedMetaInput:
|
|||||||
subtitle: Optional[str]
|
subtitle: Optional[str]
|
||||||
isfile: bool
|
isfile: bool
|
||||||
apply_words: tuple[str, ...]
|
apply_words: tuple[str, ...]
|
||||||
explicit_metainfo: Mapping[str, object]
|
explicit_metainfo: Mapping[str, Any]
|
||||||
|
|
||||||
|
|
||||||
def _empty_metainfo() -> dict:
|
def _empty_metainfo() -> dict:
|
||||||
@@ -279,7 +279,7 @@ def _find_metainfo_python(title: str) -> Tuple[str, dict]:
|
|||||||
def _prepare_meta_input(
|
def _prepare_meta_input(
|
||||||
title: str,
|
title: str,
|
||||||
subtitle: Optional[str] = None,
|
subtitle: Optional[str] = None,
|
||||||
custom_words: List[str] = None,
|
custom_words: Optional[List[str]] = None,
|
||||||
) -> _PreparedMetaInput:
|
) -> _PreparedMetaInput:
|
||||||
"""
|
"""
|
||||||
应用识别词、显式标签和文件后缀规则,生成稳定的解析阶段输入。
|
应用识别词、显式标签和文件后缀规则,生成稳定的解析阶段输入。
|
||||||
@@ -305,7 +305,7 @@ def _prepare_meta_input(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _apply_explicit_metainfo(meta: MetaBase, metainfo: Mapping[str, object]) -> None:
|
def _apply_explicit_metainfo(meta: MetaBase, metainfo: Mapping[str, Any]) -> None:
|
||||||
"""以显式标签覆盖推断字段,保持用户声明拥有最高优先级。"""
|
"""以显式标签覆盖推断字段,保持用户声明拥有最高优先级。"""
|
||||||
media_source, media_id = resolve_media_identity(media=dict(metainfo))
|
media_source, media_id = resolve_media_identity(media=dict(metainfo))
|
||||||
if media_source and media_id:
|
if media_source and media_id:
|
||||||
@@ -332,7 +332,7 @@ def _apply_explicit_metainfo(meta: MetaBase, metainfo: Mapping[str, object]) ->
|
|||||||
def _build_meta_info(
|
def _build_meta_info(
|
||||||
title: str,
|
title: str,
|
||||||
subtitle: Optional[str] = None,
|
subtitle: Optional[str] = None,
|
||||||
custom_words: List[str] = None,
|
custom_words: Optional[List[str]] = None,
|
||||||
) -> MetaBase:
|
) -> MetaBase:
|
||||||
"""按准备、分类解析、显式覆盖三个阶段构造 Python MetaInfo。"""
|
"""按准备、分类解析、显式覆盖三个阶段构造 Python MetaInfo。"""
|
||||||
prepared = _prepare_meta_input(title, subtitle, custom_words)
|
prepared = _prepare_meta_input(title, subtitle, custom_words)
|
||||||
@@ -354,7 +354,7 @@ def _build_meta_info(
|
|||||||
def _build_python_meta_info(
|
def _build_python_meta_info(
|
||||||
title: str,
|
title: str,
|
||||||
subtitle: Optional[str] = None,
|
subtitle: Optional[str] = None,
|
||||||
custom_words: List[str] = None,
|
custom_words: Optional[List[str]] = None,
|
||||||
) -> MetaBase:
|
) -> MetaBase:
|
||||||
"""构造并完成 original_name 的纯 Python 参考解析结果。"""
|
"""构造并完成 original_name 的纯 Python 参考解析结果。"""
|
||||||
meta = _build_meta_info(title=title, subtitle=subtitle, custom_words=custom_words)
|
meta = _build_meta_info(title=title, subtitle=subtitle, custom_words=custom_words)
|
||||||
|
|||||||
Reference in New Issue
Block a user