diff --git a/README.md b/README.md index 88fcd56..f05d1ab 100644 --- a/README.md +++ b/README.md @@ -34,5 +34,5 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - 插件彻底卸载 1.0 - 实时软连接 1.3 - 订阅规则自动填充 2.5 -- Emby元数据刷新 1.0 -- Emby媒体标签 1.0 +- Emby元数据刷新 1.1 +- Emby媒体标签 1.1 diff --git a/package.json b/package.json index 991c50f..4e9ae22 100644 --- a/package.json +++ b/package.json @@ -381,11 +381,12 @@ "name": "Emby元数据刷新", "description": "定时刷新Emby媒体库元数据。", "labels": "Emby", - "version": "1.0", + "version": "1.1", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png", "author": "thsrite", "level": 1, "history": { + "v1.1": "添加远程交互命令", "v1.0": "定时刷新Emby媒体库元数据" } }, @@ -393,11 +394,12 @@ "name": "Emby媒体标签", "description": "自动给媒体库媒体添加标签。", "labels": "Emby", - "version": "1.0", + "version": "1.1", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/tag.png", "author": "thsrite", "level": 1, "history": { + "v1.1": "添加远程交互命令", "v1.0": "自动给媒体库媒体添加标签" } } diff --git a/plugins/embymetarefresh/__init__.py b/plugins/embymetarefresh/__init__.py index a281857..59f6a40 100644 --- a/plugins/embymetarefresh/__init__.py +++ b/plugins/embymetarefresh/__init__.py @@ -4,11 +4,14 @@ from typing import Optional, Any, List, Dict, Tuple import pytz from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.cron import CronTrigger + +from app.core.event import eventmanager, Event from app.db.transferhistory_oper import TransferHistoryOper from app.core.config import settings from app.log import logger from app.plugins import _PluginBase from app.modules.emby import Emby +from app.schemas.types import EventType from app.utils.http import RequestUtils @@ -20,7 +23,7 @@ class EmbyMetaRefresh(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png" # 插件版本 - plugin_version = "1.0" + plugin_version = "1.1" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -128,6 +131,23 @@ class EmbyMetaRefresh(_PluginBase): self.__refresh_emby(transferinfo) logger.info(f"刷新媒体库元数据完成") + @eventmanager.register(EventType.PluginAction) + def remote_sync(self, event: Event): + """ + 远程刷新媒体库 + """ + if event: + event_data = event.event_data + if not event_data or event_data.get("action") != "emby_refresh": + return + self.post_message(channel=event.event_data.get("channel"), + title="开始刷新媒体库 ...", + userid=event.event_data.get("user")) + self.refresh() + if event: + self.post_message(channel=event.event_data.get("channel"), + title="刷新媒体库完成!", userid=event.event_data.get("user")) + def __refresh_emby(self, transferinfo): """ 刷新emby @@ -253,7 +273,15 @@ class EmbyMetaRefresh(_PluginBase): @staticmethod def get_command() -> List[Dict[str, Any]]: - pass + return [{ + "cmd": "/emby_meta_refresh", + "event": EventType.PluginAction, + "desc": "Emby媒体库刷新", + "category": "", + "data": { + "action": "emby_refresh" + } + }] def get_api(self) -> List[Dict[str, Any]]: pass diff --git a/plugins/embymetatag/__init__.py b/plugins/embymetatag/__init__.py index 861cd48..572d676 100644 --- a/plugins/embymetatag/__init__.py +++ b/plugins/embymetatag/__init__.py @@ -6,9 +6,11 @@ from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.cron import CronTrigger from app.core.config import settings +from app.core.event import eventmanager, Event from app.log import logger from app.plugins import _PluginBase from app.modules.emby import Emby +from app.schemas.types import EventType from app.utils.http import RequestUtils @@ -20,7 +22,7 @@ class EmbyMetaTag(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/tag.png" # 插件版本 - plugin_version = "1.0" + plugin_version = "1.1" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -169,6 +171,23 @@ class EmbyMetaTag(_PluginBase): logger.info("Emby媒体标签任务完成") + @eventmanager.register(EventType.PluginAction) + def remote_sync(self, event: Event): + """ + 远程添加媒体标签 + """ + if event: + event_data = event.event_data + if not event_data or event_data.get("action") != "emby_tag": + return + self.post_message(channel=event.event_data.get("channel"), + title="开始添加媒体标签 ...", + userid=event.event_data.get("user")) + self.auto_tag() + if event: + self.post_message(channel=event.event_data.get("channel"), + title="添加媒体标签完成!", userid=event.event_data.get("user")) + def __add_tag(self, itemid: str, tags: dict): req_url = "%semby/Items/%s/Tags/Add?api_key=%s" % (self._EMBY_HOST, itemid, self._EMBY_APIKEY) try: @@ -200,7 +219,15 @@ class EmbyMetaTag(_PluginBase): @staticmethod def get_command() -> List[Dict[str, Any]]: - pass + return [{ + "cmd": "/emby_meta_tag", + "event": EventType.PluginAction, + "desc": "Emby媒体标签", + "category": "", + "data": { + "action": "emby_tag" + } + }] def get_api(self) -> List[Dict[str, Any]]: pass