fix 添加远程交互命令

This commit is contained in:
thsrite
2024-05-04 21:38:05 +08:00
parent ac3f920ebf
commit 1ffa2652d8
4 changed files with 65 additions and 8 deletions

View File

@@ -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

View File

@@ -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": "自动给媒体库媒体添加标签"
}
}

View File

@@ -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

View File

@@ -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