diff --git a/scripts/writer.py b/scripts/writer.py index eb76333..2c67099 100644 --- a/scripts/writer.py +++ b/scripts/writer.py @@ -7,7 +7,7 @@ PROJECT_ROOT = Path(__file__).parent.parent sys.path.insert(0, str(PROJECT_ROOT)) sys.path.insert(0, str(PROJECT_ROOT / 'platform' / 'backend')) -from db_helper import get_topic_by_id, update_topic_status +from db_helper import get_topic_by_id, update_topic_status, save_article try: from app.core.nvidia_client import call_llm HAVE_LLM = True @@ -424,6 +424,11 @@ class Writer: out_path = out_dir / filename out_path.write_text(html, encoding='utf-8') logger.info(f"HTML 生成: {out_path}") + try: + save_article(self.topic_id, platform, html) + logger.info(f"文章写入数据库: {platform}_{self.topic_id}") + except Exception as e: + logger.warning(f"数据库保存失败: {e}") return out_path def mark_draft(self):