From 740b93558dac3bb3082b9e6e125f1d98eec87ed9 Mon Sep 17 00:00:00 2001 From: ddean2009 Date: Wed, 24 Jul 2024 22:43:48 +0800 Subject: [PATCH] bug fix --- .gitignore | 1 + config/config.example.yml | 1 - tools/utils.py | 27 ++++++++++++++------------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 76b31f2..409c0b3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ config/sceneconfig.yml config/sceneconfig_linux.yml config/config.yml +config/config-back.yml *.db temp/* hunjian_main.py diff --git a/config/config.example.yml b/config/config.example.yml index 85dfad1..26b09f4 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -76,7 +76,6 @@ publisher: enable: True title_prefix: 标题前缀 collection: 集合名称 - tags: douyin: enable: True title_prefix: 标题前缀 diff --git a/tools/utils.py b/tools/utils.py index 80267ab..eefe08b 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -68,21 +68,22 @@ def get_file_from_dir(file_dir, extension): def get_file_map_from_dir(file_dir, extension): extension_list = [ext.strip() for ext in extension.split(',')] # 确保提供的是绝对路径 - file_dir = os.path.abspath(file_dir) # 所有文件的列表 file_map = {} - - # 遍历file_dir中的文件 - for filename in os.listdir(file_dir): - # print('filename:', filename) - file_extension = os.path.splitext(filename)[1] - # 检查文件名是否以img_file_prefix开头 并且后缀是.txt - if file_extension in extension_list: - # 构建完整的文件路径 - file_path = os.path.join(file_dir, filename) - # 确保这是一个文件而不是目录 - if os.path.isfile(file_path): - file_map[file_path] = os.path.split(file_path)[1] + if file_dir is not None and os.path.exists(file_dir): + file_dir = os.path.abspath(file_dir) + + # 遍历file_dir中的文件 + for filename in os.listdir(file_dir): + # print('filename:', filename) + file_extension = os.path.splitext(filename)[1] + # 检查文件名是否以img_file_prefix开头 并且后缀是.txt + if file_extension in extension_list: + # 构建完整的文件路径 + file_path = os.path.join(file_dir, filename) + # 确保这是一个文件而不是目录 + if os.path.isfile(file_path): + file_map[file_path] = os.path.split(file_path)[1] return file_map