mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-03-27 10:05:57 +00:00
fix 联动Emby Strm Assistant插件独占模式
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
"name": "Emby元数据刷新",
|
||||
"description": "定时刷新Emby媒体库元数据,演职人员中文。",
|
||||
"labels": "Emby",
|
||||
"version": "2.1.5",
|
||||
"version": "2.1.6",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png",
|
||||
"author": "thsrite",
|
||||
"level": 1,
|
||||
"history": {
|
||||
"v2.1.6": "联动Emby Strm Assistant插件独占模式",
|
||||
"v2.1.5": "媒体库未连接不继续任务",
|
||||
"v2.1.4": "兼容特殊场景刷新",
|
||||
"v2.1.3": "增加自定义延迟",
|
||||
|
||||
@@ -622,8 +622,8 @@ class EmbyDanmu(_PluginBase):
|
||||
"""
|
||||
if not self._EMBY_HOST or not self._EMBY_APIKEY:
|
||||
return []
|
||||
req_url = f"%semby/web/configurationpages?PageType=PluginConfiguration&EnableInMainMenu=true&UserId=%s&api_key=%s" % (
|
||||
self._EMBY_HOST, self._EMBY_USER, self._EMBY_APIKEY)
|
||||
req_url = f"%semby/web/configurationpages?PageType=PluginConfiguration&EnableInMainMenu=true&api_key=%s" % (
|
||||
self._EMBY_HOST, self._EMBY_APIKEY)
|
||||
with RequestUtils().get_res(req_url) as res:
|
||||
if res:
|
||||
return res.json()
|
||||
|
||||
@@ -36,7 +36,7 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png"
|
||||
# 插件版本
|
||||
plugin_version = "2.1.5"
|
||||
plugin_version = "2.1.6"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -54,6 +54,7 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
_enabled = False
|
||||
tmdbchain = None
|
||||
_onlyonce = False
|
||||
_ExclusiveExtract = False
|
||||
_cron = None
|
||||
_actor_chi = False
|
||||
_num = None
|
||||
@@ -80,6 +81,7 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
self._onlyonce = config.get("onlyonce")
|
||||
self._cron = config.get("cron")
|
||||
self._actor_chi = config.get("actor_chi")
|
||||
self._ExclusiveExtract = config.get("ExclusiveExtract")
|
||||
self._num = config.get("num") or 5
|
||||
self._actor_path = config.get("actor_path")
|
||||
self._refresh_type = config.get("refresh_type") or "历史记录"
|
||||
@@ -140,6 +142,7 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
"actor_path": self._actor_path,
|
||||
"mediaservers": self._mediaservers,
|
||||
"interval": self._interval,
|
||||
"ExclusiveExtract": self._ExclusiveExtract,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -166,6 +169,21 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
if not self._EMBY_HOST.startswith("http"):
|
||||
self._EMBY_HOST = "http://" + self._EMBY_HOST
|
||||
|
||||
# 判断有无安装strm assistant插件
|
||||
plugin_config, plugin_id = None, None
|
||||
if self._ExclusiveExtract:
|
||||
try:
|
||||
plugin_config, plugin_id = self.__get_strm_assistant_config()
|
||||
if plugin_id:
|
||||
# 打开独占模式(方式元数据刷新导致媒体数据丢失)
|
||||
flag = self.__set_strm_assistant_exclusive_mode(emby, plugin_config, plugin_id, True)
|
||||
if not flag:
|
||||
logger.error(f"打开 Strm Assistant 独占模式失败")
|
||||
else:
|
||||
logger.info(f"Strm Assistant 独占模式已打开")
|
||||
except Exception as e:
|
||||
logger.error(f"获取 Strm Assistant 配置失败:{str(e)}")
|
||||
|
||||
if str(self._refresh_type) == "历史记录":
|
||||
# 获取days内入库的媒体
|
||||
current_date = datetime.now()
|
||||
@@ -253,7 +271,17 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
flag = self.set_iteminfo(itemid=item_info.get("Id"), iteminfo=item_info, emby=emby)
|
||||
logger.info(
|
||||
f"最新媒体:{'电视剧' if str(item_info.get('Type')) == 'Episode' else '电影'} {'%s S%02dE%02d %s' % (item_info.get('SeriesName'), item_info.get('ParentIndexNumber'), item_info.get('IndexNumber'), item_info.get('Name')) if str(item_info.get('Type')) == 'Episode' else item_info.get('Name')} {item_info.get('Id')} 演员信息完成 {flag}")
|
||||
|
||||
if self._ExclusiveExtract:
|
||||
try:
|
||||
if plugin_id:
|
||||
# 打开独占模式(方式元数据刷新导致媒体数据丢失)
|
||||
flag = self.__set_strm_assistant_exclusive_mode(emby, plugin_config, plugin_id, False)
|
||||
if not flag:
|
||||
logger.error(f"关闭 Strm Assistant 独占模式失败")
|
||||
else:
|
||||
logger.info(f"Strm Assistant 独占模式已关闭")
|
||||
except Exception as e:
|
||||
logger.error(f"关闭 Strm Assistant 独占模式失败:{str(e)}")
|
||||
logger.info(f"刷新 {emby_name} 媒体库元数据完成")
|
||||
|
||||
def __get_latest_media(self) -> List[dict]:
|
||||
@@ -535,6 +563,99 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
logger.error(f"更新人物信息失败:{str(err)}")
|
||||
return None
|
||||
|
||||
def __get_strm_assistant_config(self):
|
||||
"""
|
||||
获取Strm Assistant配置
|
||||
"""
|
||||
# 获取插件列表
|
||||
list_plugins = self.__get_plugins()
|
||||
if not list_plugins:
|
||||
return None, None
|
||||
|
||||
# 获取弹幕配置插件
|
||||
plugin_id = None
|
||||
plugin_name = None
|
||||
for plugin in list_plugins:
|
||||
if plugin.get("DisplayName") == "Strm Assistant":
|
||||
plugin_id = plugin.get("PluginId")
|
||||
plugin_name = plugin.get("Name")
|
||||
break
|
||||
|
||||
if not plugin_id:
|
||||
logger.debug("Strm Assistant插件未安装")
|
||||
return None, None
|
||||
|
||||
plugin_id = f"{plugin_id[:6]}:{plugin_name}"
|
||||
|
||||
# 获取插件配置
|
||||
plugin_info = self.__get_plugin_info(plugin_id)
|
||||
if not plugin_info:
|
||||
return None, None
|
||||
# 获取Strm Assistant配置
|
||||
plugin_config = plugin_info.get("EditObjectContainer", {}).get("Object")
|
||||
if not plugin_config:
|
||||
return None, None
|
||||
|
||||
return plugin_config, plugin_id
|
||||
|
||||
def __set_strm_assistant_exclusive_mode(self, emby, plugin_config, plugin_id, exclusive_mode: bool):
|
||||
"""
|
||||
设置Strm Assistant独占模式
|
||||
"""
|
||||
plugin_config["MediaInfoExtractOptions"]["ExclusiveExtract"] = exclusive_mode
|
||||
data = {
|
||||
"ClientLocale": "zh-cn",
|
||||
"CommandId": "PageSave",
|
||||
"ItemId": "undefined",
|
||||
"PageId": plugin_id,
|
||||
"Data": json.dumps(plugin_config, ensure_ascii=False)
|
||||
}
|
||||
|
||||
try:
|
||||
res = emby.post_data(
|
||||
url=f"[HOST]emby/UI/Command?reqformat=json&api_key=[APIKEY]",
|
||||
data=json.dumps(data),
|
||||
headers={
|
||||
"Content-Type": "text/plain"
|
||||
}
|
||||
)
|
||||
if res and res.status_code in [200, 204]:
|
||||
return True
|
||||
except Exception as err:
|
||||
logger.error(f"设置Strm Assistant独占模式失败:{str(err)}")
|
||||
return False
|
||||
|
||||
def __get_plugins(self) -> list:
|
||||
"""
|
||||
获取插件列表
|
||||
"""
|
||||
if not self._EMBY_HOST or not self._EMBY_APIKEY:
|
||||
return []
|
||||
req_url = f"%semby/web/configurationpages?PageType=PluginConfiguration&EnableInMainMenu=true&api_key=%s" % (
|
||||
self._EMBY_HOST, self._EMBY_APIKEY)
|
||||
with RequestUtils().get_res(req_url) as res:
|
||||
if res:
|
||||
return res.json()
|
||||
else:
|
||||
logger.error(f"获取插件列表失败,无法连接Emby!")
|
||||
return []
|
||||
|
||||
def __get_plugin_info(self, plugin_id) -> dict:
|
||||
"""
|
||||
获取插件详情
|
||||
"""
|
||||
if not self._EMBY_HOST or not self._EMBY_APIKEY:
|
||||
return {}
|
||||
req_url = f"%semby/UI/View?PageId=%s&api_key=%s" % (
|
||||
self._EMBY_HOST, plugin_id, self._EMBY_APIKEY)
|
||||
|
||||
with RequestUtils().get_res(req_url) as res:
|
||||
if res:
|
||||
return res.json()
|
||||
else:
|
||||
logger.error(f"获取插件详情失败,无法连接Emby!")
|
||||
return {}
|
||||
|
||||
@staticmethod
|
||||
def set_iteminfo(itemid: str, iteminfo: dict, emby):
|
||||
"""
|
||||
@@ -1081,6 +1202,27 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 4
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VSelect',
|
||||
'props': {
|
||||
'multiple': False,
|
||||
'chips': True,
|
||||
'clearable': True,
|
||||
'model': 'ExclusiveExtract',
|
||||
'label': '联动独占模式',
|
||||
'items': [{'title': 'true', 'value': "true"},
|
||||
{'title': 'false', 'value': "false"}]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1104,6 +1246,27 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VAlert',
|
||||
'props': {
|
||||
'type': 'info',
|
||||
'variant': 'tonal',
|
||||
'text': '联动独占模式:Emby安装Strm Assistant插件的前提下,为保留Emby Strm文件的媒体信息,可开启该模式,当刷新元数据前打开独占模式,刷新完后关闭独占模式'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
@@ -1111,6 +1274,7 @@ class EmbyMetaRefresh(_PluginBase):
|
||||
"enabled": False,
|
||||
"onlyonce": False,
|
||||
"actor_chi": False,
|
||||
"ExclusiveExtract": False,
|
||||
"ReplaceAllMetadata": "true",
|
||||
"ReplaceAllImages": "true",
|
||||
"cron": "5 1 * * *",
|
||||
|
||||
1191
plugins.v2/embymetarefresh/__init__.py.bk
Normal file
1191
plugins.v2/embymetarefresh/__init__.py.bk
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user