commit
77a1d56c5b
@ -64,6 +64,7 @@ class PersonMeta(_PluginBase):
|
|||||||
_onlyonce = False
|
_onlyonce = False
|
||||||
_cron = None
|
_cron = None
|
||||||
_delay = 0
|
_delay = 0
|
||||||
|
_type = "all"
|
||||||
_remove_nozh = False
|
_remove_nozh = False
|
||||||
|
|
||||||
def init_plugin(self, config: dict = None):
|
def init_plugin(self, config: dict = None):
|
||||||
@ -73,6 +74,7 @@ class PersonMeta(_PluginBase):
|
|||||||
self._enabled = config.get("enabled")
|
self._enabled = config.get("enabled")
|
||||||
self._onlyonce = config.get("onlyonce")
|
self._onlyonce = config.get("onlyonce")
|
||||||
self._cron = config.get("cron")
|
self._cron = config.get("cron")
|
||||||
|
self._type = config.get("type")
|
||||||
self._delay = config.get("delay") or 0
|
self._delay = config.get("delay") or 0
|
||||||
self._remove_nozh = config.get("remove_nozh") or False
|
self._remove_nozh = config.get("remove_nozh") or False
|
||||||
|
|
||||||
@ -116,6 +118,7 @@ class PersonMeta(_PluginBase):
|
|||||||
"enabled": self._enabled,
|
"enabled": self._enabled,
|
||||||
"onlyonce": self._onlyonce,
|
"onlyonce": self._onlyonce,
|
||||||
"cron": self._cron,
|
"cron": self._cron,
|
||||||
|
"type": self._type,
|
||||||
"delay": self._delay,
|
"delay": self._delay,
|
||||||
"remove_nozh": self._remove_nozh
|
"remove_nozh": self._remove_nozh
|
||||||
})
|
})
|
||||||
@ -182,7 +185,7 @@ class PersonMeta(_PluginBase):
|
|||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 6
|
'md': 4
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
@ -199,7 +202,7 @@ class PersonMeta(_PluginBase):
|
|||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 6
|
'md': 4
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
@ -211,6 +214,27 @@ class PersonMeta(_PluginBase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'component': 'VCol',
|
||||||
|
'props': {
|
||||||
|
'cols': 12,
|
||||||
|
'md': 4
|
||||||
|
},
|
||||||
|
'content': [
|
||||||
|
{
|
||||||
|
'component': 'VSelect',
|
||||||
|
'props': {
|
||||||
|
'model': 'type',
|
||||||
|
'label': '刮削条件',
|
||||||
|
'items': [
|
||||||
|
{'title': '演员非中文', 'value': 'name'},
|
||||||
|
{'title': '角色非中文', 'value': 'role'},
|
||||||
|
{'title': '任一非中文', 'value': 'all'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -241,6 +265,7 @@ class PersonMeta(_PluginBase):
|
|||||||
"enabled": False,
|
"enabled": False,
|
||||||
"onlyonce": False,
|
"onlyonce": False,
|
||||||
"cron": "",
|
"cron": "",
|
||||||
|
"type": "all",
|
||||||
"delay": 30,
|
"delay": 30,
|
||||||
"remove_nozh": False
|
"remove_nozh": False
|
||||||
}
|
}
|
||||||
@ -350,10 +375,22 @@ class PersonMeta(_PluginBase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __need_trans_actor(_item):
|
def __need_trans_actor(_item):
|
||||||
# 是否需要处理人物信息
|
if self._type == "all":
|
||||||
_peoples = [x for x in _item.get("People", []) if
|
# 是否需要处理人物信息
|
||||||
(x.get("Name") and not StringUtils.is_chinese(x.get("Name")))
|
_peoples = [x for x in _item.get("People", []) if
|
||||||
or (x.get("Role") and not StringUtils.is_chinese(x.get("Role")))]
|
(x.get("Name") and not StringUtils.is_chinese(x.get("Name")))
|
||||||
|
or (x.get("Role") and not StringUtils.is_chinese(x.get("Role")))]
|
||||||
|
elif self._type == "name":
|
||||||
|
# 是否需要处理人物名称
|
||||||
|
_peoples = [x for x in _item.get("People", []) if
|
||||||
|
(x.get("Name") and not StringUtils.is_chinese(x.get("Name")))]
|
||||||
|
elif self._type == "role":
|
||||||
|
# 是否需要处理人物角色
|
||||||
|
_peoples = [x for x in _item.get("People", []) if
|
||||||
|
(x.get("Role") and not StringUtils.is_chinese(x.get("Role")))]
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
if _peoples:
|
if _peoples:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -456,7 +493,7 @@ class PersonMeta(_PluginBase):
|
|||||||
# 查询媒体库人物详情
|
# 查询媒体库人物详情
|
||||||
personinfo = self.get_iteminfo(server=server, itemid=people.get("Id"))
|
personinfo = self.get_iteminfo(server=server, itemid=people.get("Id"))
|
||||||
if not personinfo:
|
if not personinfo:
|
||||||
logger.warn(f"未找到人物 {people.get('Name')} 的信息")
|
logger.debug(f"未找到人物 {people.get('Name')} 的信息")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 是否更新标志
|
# 是否更新标志
|
||||||
@ -473,20 +510,20 @@ class PersonMeta(_PluginBase):
|
|||||||
cn_name = self.__get_chinese_name(person_tmdbinfo)
|
cn_name = self.__get_chinese_name(person_tmdbinfo)
|
||||||
if cn_name:
|
if cn_name:
|
||||||
# 更新中文名
|
# 更新中文名
|
||||||
logger.info(f"{people.get('Name')} 从TMDB获取到中文名:{cn_name}")
|
logger.debug(f"{people.get('Name')} 从TMDB获取到中文名:{cn_name}")
|
||||||
personinfo["Name"] = cn_name
|
personinfo["Name"] = cn_name
|
||||||
ret_people["Name"] = cn_name
|
ret_people["Name"] = cn_name
|
||||||
updated_name = True
|
updated_name = True
|
||||||
# 更新中文描述
|
# 更新中文描述
|
||||||
biography = person_tmdbinfo.get("biography")
|
biography = person_tmdbinfo.get("biography")
|
||||||
if biography and StringUtils.is_chinese(biography):
|
if biography and StringUtils.is_chinese(biography):
|
||||||
logger.info(f"{people.get('Name')} 从TMDB获取到中文描述")
|
logger.debug(f"{people.get('Name')} 从TMDB获取到中文描述")
|
||||||
personinfo["Overview"] = biography
|
personinfo["Overview"] = biography
|
||||||
updated_overview = True
|
updated_overview = True
|
||||||
# 图片
|
# 图片
|
||||||
profile_path = person_tmdbinfo.get('profile_path')
|
profile_path = person_tmdbinfo.get('profile_path')
|
||||||
if profile_path:
|
if profile_path:
|
||||||
logger.info(f"{people.get('Name')} 从TMDB获取到图片:{profile_path}")
|
logger.debug(f"{people.get('Name')} 从TMDB获取到图片:{profile_path}")
|
||||||
profile_path = f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original{profile_path}"
|
profile_path = f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original{profile_path}"
|
||||||
|
|
||||||
# 从豆瓣信息中更新人物信息
|
# 从豆瓣信息中更新人物信息
|
||||||
@ -522,14 +559,14 @@ class PersonMeta(_PluginBase):
|
|||||||
or douban_actor.get("name") == people.get("Name"):
|
or douban_actor.get("name") == people.get("Name"):
|
||||||
# 名称
|
# 名称
|
||||||
if not updated_name:
|
if not updated_name:
|
||||||
logger.info(f"{people.get('Name')} 从豆瓣中获取到中文名:{douban_actor.get('name')}")
|
logger.debug(f"{people.get('Name')} 从豆瓣中获取到中文名:{douban_actor.get('name')}")
|
||||||
personinfo["Name"] = douban_actor.get("name")
|
personinfo["Name"] = douban_actor.get("name")
|
||||||
ret_people["Name"] = douban_actor.get("name")
|
ret_people["Name"] = douban_actor.get("name")
|
||||||
updated_name = True
|
updated_name = True
|
||||||
# 描述
|
# 描述
|
||||||
if not updated_overview:
|
if not updated_overview:
|
||||||
if douban_actor.get("title"):
|
if douban_actor.get("title"):
|
||||||
logger.info(f"{people.get('Name')} 从豆瓣中获取到中文描述:{douban_actor.get('title')}")
|
logger.debug(f"{people.get('Name')} 从豆瓣中获取到中文描述:{douban_actor.get('title')}")
|
||||||
personinfo["Overview"] = douban_actor.get("title")
|
personinfo["Overview"] = douban_actor.get("title")
|
||||||
updated_overview = True
|
updated_overview = True
|
||||||
# 饰演角色
|
# 饰演角色
|
||||||
@ -541,20 +578,20 @@ class PersonMeta(_PluginBase):
|
|||||||
character = re.sub("演员", "",
|
character = re.sub("演员", "",
|
||||||
character)
|
character)
|
||||||
if character:
|
if character:
|
||||||
logger.info(f"{people.get('Name')} 从豆瓣中获取到饰演角色:{character}")
|
logger.debug(f"{people.get('Name')} 从豆瓣中获取到饰演角色:{character}")
|
||||||
ret_people["Role"] = character
|
ret_people["Role"] = character
|
||||||
update_character = True
|
update_character = True
|
||||||
# 图片
|
# 图片
|
||||||
if not profile_path:
|
if not profile_path:
|
||||||
avatar = douban_actor.get("avatar") or {}
|
avatar = douban_actor.get("avatar") or {}
|
||||||
if avatar.get("large"):
|
if avatar.get("large"):
|
||||||
logger.info(f"{people.get('Name')} 从豆瓣中获取到图片:{avatar.get('large')}")
|
logger.debug(f"{people.get('Name')} 从豆瓣中获取到图片:{avatar.get('large')}")
|
||||||
profile_path = avatar.get("large")
|
profile_path = avatar.get("large")
|
||||||
break
|
break
|
||||||
|
|
||||||
# 更新人物图片
|
# 更新人物图片
|
||||||
if profile_path:
|
if profile_path:
|
||||||
logger.info(f"更新人物 {people.get('Name')} 的图片:{profile_path}")
|
logger.debug(f"更新人物 {people.get('Name')} 的图片:{profile_path}")
|
||||||
self.set_item_image(server=server, itemid=people.get("Id"), imageurl=profile_path)
|
self.set_item_image(server=server, itemid=people.get("Id"), imageurl=profile_path)
|
||||||
|
|
||||||
# 锁定人物信息
|
# 锁定人物信息
|
||||||
@ -567,12 +604,12 @@ class PersonMeta(_PluginBase):
|
|||||||
|
|
||||||
# 更新人物信息
|
# 更新人物信息
|
||||||
if updated_name or updated_overview or update_character:
|
if updated_name or updated_overview or update_character:
|
||||||
logger.info(f"更新人物 {people.get('Name')} 的信息:{personinfo}")
|
logger.debug(f"更新人物 {people.get('Name')} 的信息:{personinfo}")
|
||||||
ret = self.set_iteminfo(server=server, itemid=people.get("Id"), iteminfo=personinfo)
|
ret = self.set_iteminfo(server=server, itemid=people.get("Id"), iteminfo=personinfo)
|
||||||
if ret:
|
if ret:
|
||||||
return ret_people
|
return ret_people
|
||||||
else:
|
else:
|
||||||
logger.info(f"人物 {people.get('Name')} 未找到中文数据")
|
logger.debug(f"人物 {people.get('Name')} 未找到中文数据")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"更新人物信息失败:{err}")
|
logger.error(f"更新人物信息失败:{err}")
|
||||||
return None
|
return None
|
||||||
@ -583,7 +620,7 @@ class PersonMeta(_PluginBase):
|
|||||||
"""
|
"""
|
||||||
# 随机休眠 3-10 秒
|
# 随机休眠 3-10 秒
|
||||||
sleep_time = 3 + int(time.time()) % 7
|
sleep_time = 3 + int(time.time()) % 7
|
||||||
logger.info(f"随机休眠 {sleep_time}秒 ...")
|
logger.debug(f"随机休眠 {sleep_time}秒 ...")
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
# 匹配豆瓣信息
|
# 匹配豆瓣信息
|
||||||
doubaninfo = self.chain.match_doubaninfo(name=mediainfo.title,
|
doubaninfo = self.chain.match_doubaninfo(name=mediainfo.title,
|
||||||
@ -596,7 +633,7 @@ class PersonMeta(_PluginBase):
|
|||||||
doubanitem = self.chain.douban_info(doubaninfo.get("id")) or {}
|
doubanitem = self.chain.douban_info(doubaninfo.get("id")) or {}
|
||||||
return (doubanitem.get("actors") or []) + (doubanitem.get("directors") or [])
|
return (doubanitem.get("actors") or []) + (doubanitem.get("directors") or [])
|
||||||
else:
|
else:
|
||||||
logger.warn(f"未找到豆瓣信息:{mediainfo.title_year}")
|
logger.debug(f"未找到豆瓣信息:{mediainfo.title_year}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -882,7 +919,7 @@ class PersonMeta(_PluginBase):
|
|||||||
if r:
|
if r:
|
||||||
return base64.b64encode(r.content).decode()
|
return base64.b64encode(r.content).decode()
|
||||||
else:
|
else:
|
||||||
logger.info(f"{imageurl} 图片下载失败,请检查网络连通性")
|
logger.warn(f"{imageurl} 图片下载失败,请检查网络连通性")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"下载图片失败:{err}")
|
logger.error(f"下载图片失败:{err}")
|
||||||
return None
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user