From 69c3634731283c3e9f8a23f6dffdefcfd58800ab Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Wed, 31 Dec 2025 14:58:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=9B=BE=E7=89=87=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/image_migrate.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/image_migrate.py b/scripts/image_migrate.py index cb63ff32..1d0fed97 100755 --- a/scripts/image_migrate.py +++ b/scripts/image_migrate.py @@ -672,13 +672,18 @@ def create_example_config(config_file: str): def read_image_paths(image_list_file: str) -> List[str]: """从文件读取图片路径列表""" paths = [] + not_images = [] try: with open(image_list_file, "r", encoding="utf-8") as f: for line in f: line = line.strip() if line and not line.startswith("#"): - paths.append(line) - print(f"从文件读取 {len(paths)} 个图片路径") + if not line.endswith((".png", ".jpeg", ".jpg", ".gif", ".webp")): + not_images.append(line) + else: + paths.append(line) + print(f"从文件中读取到 {len(paths)} 个图片路径数据行") + print(f"从文件中读取到 {len(not_images)} 个非图片路径数据行") except Exception as e: print(f"读取图片路径文件失败 {image_list_file}: {e}") return paths @@ -889,9 +894,14 @@ def main(): print("请使用 --input 指定文件或直接在命令行提供路径") sys.exit(1) + origin_paths = image_paths # 去重 image_paths = list(set(image_paths)) + repeats = len(origin_paths) - len(image_paths) + if repeats > 0: + print(f"从文件中读取到 {repeats} 个重复图片路径数据行") + # 创建并运行迁移器 migrator = ImageMigrator( source_config=source_config,