From 8a9de531224385d3c365e96955d880991f27e110 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 17 Jan 2025 20:19:27 +0800 Subject: [PATCH] fix LibraryScraper --- package.v2.json | 3 ++- plugins.v2/libraryscraper/__init__.py | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/package.v2.json b/package.v2.json index c992a7d..60c6555 100644 --- a/package.v2.json +++ b/package.v2.json @@ -145,11 +145,12 @@ "name": "媒体库刮削", "description": "定时对媒体库进行刮削,补齐缺失元数据和图片。", "labels": "刮削", - "version": "2.1", + "version": "2.1.1", "icon": "scraper.png", "author": "jxxghp", "level": 1, "history": { + "v2.1.1": "调整目录计算方法,以支持更多重命名格式", "v2.1": "优化执行周期输入,需要MoviePilot v2.2.1+", "v2.0": "兼容MoviePilot V2 版本", "v1.5": "修复未获取fanart图片的问题", diff --git a/plugins.v2/libraryscraper/__init__.py b/plugins.v2/libraryscraper/__init__.py index d7b9198..0ef398c 100644 --- a/plugins.v2/libraryscraper/__init__.py +++ b/plugins.v2/libraryscraper/__init__.py @@ -27,7 +27,7 @@ class LibraryScraper(_PluginBase): # 插件图标 plugin_icon = "scraper.png" # 插件版本 - plugin_version = "2.1" + plugin_version = "2.1.1" # 插件作者 plugin_author = "jxxghp" # 作者主页 @@ -346,16 +346,19 @@ class LibraryScraper(_PluginBase): if not mtype: file_meta = MetaInfoPath(file_path) mtype = file_meta.type - if mtype == MediaType.TV: - dir_item = (file_path.parent.parent, mtype) - if dir_item not in scraper_paths: - logger.info(f"发现电视剧目录:{dir_item}") - scraper_paths.append(dir_item) - else: - dir_item = (file_path.parent, mtype) - if dir_item not in scraper_paths: - logger.info(f"发现电影目录:{dir_item}") - scraper_paths.append(dir_item) + # 重命名格式 + rename_format = settings.TV_RENAME_FORMAT \ + if mtype == MediaType.TV else settings.MOVIE_RENAME_FORMAT + # 计算重命名中的文件夹层数 + rename_format_level = len(rename_format.split("/")) - 1 + if rename_format_level < 1: + continue + # 取相对路径的第1层目录 + media_path = file_path.parents[rename_format_level - 1] + dir_item = (media_path, mtype) + if dir_item not in scraper_paths: + logger.info(f"发现目录:{dir_item}") + scraper_paths.append(dir_item) # 开始刮削 if scraper_paths: for item in scraper_paths: