fix 联动同时处理同名非媒体文件

This commit is contained in:
thsrite
2024-04-13 13:05:40 +08:00
parent 450a0e0e46
commit f635c8c8bd
3 changed files with 20 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ MoviePilot三方插件市场https://github.com/thsrite/MoviePilot-Plugins/
- 站点数据统计 1.4 (无未读消息版本)(废弃)
- 站点未读消息 1.4
- [云盘Strm生成 4.0](docs%2FCloudStrm.md)
- [云盘Strm生成 4.1](docs%2FCloudStrm.md)
- [Strm文件模式转换 1.0](docs%2FStrmConvert.md)
- 清理订阅缓存 1.0
- 添加种子下载 1.0

View File

@@ -2,11 +2,12 @@
"CloudStrm": {
"name": "云盘Strm生成",
"description": "监控文件创建生成Strm文件。",
"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": "fix replace",
"v3.9": "修复bug",
"v3.8": "支持联动其他转移插件",

View File

@@ -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"
# 作者主页
@@ -316,9 +316,11 @@ class CloudStrm(_PluginBase):
source_file = str(event_data.get("transferinfo").target_path)
logger.info(f"收到命令,开始处理单个文件 {source_file} ...")
if source_file:
self.__strm(source_file)
# 云盘文件json新增
self.__cloud_files.append(source_file)
self.__strm(source_file, True)
def __strm(self, source_file):
def __strm(self, source_file: str, linkage: bool = False):
"""
生成strm文件
"""
@@ -367,6 +369,18 @@ class CloudStrm(_PluginBase):
cloud_type=cloud_type,
cloud_path=cloud_path,
cloud_url=cloud_url)
# 联动的时候,同步处理同名非媒体文件
if linkage and self._copy_files:
# 查询其他文件
pattern = Path(source_file).stem.replace('[', '?').replace(']', '?')
logger.info(f"开始处理同名文件 {pattern}")
other_files = Path(source_file).parent.glob(f"{pattern}.*")
for file in other_files:
# 云盘文件json新增
self.__cloud_files.append(file)
# 其他nfo、jpg等复制文件
shutil.copy2(file, dest_file)
logger.info(f"复制其他文件 {file}{dest_file}")
else:
if self._copy_files:
# 其他nfo、jpg等复制文件