feat: add historical backfill with --init CLI and episode numbering

Adds a --init mode that seeds the database with past shows from a given
anchor episode/date forward, batch-fetching likes from SoundCloud and
partitioning them into weekly buckets. Episode numbers are tracked in
the shows table and auto-incremented by the poller for new shows.

Includes full API documentation (docs/api.md) and updated README.

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-12 02:09:15 -04:00
parent c88826ac4d
commit cb3ae403cf
14 changed files with 922 additions and 21 deletions

View File

@@ -40,6 +40,13 @@ class Poller:
week_start, week_end = get_show_week(now, self._show_day, self._show_hour)
show = self._db.get_or_create_show(week_start, week_end)
if show.episode_number is None:
latest = self._db.get_latest_episode_number()
if latest is not None:
new_ep = latest + 1
self._db.update_show_episode_number(show.id, new_ep)
logger.info("Auto-assigned episode #%d to show %d", new_ep, show.id)
tracks = await self._sc.fetch_likes(
user_id=user_id,
since=week_start,