iflytek summary + cleanup

This commit is contained in:
Beast
2026-06-13 16:47:59 +08:00
parent f883c1ff31
commit 6dd5d86c8b
11 changed files with 433 additions and 195 deletions

View File

@ -3,20 +3,29 @@
from datetime import datetime
def format_daily_digest(date, ai_body):
"""Wrap AI-generated Markdown body with frontmatter."""
def format_daily_digest(date, ai_body, tags=None, doc_type="daily-digest"):
"""Wrap AI-generated Markdown body with frontmatter, word count and reading time."""
date_str = date.strftime("%Y-%m-%d")
weekday = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"][date.weekday()]
char_count = len(ai_body.replace(" ", "").replace("\n", ""))
read_min = max(1, round(char_count / 300))
if tags is None:
tags = ["灵感收集器", "每日总结"]
tag_str = ", ".join(["'" + t + "'" for t in tags])
lines = []
lines.append("---")
lines.append("date: " + date_str)
lines.append("type: daily-digest")
lines.append("tags: [灵感收集器, 每日总结]")
lines.append("type: " + doc_type)
lines.append("tags: [" + tag_str + "]")
lines.append("---")
lines.append("")
lines.append("# " + date_str + " 灵感摘要 · " + weekday)
lines.append("")
lines.append("> 本文共 **" + str(char_count) + "** 字 · 预计阅读 **" + str(read_min) + "** 分钟")
lines.append("")
lines.append("## AI 分析(自动生成,请勿编辑)")
lines.append("")
lines.append(ai_body)