From e13a190cee3e451550efbc0acdeda609044fbf7f Mon Sep 17 00:00:00 2001 From: thsrite Date: Fri, 7 Jun 2024 23:41:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BA=91=E7=9B=98Strm=E7=94=9F=E6=88=90v?= =?UTF-8?q?4.1=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AA=92?= =?UTF-8?q?=E4=BD=93=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- package.json | 3 +- plugins/cloudstrm/__init__.py | 42 ++++++++++++++++++++++---- plugins/cloudstrmincrement/__init__.py | 3 +- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 008589a..1c723cd 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - 站点数据统计 v1.4 (无未读消息版本)(废弃) - 站点未读消息 v1.9 (依赖于[站点数据统计]插件) -- [云盘Strm生成 v4.0](docs%2FCloudStrm.md) +- [云盘Strm生成 v4.1](docs%2FCloudStrm.md) - [云盘Strm生成(增量版) v1.0](docs%2FCloudStrmIncrement.md) - [Strm文件模式转换 v1.0](docs%2FStrmConvert.md) - 清理订阅缓存 v1.0 diff --git a/package.json b/package.json index fb932f4..2d270ed 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,12 @@ "name": "云盘Strm生成", "description": "监控文件创建,生成Strm文件。", "labels": "云盘", - "version": "4.0", + "version": "4.1", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png", "author": "thsrite", "level": 1, "history": { + "v4.1": "支持自定义媒体类型", "v4.0": "回归老版本", "v3.8": "支持增量路径、支持自定义媒体类型(注:本次更新需修改配置使用)", "v3.7": "api模式支持启用https", diff --git a/plugins/cloudstrm/__init__.py b/plugins/cloudstrm/__init__.py index c6b159a..db218fa 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.0" + plugin_version = "4.1" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -56,6 +56,7 @@ class CloudStrm(_PluginBase): _cloudurlconf = {} _cloudpathconf = {} __cloud_files = [] + _rmt_mediaext = ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v" # 定时器 _scheduler: Optional[BackgroundScheduler] = None @@ -78,6 +79,8 @@ class CloudStrm(_PluginBase): self._https = config.get("https") 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" # 停止现有任务 self.stop_service() @@ -233,7 +236,8 @@ class CloudStrm(_PluginBase): continue # 不复制非媒体文件时直接过滤掉非媒体文件 - if not self._copy_files and Path(file).suffix not in settings.RMT_MEDIAEXT: + if not self._copy_files and Path(file).suffix not in [ext.strip() for ext in + self._rmt_mediaext.split(",")]: continue if source_file not in self.__cloud_files: @@ -280,7 +284,8 @@ class CloudStrm(_PluginBase): continue # 不复制非媒体文件时直接过滤掉非媒体文件 - if not self._copy_files and Path(file).suffix not in settings.RMT_MEDIAEXT: + if not self._copy_files and Path(file).suffix not in [ext.strip() for ext in + self._rmt_mediaext.split(",")]: continue logger.info(f"扫描到新文件 {source_file},正在开始处理") @@ -343,7 +348,8 @@ class CloudStrm(_PluginBase): os.makedirs(Path(dest_file).parent) # 视频文件创建.strm文件 - if Path(dest_file).suffix in settings.RMT_MEDIAEXT: + if Path(dest_file).suffix in [ext.strip() for ext in + self._rmt_mediaext.split(",")]: # 创建.strm文件 self.__create_strm_file(scheme="https" if self._https else "http", dest_file=dest_file, @@ -433,7 +439,8 @@ class CloudStrm(_PluginBase): "copy_files": self._copy_files, "https": self._https, "cron": self._cron, - "monitor_confs": self._monitor_confs + "monitor_confs": self._monitor_confs, + "rmt_mediaext": self._rmt_mediaext }) def get_state(self) -> bool: @@ -638,6 +645,28 @@ class CloudStrm(_PluginBase): }, ] }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12 + }, + 'content': [ + { + 'component': 'VTextarea', + 'props': { + 'model': 'rmt_mediaext', + 'label': '视频格式', + 'rows': 2, + 'placeholder': ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v" + } + } + ] + } + ] + }, { 'component': 'VRow', 'content': [ @@ -737,7 +766,8 @@ class CloudStrm(_PluginBase): "rebuild": False, "copy_files": False, "https": False, - "monitor_confs": "" + "monitor_confs": "", + "rmt_mediaext": ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v" } def get_page(self) -> List[dict]: diff --git a/plugins/cloudstrmincrement/__init__.py b/plugins/cloudstrmincrement/__init__.py index 5f1049b..1dff14c 100644 --- a/plugins/cloudstrmincrement/__init__.py +++ b/plugins/cloudstrmincrement/__init__.py @@ -236,7 +236,8 @@ class CloudStrmIncrement(_PluginBase): break if str(parent_path.parent) != str(Path(increment_file).root): # 父目录非根目录,才删除父目录 - if not SystemUtils.exits_files(parent_path, settings.RMT_MEDIAEXT): + if not SystemUtils.exits_files(parent_path, + [ext.strip() for ext in self._rmt_mediaext.split(",")]): # 当前路径下没有媒体文件则删除 shutil.rmtree(parent_path) logger.warn(f"增量非保留目录 {parent_path} 已删除")