mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-29 03:56:43 +08:00
fix(transfer): 修复音乐整理因缺少 tmdb_id 字段崩溃
MusicInfo 不含 tmdb_id 等 60 个影视专用字段,整理链访问 task.mediainfo.tmdb_id 直接 AttributeError,导致无分类音乐自动 整理全部失败。 源头修复:为 domain 与 schemas 两层 MusicInfo 增加 __getattr__ 兜底,缺失字段返回 None,避免下游逐点安全访问;dunder 方法 除外以保持 copy/pickle 钩子探测正常。显式声明 recognize_cache_hit 字段保留 getattr(..., False) 默认值语义。
This commit is contained in:
@@ -83,6 +83,17 @@ class MusicInfo(OptionalMediaIdentityMixin, BaseModel):
|
||||
overview: Optional[str] = None
|
||||
vote_average: float = 0.0
|
||||
|
||||
def __getattr__(self, name: str) -> None:
|
||||
"""影视专用字段兜底返回 None:音乐模型不存在这些字段,避免下游逐点安全访问。
|
||||
|
||||
与 domain 层的 MusicInfo 保持一致:通知、整理等共享影视字段的读写路径
|
||||
直接访问缺失属性时按空值处理,而不是抛 AttributeError。dunder 特殊方法
|
||||
除外,避免 copy/pickle 等机制对钩子的 hasattr 探测误判。
|
||||
"""
|
||||
if name.startswith("__") and name.endswith("__"):
|
||||
raise AttributeError(name)
|
||||
return None
|
||||
|
||||
|
||||
class MusicRelease(BaseModel):
|
||||
"""音乐专辑下的单个发行版本。"""
|
||||
|
||||
Reference in New Issue
Block a user