diff --git a/README.md b/README.md index 316c0b5..ec22ccf 100644 --- a/README.md +++ b/README.md @@ -24,5 +24,5 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - [订阅提醒 1.1](docs%2FSubscribeReminder.md) - [Emby观影报告 1.4](docs%2FEmbyReporter.md) - [豆瓣明星热映订阅 1.2](docs%2FActorSubscribe.md) -- [短剧刮削 1.4](docs%2FShortPlayMonitor.md) +- [短剧刮削 1.5](docs%2FShortPlayMonitor.md) diff --git a/docs/ShortPlayMonitor.md b/docs/ShortPlayMonitor.md index cdfcdbf..636751c 100644 --- a/docs/ShortPlayMonitor.md +++ b/docs/ShortPlayMonitor.md @@ -2,6 +2,7 @@ ### 更新记录 +- 1.5 生成tvshow.nfo - 1.4 修复转移后路径重命名 - 1.3 智能重命名 - 1.2 修复转移bug diff --git a/package.json b/package.json index 25e0005..8a4f4e3 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,7 @@ "ShortPlayMonitor": { "name": "短剧刮削", "description": "监控视频短剧创建,刮削。", - "version": "1.4", + "version": "1.5", "icon": "Amule_B.png", "author": "thsrite", "level": 1 diff --git a/plugins/shortplaymonitor/__init__.py b/plugins/shortplaymonitor/__init__.py index 3138409..99d52f9 100644 --- a/plugins/shortplaymonitor/__init__.py +++ b/plugins/shortplaymonitor/__init__.py @@ -5,6 +5,8 @@ import datetime from pathlib import Path from typing import Any, List, Dict, Tuple, Optional +from xml.dom import minidom +from app.utils.dom import DomUtils import pytz from apscheduler.schedulers.background import BackgroundScheduler @@ -46,7 +48,7 @@ class ShortPlayMonitor(_PluginBase): # 插件图标 plugin_icon = "Amule_B.png" # 插件版本 - plugin_version = "1.4" + plugin_version = "1.5" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -234,13 +236,15 @@ class ShortPlayMonitor(_PluginBase): # 硬链接 if isinstance(rename_conf, bool): + target = target_path.replace(dest_dir, "") + parent = Path(Path(target).parents[0]) + last = target.replace(str(parent), "") if rename_conf: - target = target_path.replace(dest_dir, "") - parent = Path(Path(target).parents[0]) - last = target.replace(str(parent), "") # 自定义识别次 title, _ = WordsMatcher().prepare(parent) target_path = Path(dest_dir).joinpath(title + last) + else: + title = parent else: if str(rename_conf) == "smart": target = target_path.replace(dest_dir, "") @@ -274,6 +278,10 @@ class ShortPlayMonitor(_PluginBase): retcode, retmsg = SystemUtils.link(Path(event_path), target_path) if retcode == 0: logger.info(f"文件 {event_path} 硬链接完成") + # 生成 tvshow.nfo + if not (target_path.parent / "tvshow.nfo").exists(): + self.__gen_tv_nfo_file(dir_path=target_path.parent, + title=title) # 生成缩略图 if not (target_path.parent / "poster.jpg").exists(): @@ -295,6 +303,24 @@ class ShortPlayMonitor(_PluginBase): logger.error(f"event_handler_created error: {e}") print(str(e)) + def __gen_tv_nfo_file(self, dir_path: Path, title: str): + """ + 生成电视剧的NFO描述文件 + :param dir_path: 电视剧根目录 + """ + # 开始生成XML + logger.info(f"正在生成电视剧NFO文件:{dir_path.name}") + doc = minidom.Document() + root = DomUtils.add_node(doc, doc, "tvshow") + + # 标题 + DomUtils.add_node(doc, root, "title", title) + DomUtils.add_node(doc, root, "originaltitle", title) + DomUtils.add_node(doc, root, "season", "-1") + DomUtils.add_node(doc, root, "episode", "-1") + # 保存 + self.__save_nfo(doc, dir_path.joinpath("tvshow.nfo")) + def gen_file_thumb(self, file_path: Path, cover_conf: str): """ 处理一个文件