修改了海报文案默认配置, 目前默认全部为空
This commit is contained in:
parent
a00788964d
commit
ff3159f454
Binary file not shown.
@ -296,8 +296,8 @@ class ContentGenerator:
|
|||||||
for i in range(poster_num):
|
for i in range(poster_num):
|
||||||
default_configs.append({
|
default_configs.append({
|
||||||
"index": i + 1,
|
"index": i + 1,
|
||||||
"main_title": f"景点风光 {i+1}",
|
"main_title": f" ",
|
||||||
"texts": ["自然美景", "人文体验"]
|
"texts": [" ", " "]
|
||||||
})
|
})
|
||||||
return json.dumps(default_configs, ensure_ascii=False)
|
return json.dumps(default_configs, ensure_ascii=False)
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ class ContentGenerator:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f"保存结果到文件时出错: {e}")
|
self.logger.error(f"保存结果到文件时出错: {e}")
|
||||||
# 尝试创建一个简单的备用配置
|
# 尝试创建一个简单的备用配置
|
||||||
fallback_data = [{"main_title": "景点风光", "texts": ["自然美景", "人文体验"], "index": 1}]
|
fallback_data = [{"main_title": " ", "texts": [" ", " "], "index": 1}]
|
||||||
|
|
||||||
# 保存备用数据
|
# 保存备用数据
|
||||||
result_path = os.path.join(output_dir, f"{date_time}_fallback.json")
|
result_path = os.path.join(output_dir, f"{date_time}_fallback.json")
|
||||||
@ -369,23 +369,23 @@ class ContentGenerator:
|
|||||||
# 确保必需字段存在
|
# 确保必需字段存在
|
||||||
fixed_item = {
|
fixed_item = {
|
||||||
"index": item.get("index", i + 1),
|
"index": item.get("index", i + 1),
|
||||||
"main_title": item.get("main_title", f"景点风光 {i+1}"),
|
"main_title": item.get("main_title", f""),
|
||||||
"texts": item.get("texts", ["自然美景", "人文体验"])
|
"texts": item.get("texts", [" ", " "])
|
||||||
}
|
}
|
||||||
|
|
||||||
# 确保texts是列表格式
|
# 确保texts是列表格式
|
||||||
if not isinstance(fixed_item["texts"], list):
|
if not isinstance(fixed_item["texts"], list):
|
||||||
if isinstance(fixed_item["texts"], str):
|
if isinstance(fixed_item["texts"], str):
|
||||||
fixed_item["texts"] = [fixed_item["texts"], "美景体验"]
|
fixed_item["texts"] = [fixed_item["texts"], " "]
|
||||||
else:
|
else:
|
||||||
fixed_item["texts"] = ["自然美景", "人文体验"]
|
fixed_item["texts"] = [" ", " "]
|
||||||
|
|
||||||
# 限制texts最多包含两个元素
|
# 限制texts最多包含两个元素
|
||||||
if len(fixed_item["texts"]) > 2:
|
if len(fixed_item["texts"]) > 2:
|
||||||
fixed_item["texts"] = fixed_item["texts"][:2]
|
fixed_item["texts"] = fixed_item["texts"][:2]
|
||||||
elif len(fixed_item["texts"]) < 2:
|
elif len(fixed_item["texts"]) < 2:
|
||||||
while len(fixed_item["texts"]) < 2:
|
while len(fixed_item["texts"]) < 2:
|
||||||
fixed_item["texts"].append("美景体验")
|
fixed_item["texts"].append(" ")
|
||||||
|
|
||||||
fixed_data.append(fixed_item)
|
fixed_data.append(fixed_item)
|
||||||
|
|
||||||
@ -394,39 +394,39 @@ class ContentGenerator:
|
|||||||
self.logger.warning(f"配置项 {i+1} 是字符串格式,将转换为标准格式")
|
self.logger.warning(f"配置项 {i+1} 是字符串格式,将转换为标准格式")
|
||||||
fixed_item = {
|
fixed_item = {
|
||||||
"index": i + 1,
|
"index": i + 1,
|
||||||
"main_title": f"景点风光 {i+1}",
|
"main_title": f"",
|
||||||
"texts": [item, "美景体验"]
|
"texts": [item, " "]
|
||||||
}
|
}
|
||||||
fixed_data.append(fixed_item)
|
fixed_data.append(fixed_item)
|
||||||
else:
|
else:
|
||||||
self.logger.warning(f"配置项 {i+1} 格式不支持: {type(item)},将使用默认值")
|
self.logger.warning(f"配置项 {i+1} 格式不支持: {type(item)},将使用默认值")
|
||||||
fixed_data.append({
|
fixed_data.append({
|
||||||
"index": i + 1,
|
"index": i + 1,
|
||||||
"main_title": f"景点风光 {i+1}",
|
"main_title": f"",
|
||||||
"texts": ["自然美景", "人文体验"]
|
"texts": [" ", " "]
|
||||||
})
|
})
|
||||||
|
|
||||||
# 如果数据是字典
|
# 如果数据是字典
|
||||||
elif isinstance(data, dict):
|
elif isinstance(data, dict):
|
||||||
fixed_item = {
|
fixed_item = {
|
||||||
"index": data.get("index", 1),
|
"index": data.get("index", 1),
|
||||||
"main_title": data.get("main_title", "景点风光"),
|
"main_title": data.get("main_title", ""),
|
||||||
"texts": data.get("texts", ["自然美景", "人文体验"])
|
"texts": data.get("texts", [" ", " "])
|
||||||
}
|
}
|
||||||
|
|
||||||
# 确保texts是列表格式
|
# 确保texts是列表格式
|
||||||
if not isinstance(fixed_item["texts"], list):
|
if not isinstance(fixed_item["texts"], list):
|
||||||
if isinstance(fixed_item["texts"], str):
|
if isinstance(fixed_item["texts"], str):
|
||||||
fixed_item["texts"] = [fixed_item["texts"], "美景体验"]
|
fixed_item["texts"] = [fixed_item["texts"], " "]
|
||||||
else:
|
else:
|
||||||
fixed_item["texts"] = ["自然美景", "人文体验"]
|
fixed_item["texts"] = [" ", " "]
|
||||||
|
|
||||||
# 限制texts最多包含两个元素
|
# 限制texts最多包含两个元素
|
||||||
if len(fixed_item["texts"]) > 2:
|
if len(fixed_item["texts"]) > 2:
|
||||||
fixed_item["texts"] = fixed_item["texts"][:2]
|
fixed_item["texts"] = fixed_item["texts"][:2]
|
||||||
elif len(fixed_item["texts"]) < 2:
|
elif len(fixed_item["texts"]) < 2:
|
||||||
while len(fixed_item["texts"]) < 2:
|
while len(fixed_item["texts"]) < 2:
|
||||||
fixed_item["texts"].append("美景体验")
|
fixed_item["texts"].append(" ")
|
||||||
|
|
||||||
fixed_data.append(fixed_item)
|
fixed_data.append(fixed_item)
|
||||||
|
|
||||||
@ -435,16 +435,16 @@ class ContentGenerator:
|
|||||||
self.logger.warning(f"数据格式不支持: {type(data)},将使用默认值")
|
self.logger.warning(f"数据格式不支持: {type(data)},将使用默认值")
|
||||||
fixed_data.append({
|
fixed_data.append({
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"main_title": "景点风光",
|
"main_title": " ",
|
||||||
"texts": ["自然美景", "人文体验"]
|
"texts": [" ", " "]
|
||||||
})
|
})
|
||||||
|
|
||||||
# 确保至少有一个配置项
|
# 确保至少有一个配置项
|
||||||
if not fixed_data:
|
if not fixed_data:
|
||||||
fixed_data.append({
|
fixed_data.append({
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"main_title": "景点风光",
|
"main_title": " ",
|
||||||
"texts": ["自然美景", "人文体验"]
|
"texts": [" ", " "]
|
||||||
})
|
})
|
||||||
|
|
||||||
return fixed_data
|
return fixed_data
|
||||||
@ -506,8 +506,8 @@ class ContentGenerator:
|
|||||||
for i in range(poster_num):
|
for i in range(poster_num):
|
||||||
default_configs.append({
|
default_configs.append({
|
||||||
"index": i + 1,
|
"index": i + 1,
|
||||||
"main_title": f"景点风光 {i+1}",
|
"main_title": f" ",
|
||||||
"texts": ["自然美景", "人文体验"]
|
"texts": [" ", " "]
|
||||||
})
|
})
|
||||||
return default_configs
|
return default_configs
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user