feat: delay show rotation during live recording window

Decouple the like-window boundary (Wed 10pm ET) from when the system
rotates to a new show. NTR_SHOW_ROTATION_DELAY_HOURS=2 keeps the
previous week's show visible during the ~2 hour recording, then creates
the new show at midnight.

Made-with: Cursor
This commit is contained in:
cottongin
2026-04-01 21:29:42 -04:00
parent a328684af0
commit 82049ab47f
7 changed files with 102 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ from datetime import datetime, timezone
from ntr_fetcher.db import Database
from ntr_fetcher.soundcloud import SoundCloudClient
from ntr_fetcher.week import get_show_week
from ntr_fetcher.week import get_current_show_week
logger = logging.getLogger(__name__)
@@ -18,6 +18,7 @@ class Poller:
show_day: int,
show_hour: int,
poll_interval: float,
rotation_delay_hours: float = 0,
):
self._db = db
self._sc = soundcloud
@@ -25,6 +26,7 @@ class Poller:
self._show_day = show_day
self._show_hour = show_hour
self._poll_interval = poll_interval
self._rotation_delay_hours = rotation_delay_hours
self._user_id: int | None = None
self.last_fetch: datetime | None = None
self.alive = True
@@ -37,7 +39,9 @@ class Poller:
async def poll_once(self, full: bool = False) -> None:
user_id = await self._get_user_id()
now = datetime.now(timezone.utc)
week_start, week_end = get_show_week(now, self._show_day, self._show_hour)
week_start, week_end = get_current_show_week(
now, self._show_day, self._show_hour, self._rotation_delay_hours,
)
show = self._db.get_or_create_show(week_start, week_end)
if show.episode_number is None: