iflytek summary + cleanup
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user