From c191381b394db733940de366dbc40a6a029abf88 Mon Sep 17 00:00:00 2001 From: thsrite Date: Sat, 9 Nov 2024 20:15:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A2=9E=E5=8A=A0=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E9=9D=9E=E5=AA=92=E4=BD=93=E6=96=87=E4=BB=B6=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.v2.json | 3 +- plugins.v2/cloudstrmcompanion/__init__.py | 51 +++++++++++++++++------ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/package.v2.json b/package.v2.json index a36b484..b38cdcd 100644 --- a/package.v2.json +++ b/package.v2.json @@ -418,11 +418,12 @@ "name": "云盘Strm助手", "description": "实时监控、定时全量增量生成strm文件。", "labels": "云盘", - "version": "1.0.4", + "version": "1.0.5", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/cloudcompanion.png", "author": "thsrite", "level": 1, "history": { + "v1.0.5": "增加复制非媒体文件选项", "v1.0.4": "修复实时监控,只处理指定类型的文件", "v1.0.3": "修复重建索引缓存", "v1.0.2": "增加可玩性交互命令", diff --git a/plugins.v2/cloudstrmcompanion/__init__.py b/plugins.v2/cloudstrmcompanion/__init__.py index 3ee3e79..a351de2 100644 --- a/plugins.v2/cloudstrmcompanion/__init__.py +++ b/plugins.v2/cloudstrmcompanion/__init__.py @@ -1,5 +1,6 @@ import json import os +import shutil import threading import time import traceback @@ -58,7 +59,7 @@ class CloudStrmCompanion(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/cloudcompanion.png" # 插件版本 - plugin_version = "1.0.4" + plugin_version = "1.0.5" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -78,6 +79,7 @@ class CloudStrmCompanion(_PluginBase): _rebuild = False _cover = False _monitor = False + _copy_files = False _strm_dir_conf = {} _cloud_dir_conf = {} @@ -115,6 +117,7 @@ class CloudStrmCompanion(_PluginBase): self._rebuild = config.get("rebuild") self._monitor = config.get("monitor") self._cover = config.get("cover") + self._copy_files = config.get("copy_files") self._monitor_confs = config.get("monitor_confs") self._rmt_mediaext = config.get( "rmt_mediaext") or ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v" @@ -328,10 +331,7 @@ class CloudStrmCompanion(_PluginBase): if not event.is_directory: if '.fuse_hidden' in event_path: return - # 只处理媒体文件 - if Path(event_path).suffix.lower() not in [ext.strip() for ext in - self._rmt_mediaext.split(",")]: - return + # 文件发生变化 logger.debug("监控到文件%s:%s" % (text, event_path)) self.__handle_file(event_path=event_path, mon_path=mon_path) @@ -357,13 +357,22 @@ class CloudStrmCompanion(_PluginBase): target_file = str(event_path).replace(mon_path, strm_dir) # 云盘文件路径 cloud_file = str(event_path).replace(mon_path, cloud_dir) - # 生成strm文件内容 - strm_content = self.__format_content(format_str=format_str, - local_file=event_path, - cloud_file=str(cloud_file)) - # 生成strm文件 - self.__create_strm_file(strm_file=target_file, - strm_content=strm_content) + + # 只处理媒体文件 + if Path(event_path).suffix.lower() not in [ext.strip() for ext in + self._rmt_mediaext.split(",")]: + # 生成strm文件内容 + strm_content = self.__format_content(format_str=format_str, + local_file=event_path, + cloud_file=str(cloud_file)) + # 生成strm文件 + self.__create_strm_file(strm_file=target_file, + strm_content=strm_content) + else: + if self._copy_files: + # 其他nfo、jpg等复制文件 + shutil.copy2(str(event_path), target_file) + logger.info(f"复制其他文件 {str(event_path)} 到 {target_file}") except Exception as e: logger.error("目录监控发生错误:%s - %s" % (str(e), traceback.format_exc())) @@ -713,6 +722,7 @@ class CloudStrmCompanion(_PluginBase): "cover": self._cover, "rebuild": self._rebuild, "monitor": self._monitor, + "copy_files": self._copy_files, "cron": self._cron, "monitor_confs": self._monitor_confs, "115_cookie": self._115_cookie, @@ -816,6 +826,22 @@ class CloudStrmCompanion(_PluginBase): } ] }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 4 + }, + 'content': [ + { + 'component': 'VSwitch', + 'props': { + 'model': 'copy_files', + 'label': '复制非媒体文件', + } + } + ] + } ] }, { @@ -1012,6 +1038,7 @@ class CloudStrmCompanion(_PluginBase): "rebuild": False, "monitor": False, "cover": False, + "copy_files": False, "monitor_confs": "", "115_cookie": "", "rmt_mediaext": ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v"