update
This commit is contained in:
87
app.py
87
app.py
@ -8,19 +8,8 @@ from ui_fragments import tab0_data_processing,tab1_asset_generation,tab2_online_
|
||||
# --- 本地模組匯入 ---
|
||||
from utils.paths import get_project_paths, SHARED_ASSETS_DIR, PROJECTS_DIR,get_project_list
|
||||
import callbacks
|
||||
from utils.helpers import get_notion_page_titles, display_operation_status
|
||||
# from ui_fragments.audio_manager import audio_management_fragment
|
||||
# from ui_fragments.video_manager import video_management_fragment
|
||||
# from ui_fragments.video_search import video_search_fragment
|
||||
from utils.helpers import get_notion_page_titles
|
||||
|
||||
# --- 匯入外部處理腳本 ---
|
||||
# 雖然這些腳本主要在 callbacks 中被呼叫,但在此處匯入有助於理解全貌
|
||||
# from scripts.step1_notion_sync import update_project_from_notion
|
||||
# from scripts.step2_translate_ipa import run_step2_translate_ipa
|
||||
# from scripts.step3_generate_audio import run_step3_generate_audio
|
||||
# from scripts.step4_concatenate_audio import run_step4_concatenate_audio
|
||||
# from scripts.step5_generate_ass import run_step5_generate_ass
|
||||
# from scripts.step6_assemble_video import run_step6_assemble_video
|
||||
|
||||
# --- Streamlit UI 設定 ---
|
||||
st.set_page_config(layout="wide", page_title="英語影片自動化工作流程")
|
||||
@ -46,7 +35,7 @@ if 'project_selector' not in st.session_state:
|
||||
|
||||
# --- UI 介面 ---
|
||||
st.title("🎬 英語影片自動化工作流程")
|
||||
display_operation_status()
|
||||
|
||||
# --- 側邊欄 ---
|
||||
with st.sidebar:
|
||||
st.header("API & Project Control")
|
||||
@ -62,7 +51,7 @@ with st.sidebar:
|
||||
page_titles_map = get_notion_page_titles(notion_api_key, notion_database_id)
|
||||
st.session_state.page_titles_map = page_titles_map
|
||||
st.selectbox("選擇 Notion 頁面以建立新專案:",
|
||||
options=[""] + list(page_titles_map.keys()),
|
||||
options=[""] + sorted(list(page_titles_map.keys())),
|
||||
key="selected_title")
|
||||
|
||||
if st.session_state.selected_title:
|
||||
@ -78,7 +67,7 @@ with st.sidebar:
|
||||
st.header("2. 選擇現有專案")
|
||||
|
||||
# 1. 介面邏輯變得極簡:直接呼叫工具函式
|
||||
existing_projects = get_project_list()
|
||||
existing_projects = sorted(get_project_list())
|
||||
|
||||
# 2. UI 只負責綁定 key 和 on_change 事件
|
||||
st.selectbox(
|
||||
@ -106,79 +95,23 @@ else:
|
||||
label_visibility="collapsed")
|
||||
st.markdown("---")
|
||||
|
||||
# # --- 分頁內容 ---
|
||||
# --- 分頁內容 ---
|
||||
# 第一頁,notion及專案資料
|
||||
if active_tab == tab_names[0]:
|
||||
with st.container(border=True):
|
||||
tab0_data_processing.render_tab(project)
|
||||
|
||||
# 第二頁,音訊字幕
|
||||
if active_tab == tab_names[1]:
|
||||
tab1_asset_generation.render_tab(project, callbacks)
|
||||
|
||||
|
||||
# 第三頁,背景影片搜尋
|
||||
if active_tab == tab_names[2]:
|
||||
tab2_online_video_search.render_tab(project,callbacks)
|
||||
|
||||
# 第四頁,影片合成
|
||||
if active_tab == tab_names[3]:
|
||||
tab3_video_composition.render_tab(project, callbacks)
|
||||
|
||||
st.divider()
|
||||
|
||||
# st.subheader("步驟 6.1: 管理與選擇共享影片素材")
|
||||
# shared_videos = [""] + [f.name for f in sorted(SHARED_ASSETS_DIR.glob('*.mp4'))] + [f.name for f in sorted(SHARED_ASSETS_DIR.glob('*.mov'))]
|
||||
# with st.container(border=True):
|
||||
# st.markdown("##### 從共享素材庫中選擇影片")
|
||||
# c1, c2 = st.columns(2)
|
||||
# with c1:
|
||||
# logo_selection = st.selectbox("選擇 Logo 影片:", shared_videos, key="logo_select")
|
||||
# open_selection = st.selectbox("選擇開場影片:", shared_videos, key="open_select")
|
||||
# with c2:
|
||||
# end_selection = st.selectbox("選擇結尾影片:", shared_videos, key="end_select")
|
||||
|
||||
# with st.expander("**上傳新的共享素材**"):
|
||||
# st.markdown("上傳的影片將存入 `shared_assets` 公共資料夾,可供所有專案重複使用。")
|
||||
# uploaded_files = st.file_uploader("上傳新的影片到共享素材庫", type=["mp4", "mov"], accept_multiple_files=True, label_visibility="collapsed")
|
||||
# if uploaded_files:
|
||||
# for uploaded_file in uploaded_files:
|
||||
# with open(SHARED_ASSETS_DIR / uploaded_file.name, "wb") as f:
|
||||
# f.write(uploaded_file.getbuffer())
|
||||
# st.success(f"成功上傳 {len(uploaded_files)} 個檔案到共享素材庫!")
|
||||
# time.sleep(1)
|
||||
# st.rerun()
|
||||
|
||||
# st.divider()
|
||||
# st.subheader("步驟 6.2: 執行最終影片合成")
|
||||
# all_videos_selected = all([logo_selection, open_selection, end_selection])
|
||||
# if not all_videos_selected:
|
||||
# st.info("請從上方的下拉選單中選擇所有四個影片以啟用合成按鈕。")
|
||||
|
||||
# st.button(
|
||||
# "🎬 合成最終影片",
|
||||
# on_click=callback_assemble_final_video,
|
||||
# kwargs={
|
||||
# "paths": paths,
|
||||
# "source": "assemble_video",
|
||||
# "spinner_text": "影片合成中,請稍候...",
|
||||
# "project_path": paths['root'], # 傳遞給 run_step6_assemble_video
|
||||
# "logo_video": SHARED_ASSETS_DIR / logo_selection if logo_selection else None,
|
||||
# "open_video": SHARED_ASSETS_DIR / open_selection if open_selection else None,
|
||||
# "end_video": SHARED_ASSETS_DIR / end_selection if end_selection else None
|
||||
# },
|
||||
# disabled=not all_videos_selected
|
||||
# )
|
||||
|
||||
|
||||
# if st.session_state.final_video_path and Path(st.session_state.final_video_path).exists():
|
||||
# st.divider()
|
||||
# st.header("🎉 影片製作完成!")
|
||||
# st.checkbox("顯示/隱藏影片", key="show_video", value=True)
|
||||
# if st.session_state.show_video:
|
||||
# st.video(st.session_state.final_video_path)
|
||||
|
||||
# with open(st.session_state.final_video_path, "rb") as file:
|
||||
# st.download_button(
|
||||
# "📥 下載專案影片",
|
||||
# data=file,
|
||||
# file_name=Path(st.session_state.final_video_path).name,
|
||||
# mime="video/mp4",
|
||||
# use_container_width=True
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user