version 1

This commit is contained in:
2025-07-15 14:11:39 +08:00
parent 81d4874926
commit dc94cc41c2
16 changed files with 1872 additions and 445 deletions

View File

@ -7,15 +7,35 @@ PROJECTS_DIR.mkdir(exist_ok=True)
SHARED_ASSETS_DIR.mkdir(exist_ok=True)
def get_project_paths(project_name: str) -> dict:
"""為給定專案回傳一個包含所有重要路徑的字典。"""
"""
為給定專案回傳一個包含所有重要路徑的字典。
這是一個純粹的、無副作用的函式,是路徑規則的「單一事實來源」。
"""
if not project_name:
return {}
project_root = PROJECTS_DIR / project_name
output_dir = project_root / "output" # 將所有生成物放在 output 資料夾
return {
"root": project_root,
"data": project_root / "data.json",
"audio": project_root / "audio",
"output": project_root / "output",
"combined_audio": project_root / "output" / "combined_audio.wav",
"ass_file": project_root / "output" / f"{project_name}.ass"
}
"audio": project_root / "audio", # 原始音訊片段
"output": output_dir, # 輸出的根目錄
"temp_video":output_dir / "temp_video",
"combined_audio": output_dir / "combined_audio.wav",
"ass_file": output_dir / "subtitles.ass",
"final_video": output_dir / f"{project_name}_final_video.mp4"
}
def get_project_list() -> list[str]:
"""
掃描專案根目錄並回傳所有專案名稱的列表。
這將成為獲取專案列表的「單一事實來源」。
"""
if not PROJECTS_DIR.is_dir():
PROJECTS_DIR.mkdir() # 如果根目錄不存在,就建立它
return []
# 確保只回傳目錄,並過濾掉像 .DS_Store 這樣的隱藏檔案
project_names = [d.name for d in PROJECTS_DIR.iterdir() if d.is_dir() and not d.name.startswith('.')]
project_names.sort() # 排序以獲得一致的顯示順序
return project_names