fix 实时软连接v1.4支持自定义视频格式

This commit is contained in:
thsrite
2024-06-21 20:51:05 +08:00
parent 4d5b11d281
commit 253739f48b
3 changed files with 36 additions and 6 deletions

View File

@@ -33,7 +33,7 @@ MoviePilot三方插件市场https://github.com/thsrite/MoviePilot-Plugins/
- [自定义命令 v1.7](docs%2FCustomCommand.md)
- docker自定义任务 v1.3
- 插件彻底卸载 v1.0
- 实时软连接 v1.3
- 实时软连接 v1.4
- 订阅规则自动填充 v2.7
- Emby元数据刷新 v1.1
- Emby媒体标签 v1.2

View File

@@ -378,11 +378,12 @@
"name": "实时软连接",
"description": "监控目录文件变化,媒体文件软连接,其他文件可选复制。",
"labels": "文件管理",
"version": "1.3",
"version": "1.4",
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/softlink.png",
"author": "thsrite",
"level": 1,
"history": {
"v1.4": "支持自定义视频格式",
"v1.3": "异步启动"
}
},

View File

@@ -19,7 +19,7 @@ from app.core.config import settings
from app.core.event import eventmanager, Event
from app.log import logger
from app.plugins import _PluginBase
from app.schemas.types import EventType, MediaType, SystemConfigKey
from app.schemas.types import EventType, SystemConfigKey
from app.utils.system import SystemUtils
lock = threading.Lock()
@@ -52,7 +52,7 @@ class FileSoftLink(_PluginBase):
# 插件图标
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/softlink.png"
# 插件版本
plugin_version = "1.3"
plugin_version = "1.4"
# 插件作者
plugin_author = "thsrite"
# 作者主页
@@ -79,6 +79,9 @@ class FileSoftLink(_PluginBase):
# 存储源目录与目的目录关系
_dirconf: Dict[str, Optional[Path]] = {}
_medias = {}
_rmt_mediaext = ".mp4, .mkv, .ts, .iso,.rmvb, .avi, .mov, .mpeg,.mpg, .wmv, .3gp, .asf, .m4v, .flv, .m2ts, .strm,.tp, .f4v"
# 退出事件
_event = threading.Event()
@@ -96,6 +99,8 @@ class FileSoftLink(_PluginBase):
self._exclude_keywords = config.get("exclude_keywords") or ""
self._cron = config.get("cron")
self._size = config.get("size") or 0
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()
@@ -328,7 +333,8 @@ class FileSoftLink(_PluginBase):
os.makedirs(Path(target_file).parent)
# 媒体文件软连接
if Path(target_file).suffix in settings.RMT_MEDIAEXT:
if Path(target_file).suffix.lower() not in [ext.strip() for ext in
self._rmt_mediaext.split(",")]:
retcode, retmsg = SystemUtils.softlink(file_path, Path(target_file))
logger.info(f"创建媒体文件软连接 {str(file_path)}{target_file} {retcode} {retmsg}")
else:
@@ -556,6 +562,28 @@ class FileSoftLink(_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': [
@@ -587,7 +615,8 @@ class FileSoftLink(_PluginBase):
"monitor_dirs": "",
"exclude_keywords": "",
"cron": "",
"size": 0
"size": 0,
"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]: