mirror of
https://github.com/Hommy-master/capcut-mate.git
synced 2026-09-01 15:32:57 +08:00
增加接口容错处理。
This commit is contained in:
@@ -22,13 +22,16 @@ def audio_infos(
|
||||
str: JSON字符串格式的音频信息
|
||||
|
||||
Raises:
|
||||
ValueError: 当mp3_urls和timelines长度不匹配时
|
||||
无异常抛出,长度不匹配时以最短的为准
|
||||
"""
|
||||
logger.info(f"audio_infos called with {len(mp3_urls)} audio files and {len(timelines)} timelines")
|
||||
|
||||
# 检查参数长度是否匹配
|
||||
# 长度不相等时以最短的为准
|
||||
if len(mp3_urls) != len(timelines):
|
||||
raise ValueError(f"mp3_urls length ({len(mp3_urls)}) does not match timelines length ({len(timelines)})")
|
||||
min_len = min(len(mp3_urls), len(timelines))
|
||||
logger.warning(f"mp3_urls length ({len(mp3_urls)}) does not match timelines length ({len(timelines)}), using shorter length: {min_len}")
|
||||
mp3_urls = mp3_urls[:min_len]
|
||||
timelines = timelines[:min_len]
|
||||
|
||||
# 构建音频信息列表
|
||||
infos = []
|
||||
|
||||
@@ -42,13 +42,16 @@ def caption_infos(
|
||||
str: JSON字符串格式的字幕信息
|
||||
|
||||
Raises:
|
||||
ValueError: 当texts和timelines长度不匹配时
|
||||
无异常抛出,长度不匹配时以最短的为准
|
||||
"""
|
||||
logger.info(f"caption_infos called with {len(texts)} texts and {len(timelines)} timelines")
|
||||
|
||||
# 检查参数长度是否匹配
|
||||
# 长度不相等时以最短的为准
|
||||
if len(texts) != len(timelines):
|
||||
raise ValueError(f"texts length ({len(texts)}) does not match timelines length ({len(timelines)})")
|
||||
min_len = min(len(texts), len(timelines))
|
||||
logger.warning(f"texts length ({len(texts)}) does not match timelines length ({len(timelines)}), using shorter length: {min_len}")
|
||||
texts = texts[:min_len]
|
||||
timelines = timelines[:min_len]
|
||||
|
||||
# 构建字幕信息列表
|
||||
infos = []
|
||||
|
||||
@@ -18,13 +18,16 @@ def effect_infos(
|
||||
str: JSON字符串格式的特效信息
|
||||
|
||||
Raises:
|
||||
ValueError: 当effects和timelines长度不匹配时
|
||||
无异常抛出,长度不匹配时以最短的为准
|
||||
"""
|
||||
logger.info(f"effect_infos called with {len(effects)} effects and {len(timelines)} timelines")
|
||||
|
||||
# 检查参数长度是否匹配
|
||||
# 长度不相等时以最短的为准
|
||||
if len(effects) != len(timelines):
|
||||
raise ValueError(f"effects length ({len(effects)}) does not match timelines length ({len(timelines)})")
|
||||
min_len = min(len(effects), len(timelines))
|
||||
logger.warning(f"effects length ({len(effects)}) does not match timelines length ({len(timelines)}), using shorter length: {min_len}")
|
||||
effects = effects[:min_len]
|
||||
timelines = timelines[:min_len]
|
||||
|
||||
# 构建特效信息列表
|
||||
infos = []
|
||||
|
||||
Reference in New Issue
Block a user