fix: 合规审查卡死修复 + 小红书复制格式 + today-only过滤
This commit is contained in:
+6
-5
@@ -28,7 +28,7 @@ logging.basicConfig(
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def select_next_topic(topic_id: str = None) -> Dict:
|
||||
def select_next_topic(topic_id: str = None, today_only: bool = False) -> Dict:
|
||||
"""选择并锁定要创作的选题(趋势引擎匹配 → 回退优先级)"""
|
||||
if topic_id:
|
||||
topic = get_topic_by_id(topic_id)
|
||||
@@ -50,7 +50,7 @@ def select_next_topic(topic_id: str = None) -> Dict:
|
||||
except Exception as e:
|
||||
logger.warning(f"选题引擎失效,回退简单策略: {e}")
|
||||
|
||||
topic = get_next_topic(priority='高') or get_next_topic()
|
||||
topic = get_next_topic(priority='高', today_only=today_only) or get_next_topic(today_only=today_only)
|
||||
if not topic:
|
||||
raise ValueError("No available topics to create (all locked or wrong status)")
|
||||
update_topic_status(topic['id'], 'review')
|
||||
@@ -80,11 +80,11 @@ def run_optimizer_step(topic_id: str) -> bool:
|
||||
logger.info(f"compliance_optimizer 完成: {result.stdout.strip()}")
|
||||
return True
|
||||
|
||||
def run_pipeline(topic_id: str = None) -> Dict:
|
||||
def run_pipeline(topic_id: str = None, today_only: bool = False) -> Dict:
|
||||
"""运行完整流水线:研究 → 大纲 → 撰写 → 合规优化"""
|
||||
tid = None
|
||||
try:
|
||||
topic = select_next_topic(topic_id)
|
||||
topic = select_next_topic(topic_id, today_only)
|
||||
tid = topic['id']
|
||||
logger.info(f"开始创作流水线: topic_id={tid}, title={topic.get('title')}")
|
||||
|
||||
@@ -127,9 +127,10 @@ def main():
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description='内容创作流水线(研究→大纲→撰写→合规优化)')
|
||||
parser.add_argument('--topic-id', help='指定选题ID,不指定则自动选择待处理选题')
|
||||
parser.add_argument('--today-only', action='store_true', help='仅处理当天创建的选题')
|
||||
args = parser.parse_args()
|
||||
|
||||
result = run_pipeline(args.topic_id)
|
||||
result = run_pipeline(args.topic_id, today_only=args.today_only)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
sys.exit(0 if result['ok'] else 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user