Refactor AI daily report pipeline

This commit is contained in:
Mimikko-zeus
2026-06-04 15:21:56 +08:00
parent 94e18ce22d
commit 5a98696255
64 changed files with 4778 additions and 1316 deletions

View File

@@ -0,0 +1,32 @@
from __future__ import annotations
import json
from typing import Any, Callable
from ai_daily_report.models import SourceConfig
FetchText = Callable[[str, int], str]
def fetch_aihot(config: SourceConfig, run_date: str, fetch_text: FetchText) -> list[dict[str, Any]]:
data = json.loads(fetch_text(f"https://aihot.virxact.com/api/public/daily/{run_date}", config.timeout_seconds))
items: list[dict[str, Any]] = []
generated = data.get("generatedAt")
for section in data.get("sections", []) or []:
for raw in section.get("items", []) or []:
items.append(
{
"source_group": config.name,
"source_label": raw.get("sourceName") or config.name,
"title_raw": raw.get("title") or "",
"summary_raw": raw.get("summary") or "",
"url": raw.get("sourceUrl") or "",
"published_at": generated,
"origin_type": "aihot_json",
"section_hint": section.get("label") or "",
"language_hint": "zh",
}
)
return items