✨ 核心功能
账户文件管理
支持导入Excel/CSV账户文件,自动解析并生成JSON配置文件,方便其他程序调用。
智能数据筛选
根据转化数阈值自动筛选符合条件的视频素材,支持批量处理多个CSV文件。
MD文件生成
自动生成Markdown格式的视频列表文件,支持实时预览和文件管理。
缓存清理
一键清除CSV和MD缓存文件,保持数据目录整洁,避免冗余数据堆积。
🔄 工作流程
1
导入数据
将CSV文件放入指定目录,或导入账户文件
2
设置阈值
输入转化数阈值,筛选高质量素材
3
生成素材
一键生成筛选后的MD文件列表
4
导出使用
查看预览或导出JSON配置
🛠️ 技术栈
本项目采用Python开发,使用Tkinter构建可视化界面,Pandas进行数据处理,支持多种数据格式的导入导出。
Python 3.10+
Tkinter
Pandas
JSON
CSV/Excel
💻 核心代码展示
gui_init.py
class ToolGUI:
def __init__(self, root):
self.root = root
self.root.title("视频素材处理工具")
self.root.geometry("850x650")
self.root.resizable(True, True)
# 创建数据文件夹结构
self.create_data_directories()
# 创建账户文件目录
self.create_account_directory()
# 设置样式
style = ttk.Style()
style.configure("TButton", font=("微软雅黑", 10), padding=8)
style.configure("TLabel", font=("微软雅黑", 10))
style.configure("Header.TLabel", font=("微软雅黑", 12, "bold"))
json_generator.py
def generate_json_config(self):
"""生成JSON配置文件"""
file_ext = os.path.splitext(self.selected_account_path)[1].lower()
if file_ext in ['.csv']:
df = pd.read_csv(self.selected_account_path)
elif file_ext in ['.xlsx', '.xls']:
df = pd.read_excel(self.selected_account_path)
# 将DataFrame转换为字典
account_data = df.to_dict('records')
# 保存为JSON文件
json_path = os.path.join(self.get_account_directory(), json_filename)
with open(json_path, 'w', encoding='utf-8') as f:
json.dump(account_data, f, ensure_ascii=False, indent=4)
material_filter.py
def generate_material(self):
"""生成素材功能"""
threshold = int(self.threshold_entry.get().strip())
csv_dir = self.get_csv_directory()
csv_files = [f for f in os.listdir(csv_dir)
if f.startswith('视频库_') and f.endswith('.csv')]
all_video_names = []
for file in csv_files:
df = pd.read_csv(os.path.join(csv_dir, file))
# 筛选转化数 >= 阈值的视频名称
filtered = df[df['转化数'] >= threshold]
all_video_names.extend(filtered['视频名称'].tolist())
# 去重并保存
unique_video_names = list(set(all_video_names))
directory_manager.py
def create_data_directories(self):
"""创建数据文件夹结构"""
try:
# 创建主数据目录
os.makedirs(self.get_data_directory(), exist_ok=True)
# 创建CSV子目录
os.makedirs(self.get_csv_directory(), exist_ok=True)
# 创建MD子目录
os.makedirs(self.get_md_directory(), exist_ok=True)
# 创建账户文件目录
os.makedirs(self.get_account_directory(), exist_ok=True)
except Exception as e:
self.update_status(f"创建数据目录时出错: {str(e)}")