From 8902fb50d667bb0b5333a290bfaf22673ad4a497 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 16 Jul 2025 22:22:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20context.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/context.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/app/core/context.py b/app/core/context.py index 2fcf8714..d5b26f5e 100644 --- a/app/core/context.py +++ b/app/core/context.py @@ -474,8 +474,16 @@ class MediaInfo: self.names = info.get('names') or [] # 剩余属性赋值 for key, value in info.items(): - # 属性存在、值为空且类型一致则赋值 - if hasattr(self, key) and not getattr(self, key) and type(getattr(self, key)) == type(value): + if not value: + continue + if not hasattr(self, key): + continue + current_value = getattr(self, key) + if current_value: + continue + if current_value is None: + setattr(self, key, value) + elif type(current_value) == type(value): setattr(self, key, value) def set_douban_info(self, info: dict): @@ -607,8 +615,16 @@ 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 not getattr(self, key) and type(getattr(self, key)) == type(value): + if not value: + continue + if not hasattr(self, key): + continue + current_value = getattr(self, key) + if current_value: + continue + if current_value is None: + setattr(self, key, value) + elif type(current_value) == type(value): setattr(self, key, value) def set_bangumi_info(self, info: dict):