"""抓取 kline8.com 缠论《教你炒股票》系列的配置常量。"""

from pathlib import Path

# —— 源站点 ——
BASE_URL = "https://www.kline8.com"
INDEX_URL = f"{BASE_URL}/chanlun?p=0"  # p=0 是目录页


def article_url(p: int) -> str:
    """第 p 篇文章的 URL（p=1 即第一篇）。"""
    return f"{BASE_URL}/chanlun?p={p}"


# —— 请求参数 ——
USER_AGENT = (
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
    "AppleWebKit/537.36 (KHTML, like Gecko) "
    "Chrome/124.0 Safari/537.36"
)
REQUEST_TIMEOUT = 20  # 秒
REQUEST_DELAY = 0.35  # 每次请求间隔（秒），礼貌抓取
MAX_RETRIES = 3

# 源站个别篇目 <h5> 日期残缺（仅写"2006"），用已知准确时间纠偏（精确到分钟）
DATE_OVERRIDES = {
    91: "2007-12-17 21:40",
    107: "2008-08-19 16:10",
}

# —— 本项目产物（归档） ——
PROJECT_ROOT = Path(__file__).resolve().parent
DATA_DIR = PROJECT_ROOT / "data"
RAW_DIR = DATA_DIR / "raw"          # 原始 HTML 归档
MARKDOWN_DIR = DATA_DIR / "markdown"  # 每篇 markdown 归档
JSON_PATH = DATA_DIR / "articles.json"  # 全量结构化数据

# —— 目标 Vue 项目（写入数据与图片） ——
CHAN_PROJECT = Path(r"D:\code\chan")
CHAN_DATA_FILE = CHAN_PROJECT / "src" / "data" / "chanlun.ts"
CHAN_IMG_DIR = CHAN_PROJECT / "public" / "chanlun-img"
CHAN_IMG_URL_PREFIX = "/chanlun-img"
