From ba4871715c1ffdae951ce8cd526f2460634d9f8e Mon Sep 17 00:00:00 2001 From: linyq Date: Wed, 7 May 2025 11:34:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(update=5Fscript):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=B7=AF=E5=BE=84=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 item_copy 中初始化 video 字段为空字符串- 根据 item_id 或 orig_timestamp 在 video_result 中查找并添加视频路径 - 更新打印信息,增加视频路径输出 --- app/services/update_script.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/services/update_script.py b/app/services/update_script.py index 30f0082..43f2ff8 100644 --- a/app/services/update_script.py +++ b/app/services/update_script.py @@ -109,6 +109,7 @@ def update_script_timestamps( # 初始化音频和字幕路径为空字符串 item_copy['audio'] = "" item_copy['subtitle'] = "" + item_copy['video'] = "" # 初始化视频路径为空字符串 # 如果提供了音频结果字典且ID存在于音频结果中,直接使用对应的音频路径 if audio_result: @@ -124,6 +125,12 @@ def update_script_timestamps( elif orig_timestamp in subtitle_result: item_copy['subtitle'] = subtitle_result[orig_timestamp] + # 添加视频路径 + if item_id and item_id in video_result: + item_copy['video'] = video_result[item_id] + elif orig_timestamp in video_result: + item_copy['video'] = video_result[orig_timestamp] + # 更新时间戳和计算持续时间 current_duration = 0.0 if item_id and item_id in id_timestamp_mapping: @@ -232,4 +239,4 @@ if __name__ == '__main__': print( f"ID: {item['_id']} | Picture: {item['picture'][:20]}... | Timestamp: {item['timestamp']} | " + f"SourceTimeRange: {item['sourceTimeRange']} | EditedTimeRange: {item.get('editedTimeRange', '')} | " + - f"Duration: {item['duration']} 秒 | Audio: {item['audio']} | Subtitle: {item['subtitle']}") + f"Duration: {item['duration']} 秒 | Audio: {item['audio']} | Video: {item['video']} | Subtitle: {item['subtitle']}")