From d50c6e695ca3762c8f788fb1cc15e4f350df1c54 Mon Sep 17 00:00:00 2001 From: linyq Date: Tue, 27 Aug 2024 15:46:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=9D=E5=AD=98=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=BF=85=E9=A1=BB=E5=88=B7=E6=96=B0=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8=E6=89=8D=E8=83=BD=E5=8A=A0=E8=BD=BD=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/task.py | 4 ---- webui/Main.py | 15 ++++++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/services/task.py b/app/services/task.py index 2f9e365..32b0e44 100644 --- a/app/services/task.py +++ b/app/services/task.py @@ -339,9 +339,6 @@ def start_subclip(task_id, params: VideoClipParams, subclip_path_videos): max_clip_duration = params.video_clip_duration logger.info("\n\n## 1. 读取json") - # video_script = params.video_script.strip() - # 搜索 ../storage 目录下 名称为 video_subject 的docx文件,并读出所有字符串 - # video_script_path = path.join('E:\\Projects\\linyq\\MoneyPrinterLin\\txt.txt\\txt2.json') video_script_path = path.join(params.video_clip_json) # 判断json文件是否存在 if path.exists(video_script_path): @@ -356,7 +353,6 @@ def start_subclip(task_id, params: VideoClipParams, subclip_path_videos): logger.debug(f"原json时间戳: \n{time_list}") else: - print("#@#@#@", params.video_clip_json) raise ValueError("解说文案不存在!检查文案名称是否正确。") # video_script = llm.text_polishing(context=video_script, language=params.video_language) diff --git a/webui/Main.py b/webui/Main.py index eaaca55..4c87202 100644 --- a/webui/Main.py +++ b/webui/Main.py @@ -385,9 +385,8 @@ with left_panel: save_path = os.path.join(script_dir, f"{timestamp}.json") # 尝试解析输入的 JSON 数据 - # input_json = str(video_clip_json_details).replace("'", '"') input_json = str(video_clip_json_details) - logger.error(input_json) + # 去掉json的头尾标识 input_json = input_json.strip('```json').strip('```') try: data = json.loads(input_json) @@ -411,8 +410,9 @@ with left_panel: json.dump(data, file, ensure_ascii=False, indent=4) # 将data的值存储到 session_state 中,类似缓存 st.session_state['video_script_list'] = data - - logger.debug(f"脚本内容已成功保存到 {save_path}") + st.session_state['video_clip_json_path'] = save_path + # 刷新页面 + st.rerun() with button_columns[1]: if st.button(tr("Crop Video"), key="auto_crop_video", use_container_width=True): @@ -731,7 +731,12 @@ with st.expander(tr("Video Check"), expanded=False): start_button = st.button(tr("Generate Video"), use_container_width=True, type="primary") if start_button: config.save_config() - task_id = st.session_state['task_id'] + task_id = st.session_state.get('task_id') + params.video_clip_json = st.session_state['video_clip_json_path'] + if not task_id: + st.error(tr("请先裁剪视频")) + scroll_to_bottom() + st.stop() if not params.video_clip_json: st.error(tr("脚本文件不能为空")) scroll_to_bottom()