From 034b43bf70a62659a7fb502567dd54a9b19dbc73 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 16 Jul 2025 19:59:06 +0800 Subject: [PATCH] fix context --- app/core/context.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/core/context.py b/app/core/context.py index 2a55a095..2fcf8714 100644 --- a/app/core/context.py +++ b/app/core/context.py @@ -474,7 +474,8 @@ class MediaInfo: self.names = info.get('names') or [] # 剩余属性赋值 for key, value in info.items(): - if hasattr(self, key) and getattr(self, key) is None: + # 属性存在、值为空且类型一致则赋值 + if hasattr(self, key) and not getattr(self, key) and type(getattr(self, key)) == type(value): setattr(self, key, value) def set_douban_info(self, info: dict): @@ -606,7 +607,8 @@ class MediaInfo: self.production_countries = [{"id": country, "name": country} for country in info.get("countries") or []] # 剩余属性赋值 for key, value in info.items(): - if hasattr(self, key) and getattr(self, key) is None: + # 属性存在、值为空且类型一致则赋值 + if hasattr(self, key) and not getattr(self, key) and type(getattr(self, key)) == type(value): setattr(self, key, value) def set_bangumi_info(self, info: dict):