* feat: 1.2.0 — fix Telegram markup, premieres, lookback; add CI, state branch, changelog Fixes - Telegram: HTML parse mode; titles no longer render with backslashes. - Skip scheduled Premieres until they are public (watch-page check). - Replace "published today (UTC)" with a 48h lookback window so delayed scheduled runs cannot lose videos. - Distinguish skipped vs failed platforms; exit 1 on failure so the CI-failure notifier fires. Infrastructure - ci.yml: ruff (incl. S rules), pytest, zizmor, actionlint; `ci` gate job. - release.yml: tag v* -> GitHub Release from changelog/1.x.md -> Discord. - Dependabot for actions + dev deps; actions SHA-pinned. - State moves to the orphan `state` branch (main becomes ruleset-protected). - Shared message builder and HTTP client; tests; docs rewritten. - Remove unused .github/scripts/discord_notify.py. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * ci: add 7-day Dependabot cooldown (zizmor dependabot-cooldown) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
"""
|
|
State management for tracking posted video IDs.
|
|
|
|
State file: one video ID per line, oldest first, capped at MAX_STATE_IDS.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from config import MAX_STATE_IDS, STATE_FILE
|
|
|
|
|
|
def _read_ids(path: Path) -> list[str]:
|
|
if not path.exists():
|
|
return []
|
|
return [line.strip() for line in path.read_text(encoding="utf-8").splitlines() if line.strip()]
|
|
|
|
|
|
def load_posted_ids(path: Path = STATE_FILE) -> set[str]:
|
|
"""Read all posted video IDs from the state file."""
|
|
return set(_read_ids(path))
|
|
|
|
|
|
def save_posted_ids(new_ids: list[str], path: Path = STATE_FILE) -> None:
|
|
"""Append new IDs, keeping order and at most MAX_STATE_IDS entries."""
|
|
combined = _read_ids(path)
|
|
seen = set(combined)
|
|
for vid in new_ids:
|
|
if vid not in seen:
|
|
combined.append(vid)
|
|
seen.add(vid)
|
|
combined = combined[-MAX_STATE_IDS:]
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text("\n".join(combined) + "\n", encoding="utf-8")
|