fix 云盘Strm生成v4.1支持自定义媒体类型

This commit is contained in:
thsrite
2024-06-07 23:41:10 +08:00
parent ac8ba98f0a
commit e13a190cee
4 changed files with 41 additions and 9 deletions

View File

@@ -11,7 +11,7 @@ MoviePilot三方插件市场https://github.com/thsrite/MoviePilot-Plugins/
- 站点数据统计 v1.4 (无未读消息版本)(废弃)
- 站点未读消息 v1.9 (依赖于[站点数据统计]插件)
- [云盘Strm生成 v4.0](docs%2FCloudStrm.md)
- [云盘Strm生成 v4.1](docs%2FCloudStrm.md)
- [云盘Strm生成增量版 v1.0](docs%2FCloudStrmIncrement.md)
- [Strm文件模式转换 v1.0](docs%2FStrmConvert.md)
- 清理订阅缓存 v1.0

View File

@@ -3,11 +3,12 @@
"name": "云盘Strm生成",
"description": "监控文件创建生成Strm文件。",
"labels": "云盘",
"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": "回归老版本",
"v3.8": "支持增量路径、支持自定义媒体类型(注:本次更新需修改配置使用)",
"v3.7": "api模式支持启用https",

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"
# 作者主页
@@ -56,6 +56,7 @@ class CloudStrm(_PluginBase):
_cloudurlconf = {}
_cloudpathconf = {}
__cloud_files = []
_rmt_mediaext = ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v"
# 定时器
_scheduler: Optional[BackgroundScheduler] = None
@@ -78,6 +79,8 @@ class CloudStrm(_PluginBase):
self._https = config.get("https")
self._copy_files = config.get("copy_files")
self._monitor_confs = config.get("monitor_confs")
self._rmt_mediaext = config.get(
"rmt_mediaext") or ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v"
# 停止现有任务
self.stop_service()
@@ -233,7 +236,8 @@ class CloudStrm(_PluginBase):
continue
# 不复制非媒体文件时直接过滤掉非媒体文件
if not self._copy_files and Path(file).suffix not in settings.RMT_MEDIAEXT:
if not self._copy_files and Path(file).suffix not in [ext.strip() for ext in
self._rmt_mediaext.split(",")]:
continue
if source_file not in self.__cloud_files:
@@ -280,7 +284,8 @@ class CloudStrm(_PluginBase):
continue
# 不复制非媒体文件时直接过滤掉非媒体文件
if not self._copy_files and Path(file).suffix not in settings.RMT_MEDIAEXT:
if not self._copy_files and Path(file).suffix not in [ext.strip() for ext in
self._rmt_mediaext.split(",")]:
continue
logger.info(f"扫描到新文件 {source_file},正在开始处理")
@@ -343,7 +348,8 @@ class CloudStrm(_PluginBase):
os.makedirs(Path(dest_file).parent)
# 视频文件创建.strm文件
if Path(dest_file).suffix in settings.RMT_MEDIAEXT:
if Path(dest_file).suffix in [ext.strip() for ext in
self._rmt_mediaext.split(",")]:
# 创建.strm文件
self.__create_strm_file(scheme="https" if self._https else "http",
dest_file=dest_file,
@@ -433,7 +439,8 @@ class CloudStrm(_PluginBase):
"copy_files": self._copy_files,
"https": self._https,
"cron": self._cron,
"monitor_confs": self._monitor_confs
"monitor_confs": self._monitor_confs,
"rmt_mediaext": self._rmt_mediaext
})
def get_state(self) -> bool:
@@ -638,6 +645,28 @@ class CloudStrm(_PluginBase):
},
]
},
{
'component': 'VRow',
'content': [
{
'component': 'VCol',
'props': {
'cols': 12
},
'content': [
{
'component': 'VTextarea',
'props': {
'model': 'rmt_mediaext',
'label': '视频格式',
'rows': 2,
'placeholder': ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v"
}
}
]
}
]
},
{
'component': 'VRow',
'content': [
@@ -737,7 +766,8 @@ class CloudStrm(_PluginBase):
"rebuild": False,
"copy_files": False,
"https": False,
"monitor_confs": ""
"monitor_confs": "",
"rmt_mediaext": ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v"
}
def get_page(self) -> List[dict]:

View File

@@ -236,7 +236,8 @@ class CloudStrmIncrement(_PluginBase):
break
if str(parent_path.parent) != str(Path(increment_file).root):
# 父目录非根目录,才删除父目录
if not SystemUtils.exits_files(parent_path, settings.RMT_MEDIAEXT):
if not SystemUtils.exits_files(parent_path,
[ext.strip() for ext in self._rmt_mediaext.split(",")]):
# 当前路径下没有媒体文件则删除
shutil.rmtree(parent_path)
logger.warn(f"增量非保留目录 {parent_path} 已删除")