mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-03-27 10:05:57 +00:00
feat 云盘助手v1.4\n转移完删除本地文件时,支持自定义保留目录层级
This commit is contained in:
@@ -42,4 +42,4 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/
|
||||
- 目录监控(统一入库消息增强版) v1.0
|
||||
- Sql执行器 v1.2
|
||||
- 命令执行器 v1.2
|
||||
- 云盘助手 v1.3
|
||||
- 云盘助手 v1.4
|
||||
@@ -17,6 +17,7 @@
|
||||
"mount_path": "/mnt/cloud/115/media/movies",
|
||||
"return_path": "/mnt/softlink/movies",
|
||||
"delete_local": "false",
|
||||
"preserve_hierarchy": 0,
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
"overwrite": "false",
|
||||
@@ -41,6 +42,7 @@
|
||||
"cloud_url": "http://localhost:19798",
|
||||
"cloud_scheme": "http/https",
|
||||
"delete_local": "false",
|
||||
"preserve_hierarchy": 0,
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
"overwrite": "false",
|
||||
@@ -64,6 +66,7 @@ cd2方式上传--softlink回本地(暂时移除)
|
||||
"cd2_path": "/115/media/movies",
|
||||
"return_path": "/mnt/softlink/movies",
|
||||
"delete_local": "false",
|
||||
"preserve_hierarchy": 0,
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
"overwrite": "false",
|
||||
@@ -91,6 +94,7 @@ cd2方式上传--strm回本地(暂时移除)
|
||||
"cloud_url": "http://localhost:19798",
|
||||
"cloud_scheme": "http/https",
|
||||
"delete_local": "false",
|
||||
"preserve_hierarchy": 0,
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
"overwrite": "false",
|
||||
@@ -113,6 +117,7 @@ cd2方式上传--strm回本地(暂时移除)
|
||||
- return_path:MoviePilot中软链接/strm生成路径
|
||||
- monitor_mode:监控模式 compatibility/fast
|
||||
- delete_local:是否删除本地文件
|
||||
- preserve_hierarchy:保留监控目录后结构层级,例如 1:表示保留监控目录后一层目录结构,0:表示仅保留到监控目录
|
||||
- delete_history:是否删除MoviePilot中转移历史记录
|
||||
- just_media:是否只监控媒体文件
|
||||
- overwrite:是否覆盖已存在云盘文件
|
||||
|
||||
@@ -520,11 +520,12 @@
|
||||
"name": "云盘助手",
|
||||
"description": "定时移动到云盘,软连接/strm回本地,定时清理无效软连接。",
|
||||
"labels": "云盘",
|
||||
"version": "1.3",
|
||||
"version": "1.4",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/cloudassistant.png",
|
||||
"author": "thsrite",
|
||||
"level": 3,
|
||||
"history": {
|
||||
"v1.4": "转移完删除本地文件时,支持自定义保留目录层级",
|
||||
"v1.3": "完善逻辑,增加刷新emby媒体库(需要主程序1.9.9+)",
|
||||
"v1.2": "移除cd2上传",
|
||||
"v1.1": "支持cd2上传、支持定时清理无效软连接、支持strm生成方式",
|
||||
|
||||
@@ -64,7 +64,7 @@ class CloudAssistant(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/cloudassistant.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.3"
|
||||
plugin_version = "1.4"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -110,6 +110,7 @@ class CloudAssistant(_PluginBase):
|
||||
"mount_path": "/mnt/cloud/115/media/movies",
|
||||
"return_path": "/mnt/softlink/movies",
|
||||
"delete_local": "false",
|
||||
"preserve_hierarchy": 0,
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
"overwrite": "false",
|
||||
@@ -402,6 +403,7 @@ class CloudAssistant(_PluginBase):
|
||||
delete_history = monitor_dir.get("delete_history") or "false"
|
||||
overwrite = monitor_dir.get("overwrite") or "false"
|
||||
upload_cloud = monitor_dir.get("upload_cloud") or "true"
|
||||
preserve_hierarchy = monitor_dir.get("preserve_hierarchy") or 0
|
||||
|
||||
# 1、转移到云盘挂载路径 上传到cd2
|
||||
# 挂载的路径
|
||||
@@ -502,7 +504,7 @@ class CloudAssistant(_PluginBase):
|
||||
# 3、存操作记录
|
||||
if (self._only_media and Path(file_path).suffix.lower() in [ext.strip() for ext in
|
||||
self._rmt_mediaext.split(",")]) \
|
||||
or not self._only_media:
|
||||
or not self._only_media:
|
||||
history = self.get_data('history') or []
|
||||
history.append({
|
||||
"file_path": str(file_path),
|
||||
@@ -520,9 +522,14 @@ class CloudAssistant(_PluginBase):
|
||||
if file_path.exists():
|
||||
file_path.unlink()
|
||||
logger.info(f"删除本地文件:{file_path}")
|
||||
|
||||
# 保留层级
|
||||
mon_path_depth = len(Path(mon_path).parts)
|
||||
retain_depth = mon_path_depth + 2
|
||||
|
||||
for file_dir in file_path.parents:
|
||||
if len(str(file_dir)) <= len(str(Path(mon_path))):
|
||||
# 重要,删除到监控目录为止
|
||||
if len(file_dir.parts) <= retain_depth:
|
||||
# 重要,删除到保留层级目录为止
|
||||
break
|
||||
files = SystemUtils.list_files(file_dir, settings.RMT_MEDIAEXT + settings.DOWNLOAD_TMPEXT)
|
||||
if not files:
|
||||
|
||||
Reference in New Issue
Block a user