diff --git a/app/plugins/personmeta/__init__.py b/app/plugins/personmeta/__init__.py index debff1ff..884eaa50 100644 --- a/app/plugins/personmeta/__init__.py +++ b/app/plugins/personmeta/__init__.py @@ -64,6 +64,7 @@ class PersonMeta(_PluginBase): _onlyonce = False _cron = None _delay = 0 + _type = "all" _remove_nozh = False def init_plugin(self, config: dict = None): @@ -73,6 +74,7 @@ class PersonMeta(_PluginBase): self._enabled = config.get("enabled") self._onlyonce = config.get("onlyonce") self._cron = config.get("cron") + self._type = config.get("type") self._delay = config.get("delay") or 0 self._remove_nozh = config.get("remove_nozh") or False @@ -116,6 +118,7 @@ class PersonMeta(_PluginBase): "enabled": self._enabled, "onlyonce": self._onlyonce, "cron": self._cron, + "type": self._type, "delay": self._delay, "remove_nozh": self._remove_nozh }) @@ -182,7 +185,7 @@ class PersonMeta(_PluginBase): 'component': 'VCol', 'props': { 'cols': 12, - 'md': 6 + 'md': 4 }, 'content': [ { @@ -199,7 +202,7 @@ class PersonMeta(_PluginBase): 'component': 'VCol', 'props': { 'cols': 12, - 'md': 6 + 'md': 4 }, '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, "onlyonce": False, "cron": "", + "type": "all", "delay": 30, "remove_nozh": False } @@ -350,10 +375,22 @@ class PersonMeta(_PluginBase): """ def __need_trans_actor(_item): - # 是否需要处理人物信息 - _peoples = [x for x in _item.get("People", []) if - (x.get("Name") and not StringUtils.is_chinese(x.get("Name"))) - or (x.get("Role") and not StringUtils.is_chinese(x.get("Role")))] + if self._type == "all": + # 是否需要处理人物信息 + _peoples = [x for x in _item.get("People", []) if + (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: return True return False @@ -456,7 +493,7 @@ class PersonMeta(_PluginBase): # 查询媒体库人物详情 personinfo = self.get_iteminfo(server=server, itemid=people.get("Id")) if not personinfo: - logger.warn(f"未找到人物 {people.get('Name')} 的信息") + logger.debug(f"未找到人物 {people.get('Name')} 的信息") return None # 是否更新标志 @@ -473,20 +510,20 @@ class PersonMeta(_PluginBase): cn_name = self.__get_chinese_name(person_tmdbinfo) 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 ret_people["Name"] = cn_name updated_name = True # 更新中文描述 biography = person_tmdbinfo.get("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 updated_overview = True # 图片 profile_path = person_tmdbinfo.get('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}" # 从豆瓣信息中更新人物信息 @@ -522,14 +559,14 @@ class PersonMeta(_PluginBase): or douban_actor.get("name") == people.get("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") ret_people["Name"] = douban_actor.get("name") updated_name = True # 描述 if not updated_overview: 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") updated_overview = True # 饰演角色 @@ -541,20 +578,20 @@ class PersonMeta(_PluginBase): character = re.sub("演员", "", character) if character: - logger.info(f"{people.get('Name')} 从豆瓣中获取到饰演角色:{character}") + logger.debug(f"{people.get('Name')} 从豆瓣中获取到饰演角色:{character}") ret_people["Role"] = character update_character = True # 图片 if not profile_path: avatar = douban_actor.get("avatar") or {} 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") break # 更新人物图片 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) # 锁定人物信息 @@ -567,12 +604,12 @@ class PersonMeta(_PluginBase): # 更新人物信息 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) if ret: return ret_people else: - logger.info(f"人物 {people.get('Name')} 未找到中文数据") + logger.debug(f"人物 {people.get('Name')} 未找到中文数据") except Exception as err: logger.error(f"更新人物信息失败:{err}") return None @@ -583,7 +620,7 @@ class PersonMeta(_PluginBase): """ # 随机休眠 3-10 秒 sleep_time = 3 + int(time.time()) % 7 - logger.info(f"随机休眠 {sleep_time}秒 ...") + logger.debug(f"随机休眠 {sleep_time}秒 ...") time.sleep(sleep_time) # 匹配豆瓣信息 doubaninfo = self.chain.match_doubaninfo(name=mediainfo.title, @@ -596,7 +633,7 @@ class PersonMeta(_PluginBase): doubanitem = self.chain.douban_info(doubaninfo.get("id")) or {} return (doubanitem.get("actors") or []) + (doubanitem.get("directors") or []) else: - logger.warn(f"未找到豆瓣信息:{mediainfo.title_year}") + logger.debug(f"未找到豆瓣信息:{mediainfo.title_year}") return [] @staticmethod @@ -882,7 +919,7 @@ class PersonMeta(_PluginBase): if r: return base64.b64encode(r.content).decode() else: - logger.info(f"{imageurl} 图片下载失败,请检查网络连通性") + logger.warn(f"{imageurl} 图片下载失败,请检查网络连通性") except Exception as err: logger.error(f"下载图片失败:{err}") return None