mirror of
https://github.com/linyqh/NarratoAI.git
synced 2025-12-13 12:12:50 +00:00
优化保存脚本必须刷新浏览器才能加载下拉框的bug
This commit is contained in:
parent
7b7e2391b3
commit
d50c6e695c
@ -339,9 +339,6 @@ def start_subclip(task_id, params: VideoClipParams, subclip_path_videos):
|
|||||||
max_clip_duration = params.video_clip_duration
|
max_clip_duration = params.video_clip_duration
|
||||||
|
|
||||||
logger.info("\n\n## 1. 读取json")
|
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)
|
video_script_path = path.join(params.video_clip_json)
|
||||||
# 判断json文件是否存在
|
# 判断json文件是否存在
|
||||||
if path.exists(video_script_path):
|
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}")
|
logger.debug(f"原json时间戳: \n{time_list}")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("#@#@#@", params.video_clip_json)
|
|
||||||
raise ValueError("解说文案不存在!检查文案名称是否正确。")
|
raise ValueError("解说文案不存在!检查文案名称是否正确。")
|
||||||
|
|
||||||
# video_script = llm.text_polishing(context=video_script, language=params.video_language)
|
# video_script = llm.text_polishing(context=video_script, language=params.video_language)
|
||||||
|
|||||||
@ -385,9 +385,8 @@ with left_panel:
|
|||||||
save_path = os.path.join(script_dir, f"{timestamp}.json")
|
save_path = os.path.join(script_dir, f"{timestamp}.json")
|
||||||
|
|
||||||
# 尝试解析输入的 JSON 数据
|
# 尝试解析输入的 JSON 数据
|
||||||
# input_json = str(video_clip_json_details).replace("'", '"')
|
|
||||||
input_json = str(video_clip_json_details)
|
input_json = str(video_clip_json_details)
|
||||||
logger.error(input_json)
|
# 去掉json的头尾标识
|
||||||
input_json = input_json.strip('```json').strip('```')
|
input_json = input_json.strip('```json').strip('```')
|
||||||
try:
|
try:
|
||||||
data = json.loads(input_json)
|
data = json.loads(input_json)
|
||||||
@ -411,8 +410,9 @@ with left_panel:
|
|||||||
json.dump(data, file, ensure_ascii=False, indent=4)
|
json.dump(data, file, ensure_ascii=False, indent=4)
|
||||||
# 将data的值存储到 session_state 中,类似缓存
|
# 将data的值存储到 session_state 中,类似缓存
|
||||||
st.session_state['video_script_list'] = data
|
st.session_state['video_script_list'] = data
|
||||||
|
st.session_state['video_clip_json_path'] = save_path
|
||||||
logger.debug(f"脚本内容已成功保存到 {save_path}")
|
# 刷新页面
|
||||||
|
st.rerun()
|
||||||
|
|
||||||
with button_columns[1]:
|
with button_columns[1]:
|
||||||
if st.button(tr("Crop Video"), key="auto_crop_video", use_container_width=True):
|
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")
|
start_button = st.button(tr("Generate Video"), use_container_width=True, type="primary")
|
||||||
if start_button:
|
if start_button:
|
||||||
config.save_config()
|
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:
|
if not params.video_clip_json:
|
||||||
st.error(tr("脚本文件不能为空"))
|
st.error(tr("脚本文件不能为空"))
|
||||||
scroll_to_bottom()
|
scroll_to_bottom()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user