feat 云盘助手v1.2\n支持cd2上传、支持定时清理无效软连接、支持strm生成方式

This commit is contained in:
thsrite
2024-06-22 21:14:08 +08:00
parent 9d45d1972e
commit 6bff0e2952
2 changed files with 44 additions and 36 deletions

View File

@@ -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_dirstrm模式下媒体服务器内源文件路径
- cloud_typestrm模式下云盘类型可选值alist/cd2
- cloud_pathstrm模式下cd2/alist挂载本地跟路径

View File

@@ -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():