mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-05-31 07:26:47 +00:00
feat 云盘助手v1.2\n支持cd2上传、支持定时清理无效软连接、支持strm生成方式
This commit is contained in:
@@ -22,7 +22,8 @@ cd2方式上传--softlink回本地
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
“copy_other_files”: "false",
|
||||
"overwrite": "false"
|
||||
"overwrite": "false",
|
||||
"upload_cloud": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -49,7 +50,8 @@ cd2方式上传--strm回本地
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
“copy_other_files”: "false",
|
||||
"overwrite": "false"
|
||||
"overwrite": "false",
|
||||
"upload_cloud": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -68,7 +70,8 @@ cd2方式上传--strm回本地
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
“copy_other_files”: "false",
|
||||
"overwrite": "false"
|
||||
"overwrite": "false",
|
||||
"upload_cloud": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -92,7 +95,8 @@ cd2方式上传--strm回本地
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
“copy_other_files”: "false",
|
||||
"overwrite": "false"
|
||||
"overwrite": "false",
|
||||
"upload_cloud": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -113,6 +117,7 @@ cd2方式上传--strm回本地
|
||||
- just_media:是否只监控媒体文件
|
||||
- copy_other_files:软连接时是否复制本地非媒体文件到软连接路径
|
||||
- overwrite:是否覆盖已存在云盘文件
|
||||
- upload_cloud: 是否上传到云盘,false则直接软连接或者strm回本地
|
||||
- library_dir:strm模式下,媒体服务器内源文件路径
|
||||
- cloud_type:strm模式下,云盘类型,可选值:alist/cd2
|
||||
- cloud_path:strm模式下,cd2/alist挂载本地跟路径
|
||||
|
||||
@@ -109,7 +109,8 @@ class CloudAssistant(_PluginBase):
|
||||
"delete_local": "false",
|
||||
"delete_history": "false",
|
||||
"just_media": "true",
|
||||
"overwrite": "false"
|
||||
"overwrite": "false",
|
||||
"upload_cloud": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -386,47 +387,49 @@ class CloudAssistant(_PluginBase):
|
||||
delete_local = monitor_dir.get("delete_local") or "false"
|
||||
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"
|
||||
|
||||
# 1、转移到云盘挂载路径 上传到cd2
|
||||
# 挂载的路径
|
||||
mount_file = str(file_path).replace(str(mon_path), str(mount_path))
|
||||
logger.info(f"挂载目录文件 {mount_file}")
|
||||
|
||||
# cd2模式
|
||||
if self._client:
|
||||
logger.info("开始上传文件到CloudDrive2")
|
||||
# cd2目标路径
|
||||
cd2_file = str(file_path).replace(str(mon_path), str(cd2_path))
|
||||
logger.info(f"cd2目录文件 {cd2_file}")
|
||||
if str(upload_cloud) == "true":
|
||||
# cd2模式
|
||||
if self._client:
|
||||
logger.info("开始上传文件到CloudDrive2")
|
||||
# cd2目标路径
|
||||
cd2_file = str(file_path).replace(str(mon_path), str(cd2_path))
|
||||
logger.info(f"cd2目录文件 {cd2_file}")
|
||||
|
||||
# 上传前先检查文件是否存在
|
||||
cd2_file_exists = False
|
||||
if str(overwrite) == "false":
|
||||
if self._fs.exists(Path(cd2_file)): # 云盘文件存在则跳过
|
||||
logger.info(f"云盘文件 {cd2_file} 已存在,跳过上传")
|
||||
cd2_file_exists = True
|
||||
# 上传前先检查文件是否存在
|
||||
cd2_file_exists = False
|
||||
if str(overwrite) == "false":
|
||||
if self._fs.exists(Path(cd2_file)): # 云盘文件存在则跳过
|
||||
logger.info(f"云盘文件 {cd2_file} 已存在,跳过上传")
|
||||
cd2_file_exists = True
|
||||
|
||||
if not cd2_file_exists:
|
||||
# cd2目录不存在则创建
|
||||
if not self._fs.exists(Path(cd2_file).parent):
|
||||
self._fs.mkdir(Path(cd2_file).parent)
|
||||
logger.info(f"创建cd2目录 {Path(cd2_file).parent}")
|
||||
# 切换cd2路径
|
||||
self._fs.chdir(Path(cd2_file).parent)
|
||||
if not cd2_file_exists:
|
||||
# cd2目录不存在则创建
|
||||
if not self._fs.exists(Path(cd2_file).parent):
|
||||
self._fs.mkdir(Path(cd2_file).parent)
|
||||
logger.info(f"创建cd2目录 {Path(cd2_file).parent}")
|
||||
# 切换cd2路径
|
||||
self._fs.chdir(Path(cd2_file).parent)
|
||||
|
||||
# 上传文件到cd2
|
||||
logger.info(f"开始上传文件 {file_path} 到 {cd2_file}")
|
||||
self._fs.upload(file_path, overwrite_or_ignore=True)
|
||||
logger.info(f"上传文件 {file_path} 到 {cd2_file}完成")
|
||||
# 上传文件到cd2
|
||||
logger.info(f"开始上传文件 {file_path} 到 {cd2_file}")
|
||||
self._fs.upload(file_path, overwrite_or_ignore=True)
|
||||
logger.info(f"上传文件 {file_path} 到 {cd2_file}完成")
|
||||
|
||||
# 上传任务列表
|
||||
# upload_tasklist = self._client.upload_tasklist
|
||||
# logger.info(f"上传任务列表 {upload_tasklist}")
|
||||
else:
|
||||
logger.info(f"开始 {self._transfer_type} 方式转移文件")
|
||||
self.__transfer_file(file_path=file_path,
|
||||
target_file=mount_file,
|
||||
transfer_type=self._transfer_type)
|
||||
# 上传任务列表
|
||||
# upload_tasklist = self._client.upload_tasklist
|
||||
# logger.info(f"上传任务列表 {upload_tasklist}")
|
||||
else:
|
||||
logger.info(f"开始 {self._transfer_type} 方式转移文件")
|
||||
self.__transfer_file(file_path=file_path,
|
||||
target_file=mount_file,
|
||||
transfer_type=self._transfer_type)
|
||||
|
||||
# 2、软连接回本地路径
|
||||
if not Path(mount_file).exists():
|
||||
|
||||
Reference in New Issue
Block a user