novel-doomsday-resurgence/fix_empty_titles_v2.py
AI写作助手 2fb9d96320 完整提交: 章节整合操作 + 系统状态更新
包含以下更改:
1. 章节整合: 第131-145章 → 第131-133章
2. 章节重新编号: 146章 → 134章
3. 状态文件更新: chapter_summaries.json
4. 配置更新: inkos.json 添加整合历史
5. 日志记录: integration_20260402.md
6. 备份文件: 章节和状态文件备份
7. 快照文件: system_snapshot_20260402_1815.md

整合效果:
- 重复章节精简: 15章 → 3章 (80%精简)
- 总章节数: 146章 → 134章 (8.2%精简)
- 剧情推进: 从停滞重复变为紧凑连贯
- 读者体验: 大幅改善阅读流畅度

系统状态:
- inkos守护进程: 运行中 (PID: 1899789)
- 章节进度: 134/200章 (67%完成)
- 总字数: 549,363字
- 已知问题: inkos 0.6.3 验证bug

下一步计划:
1. 监控inkos系统稳定性
2. 修复inkos验证bug
3. 继续推进剩余66章创作
2026-04-02 18:20:07 +08:00

50 lines
1.7 KiB
Python

import json
import sys
import os
def fix_index_json(filepath):
try:
with open(filepath, 'r', encoding='utf-8') as f:
data = json.load(f)
if not isinstance(data, list):
print(f"数据结构不是数组,而是 {type(data)}")
return
fixed_count = 0
for i, item in enumerate(data):
if not item.get('title') or str(item.get('title', '')).strip() == '':
# 生成一个默认标题
chapter_num = item.get('number', i+1)
item['title'] = f"{chapter_num}"
fixed_count += 1
print(f"修复第 {i+1} 项 (章节号: {chapter_num}) - 标题设置为: {item['title']}")
if fixed_count > 0:
# 备份原文件
backup_path = filepath + '.backup_fix'
with open(backup_path, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
print(f"已创建备份: {backup_path}")
# 写入修复后的文件
with open(filepath, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
print(f"修复完成,修复了 {fixed_count} 个空标题")
else:
print("没有发现空标题,无需修复")
except Exception as e:
print(f"处理文件时出错: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
index_path = "books/末日重生-开局囤货十亿物资/chapters/index.json"
if os.path.exists(index_path):
fix_index_json(index_path)
else:
print(f"文件不存在: {index_path}")