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