diff --git a/scripts/writer.py b/scripts/writer.py index 2c67099..1da4c8f 100644 --- a/scripts/writer.py +++ b/scripts/writer.py @@ -18,7 +18,6 @@ import mistune DATA_DIR = PROJECT_ROOT / "automation" / "data" OUTLINE_DIR = DATA_DIR / "outlines" -RELEASE_DIR = DATA_DIR / "releases" TEMPLATES_DIR = PROJECT_ROOT / "automation" / "templates" LOGS_DIR = PROJECT_ROOT / "automation" / "logs" TODAY = datetime.datetime.now().strftime("%Y-%m-%d") @@ -59,8 +58,6 @@ class Writer: if not outline_file.exists(): raise FileNotFoundError(f"Outline not found: {outline_file}") self.outline_content = outline_file.read_text(encoding='utf-8') - self.release_dir = RELEASE_DIR / TODAY - self.release_dir.mkdir(parents=True, exist_ok=True) research_file = DATA_DIR / "research" / TODAY / f"{topic_id}_research.md" self.research_notes = research_file.read_text(encoding='utf-8') if research_file.exists() else "" @@ -417,19 +414,14 @@ class Writer: return html - def save_html(self, html: str, platform: str) -> Path: - out_dir = self.release_dir / platform - out_dir.mkdir(parents=True, exist_ok=True) - filename = f"{platform}_{self.topic_id}.html" - out_path = out_dir / filename - out_path.write_text(html, encoding='utf-8') - logger.info(f"HTML 生成: {out_path}") + def save_html(self, html: str, platform: str) -> str: try: save_article(self.topic_id, platform, html) logger.info(f"文章写入数据库: {platform}_{self.topic_id}") + return f"db:{platform}_{self.topic_id}" except Exception as e: logger.warning(f"数据库保存失败: {e}") - return out_path + return "" def mark_draft(self): update_topic_status(self.topic_id, 'review')