From dd8bf698a2e54f83d64e51d8f7741135153ec69d Mon Sep 17 00:00:00 2001 From: thsrite Date: Mon, 11 Nov 2024 14:06:31 +0800 Subject: [PATCH] fix #121 --- package.json | 6 ++++-- package.v2.json | 2 +- plugins.v2/cloudlinkmonitor/__init__.py | 2 +- plugins.v2/cloudstrmcompanion/__init__.py | 2 +- plugins/cloudstrm/__init__.py | 16 ++++++++++++++- plugins/cloudstrmincrement/__init__.py | 25 +++++++++++++++++------ 6 files changed, 41 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index ca30efd..9be9a95 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,13 @@ "name": "云盘Strm生成", "description": "监控文件创建,生成Strm文件。", "labels": "云盘", - "version": "4.4", + "version": "4.4.1", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png", "author": "thsrite", "level": 1, "v2": true, "history": { + "v4.4.1": "支持[目录实时监控]插件联动", "v4.4": "修复bug", "v4.3": "回滚自定义媒体类型", "v4.2": "扩展名转小写", @@ -26,12 +27,13 @@ "name": "云盘Strm生成(增量版)", "description": "监控文件创建,生成Strm文件(增量版)。", "labels": "云盘", - "version": "1.1.2", + "version": "1.1.3", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png", "author": "thsrite", "level": 1, "v2": true, "history": { + "v1.1.3": "支持[目录实时监控]插件联动", "v1.1.2": "增量文件可选择是否保留", "v1.1.1": "写入strm使用utf-8编码", "v1.1": "某种场景下可能出现卡死,修复bug", diff --git a/package.v2.json b/package.v2.json index 301872f..f09ba33 100644 --- a/package.v2.json +++ b/package.v2.json @@ -370,7 +370,7 @@ "author": "thsrite", "level": 1, "history": { - "v2.5.2": "支持联动[云盘Strm助手]插件", + "v2.5.2": "支持联动[云盘Strm]相关插件", "v2.5.1": "修复媒体刮削", "v2.5": "兼容v2", "v2.4.5": "联动实时软连接插件(近媒体文件)", diff --git a/plugins.v2/cloudlinkmonitor/__init__.py b/plugins.v2/cloudlinkmonitor/__init__.py index eab610a..c7b772c 100644 --- a/plugins.v2/cloudlinkmonitor/__init__.py +++ b/plugins.v2/cloudlinkmonitor/__init__.py @@ -559,7 +559,7 @@ class CloudLinkMonitor(_PluginBase): # 通知Strm助手生成 self.eventmanager.send_event(EventType.PluginAction, { 'file_path': str(transferinfo.target_item.path), - 'action': 'strm_file' + 'action': 'cloudstrm_file' }) # 移动模式删除空目录 diff --git a/plugins.v2/cloudstrmcompanion/__init__.py b/plugins.v2/cloudstrmcompanion/__init__.py index 38cb8f1..7e231e7 100644 --- a/plugins.v2/cloudstrmcompanion/__init__.py +++ b/plugins.v2/cloudstrmcompanion/__init__.py @@ -235,7 +235,7 @@ class CloudStrmCompanion(_PluginBase): def strm_one(self, event: Event = None): if event: event_data = event.event_data - if not event_data or event_data.get("action") != "strm_file": + if not event_data or event_data.get("action") != "cloudstrm_file": return file_path = event_data.get("file_path") if not file_path: diff --git a/plugins/cloudstrm/__init__.py b/plugins/cloudstrm/__init__.py index 7b093d6..693cf22 100644 --- a/plugins/cloudstrm/__init__.py +++ b/plugins/cloudstrm/__init__.py @@ -26,7 +26,7 @@ class CloudStrm(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png" # 插件版本 - plugin_version = "4.4" + plugin_version = "4.4.1" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -165,6 +165,20 @@ class CloudStrm(_PluginBase): self._scheduler.print_jobs() self._scheduler.start() + @eventmanager.register(EventType.PluginAction) + def cloudstrm_file(self, event: Event = None): + if event: + event_data = event.event_data + if not event_data or event_data.get("action") != "cloudstrm_file": + return + + file_path = event_data.get("file_path") + if not file_path: + logger.error(f"缺少参数:{event_data}") + return + + self.__strm(source_file=file_path) + @eventmanager.register(EventType.PluginAction) def scan(self, event: Event = None): """ diff --git a/plugins/cloudstrmincrement/__init__.py b/plugins/cloudstrmincrement/__init__.py index 4a2c7b1..8b4537c 100644 --- a/plugins/cloudstrmincrement/__init__.py +++ b/plugins/cloudstrmincrement/__init__.py @@ -3,18 +3,17 @@ import shutil import urllib.parse from datetime import datetime, timedelta from pathlib import Path - -import pytz from typing import Any, List, Dict, Tuple, Optional -from app.core.event import eventmanager, Event -from app.schemas.types import EventType +import pytz 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.core.config import settings +from app.schemas.types import EventType from app.utils.system import SystemUtils @@ -26,7 +25,7 @@ class CloudStrmIncrement(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png" # 插件版本 - plugin_version = "1.1.2" + plugin_version = "1.1.3" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -164,6 +163,20 @@ class CloudStrmIncrement(_PluginBase): self._scheduler.print_jobs() self._scheduler.start() + @eventmanager.register(EventType.PluginAction) + def cloudstrm_file(self, event: Event = None): + if event: + event_data = event.event_data + if not event_data or event_data.get("action") != "cloudstrm_file": + return + + file_path = event_data.get("file_path") + if not file_path: + logger.error(f"缺少参数:{event_data}") + return + + self.__strm(source_file=file_path) + @eventmanager.register(EventType.PluginAction) def scan(self, event: Event = None): """