fix 云盘Strm助手v1.3.2

插件联动生成Strm文件同时处理非媒体文件
This commit is contained in:
thsrite
2025-04-21 11:48:13 +08:00
parent 9d684519cd
commit 6b76b5ce79
2 changed files with 39 additions and 18 deletions

View File

@@ -447,11 +447,12 @@
"name": "云盘Strm助手",
"description": "实时监控、定时全量增量生成strm文件。",
"labels": "云盘",
"version": "1.3.1",
"version": "1.3.2",
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/cloudcompanion.png",
"author": "thsrite",
"level": 1,
"history": {
"v1.3.2": "插件联动生成Strm文件同时处理非媒体文件",
"v1.3.1": "增加全量同步",
"v1.3": "移除全量同步、定时同步(谨慎升级)",
"v1.2.7": "增加路径替换规则",

View File

@@ -57,7 +57,7 @@ class CloudStrmCompanion(_PluginBase):
# 插件图标
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/cloudcompanion.png"
# 插件版本
plugin_version = "1.3.1"
plugin_version = "1.3.2"
# 插件作者
plugin_author = "thsrite"
# 作者主页
@@ -106,7 +106,6 @@ class CloudStrmCompanion(_PluginBase):
# 退出事件
_event = threading.Event()
def init_plugin(self, config: dict = None):
# 清空配置
self._strm_dir_conf = {}
@@ -337,24 +336,45 @@ class CloudStrmCompanion(_PluginBase):
# 生成strm文件
self.__create_strm_file(strm_file=target_file,
strm_content=strm_content)
else:
# 复制非媒体文件
if self._copy_files and self._other_mediaext and Path(event_path).suffix.lower() in [ext.strip() for
ext in
self._other_mediaext.split(
",")]:
os.makedirs(os.path.dirname(target_file), exist_ok=True)
shutil.copy2(str(event_path), target_file)
logger.info(f"复制非媒体文件 {str(event_path)}{target_file}")
# 复制字幕文件独立于copy_files检查
if self._copy_subtitles and Path(event_path).suffix.lower() in ['.srt', '.ass', '.ssa', '.sub']:
os.makedirs(os.path.dirname(target_file), exist_ok=True)
shutil.copy2(str(event_path), target_file)
logger.info(f"复制字幕文件 {str(event_path)}{target_file}")
# nfo、jpg等同名文件
pattern = Path(event_path).stem.replace('[', '?').replace(']', '?')
files = list(Path(event_path).parent.glob(f"{pattern}.*"))
logger.debug(f"筛选到 {Path(event_path).parent} 下同名文件 {pattern} {files}")
for file in files:
target_file = str(file).replace(mon_path, strm_dir)
self.__handle_other_files(event_path=str(file), target_file=target_file)
# thumb图片
thumb_file = Path(event_path).parent / (Path(event_path).stem + "-thumb.jpg")
if thumb_file.exists():
target_file = str(thumb_file).replace(mon_path, strm_dir)
self.__handle_other_files(event_path=str(thumb_file), target_file=target_file)
else:
self.__handle_other_files(event_path=event_path, target_file=target_file)
except Exception as e:
logger.error("目录监控发生错误:%s - %s" % (str(e), traceback.format_exc()))
def __handle_other_files(self, event_path: str, target_file: str):
"""
处理非媒体文件
:param event_path: 事件文件路径
"""
# 复制非媒体文件
if self._copy_files and self._other_mediaext and Path(event_path).suffix.lower() in [ext.strip() for
ext in
self._other_mediaext.split(
",")]:
os.makedirs(os.path.dirname(target_file), exist_ok=True)
shutil.copy2(str(event_path), target_file)
logger.info(f"复制非媒体文件 {str(event_path)}{target_file}")
# 复制字幕文件独立于copy_files检查
if self._copy_subtitles and Path(event_path).suffix.lower() in ['.srt', '.ass', '.ssa', '.sub']:
os.makedirs(os.path.dirname(target_file), exist_ok=True)
shutil.copy2(str(event_path), target_file)
logger.info(f"复制字幕文件 {str(event_path)}{target_file}")
def __sava_json(self):
"""
保存json文件
@@ -1316,4 +1336,4 @@ class CloudStrmCompanion(_PluginBase):
self._event.set()
self._scheduler.shutdown()
self._event.clear()
self._scheduler = None
self._scheduler = None