fix: template
This commit is contained in:
@@ -177,15 +177,34 @@ def get_template_detail(
|
||||
tracks_data = draft_content.get('tracks', [])
|
||||
materials_data = draft_content.get('materials', [])
|
||||
|
||||
# 确保 tracks_data 和 materials_data 是列表
|
||||
if not isinstance(tracks_data, list):
|
||||
logger.warning(f"tracks_data is not a list: {type(tracks_data)}")
|
||||
tracks_data = []
|
||||
|
||||
if not isinstance(materials_data, list):
|
||||
logger.warning(f"materials_data is not a list: {type(materials_data)}")
|
||||
materials_data = []
|
||||
|
||||
# 创建素材查找表
|
||||
materials_lookup = {}
|
||||
for material in materials_data:
|
||||
# 确保 material 是字典
|
||||
if not isinstance(material, dict):
|
||||
logger.warning(f"material is not a dict: {type(material)}")
|
||||
continue
|
||||
|
||||
material_id = material.get('id', '')
|
||||
if material_id:
|
||||
materials_lookup[material_id] = material
|
||||
|
||||
# 处理轨道
|
||||
for idx, track_data in enumerate(tracks_data):
|
||||
# 确保 track_data 是字典
|
||||
if not isinstance(track_data, dict):
|
||||
logger.warning(f"track_data is not a dict: {type(track_data)}")
|
||||
continue
|
||||
|
||||
track = {
|
||||
'id': track_data.get('id', f'track_{idx}'),
|
||||
'name': track_data.get('name', f'轨道 {idx + 1}'),
|
||||
@@ -197,7 +216,18 @@ def get_template_detail(
|
||||
|
||||
# 处理片段
|
||||
segments_data = track_data.get('segments', [])
|
||||
|
||||
# 确保 segments_data 是列表
|
||||
if not isinstance(segments_data, list):
|
||||
logger.warning(f"segments_data is not a list: {type(segments_data)}")
|
||||
segments_data = []
|
||||
|
||||
for segment_data in segments_data:
|
||||
# 确保 segment_data 是字典
|
||||
if not isinstance(segment_data, dict):
|
||||
logger.warning(f"segment_data is not a dict: {type(segment_data)}")
|
||||
continue
|
||||
|
||||
# 获取时间信息
|
||||
start_time = segment_data.get('start', 0) / 1000.0 # 转换为秒
|
||||
end_time = segment_data.get('end', 0) / 1000.0
|
||||
|
||||
Reference in New Issue
Block a user