mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
更新 context.py
This commit is contained in:
+20
-4
@@ -474,8 +474,16 @@ class MediaInfo:
|
|||||||
self.names = info.get('names') or []
|
self.names = info.get('names') or []
|
||||||
# 剩余属性赋值
|
# 剩余属性赋值
|
||||||
for key, value in info.items():
|
for key, value in info.items():
|
||||||
# 属性存在、值为空且类型一致则赋值
|
if not value:
|
||||||
if hasattr(self, key) and not getattr(self, key) and type(getattr(self, key)) == type(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)
|
setattr(self, key, value)
|
||||||
|
|
||||||
def set_douban_info(self, info: dict):
|
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 []]
|
self.production_countries = [{"id": country, "name": country} for country in info.get("countries") or []]
|
||||||
# 剩余属性赋值
|
# 剩余属性赋值
|
||||||
for key, value in info.items():
|
for key, value in info.items():
|
||||||
# 属性存在、值为空且类型一致则赋值
|
if not value:
|
||||||
if hasattr(self, key) and not getattr(self, key) and type(getattr(self, key)) == type(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)
|
setattr(self, key, value)
|
||||||
|
|
||||||
def set_bangumi_info(self, info: dict):
|
def set_bangumi_info(self, info: dict):
|
||||||
|
|||||||
Reference in New Issue
Block a user