# Tasks / To-Do

## Open
- `now-playing.php` — add `positionSec` back to main branch (lost when switching from sim branch)
- Encode Sunday service videos to HLS (so 00:00 block doesn't warn "No videos")
- YouTube API key — expired, blocks new video downloads; renew in Google Cloud Console
- `playlists.json` — duplicate `bible` id (entries: "Bible" and "Bible Readings")

## Done
- `generate_daily_plan.php` — supports both v2 (`media`/`after`) and v3 (`package`) schedule formats
- `import_videos.php` — import manually-created videos; generates `.json` sidecar + `.jpg` thumbnail
- `gen_bumpers.sh` — generates 1280×720 H.264 bumper MP4s (brand, coming-up, stay-tuned)
- `stream.php` — fixed `EXT-X-TARGETDURATION` (dynamic, not hardcoded 7) and `EXT-X-MEDIA-SEQUENCE` (Roku levelParsingError)
- `playlists.json` — restored `bible` and `bumpers` entries (type: manual)
- `gen_banners.py` — per-video banners now output `.banner.jpg` (not `.banner.png`) for Roku compatibility
- Admin "Write failed" — fixed: `data/` dir ownership changed to `ubuntu:www-data` so Apache can write
- Cron — consolidated to single nightly job at 2am UTC: `vod/run.sh` → `live/run.sh`
- `generate_daily_plan.php` — extended to 30-hour plan (today 0–86400 + tomorrow 86400–108000) to avoid midnight gap; added `source` metadata per entry (schedDay, package, pkgEntry, isPrimary)
- `stream.php` + `now-playing.php` — fixed midnight gap: apply plan-date offset when `plan_date < today` so binary search finds 30-hour entries correctly
- `now-playing.php` — `next` now shows first video of the next scheduled block (not fillers)
- `admin/daily-plan.php` — new page: now-playing progress, stream health, full schedule with 5-level hierarchy (Schedule Day → Entry → Package → Package Entry → Video)
- `live/scripts/validate_plan.php` — CLI validator: plan freshness, entry integrity (disk/HLS/duration), now-playing, stream m3u8, cross-check videoId agreement
- PHP 7.x compat — replaced `str_starts_with()` with `strncmp()` in `admin/daily-plan.php` and `validate_plan.php`

## Nightly Run (2am UTC)
```
vod/run.sh
  ├─ Process.php              download new YouTube videos
  ├─ genFeed.php              regenerate Roku feed
  └─ live/run.sh
       ├─ generate_daily_plan.php   build today's schedule + live banner
       ├─ encode_videos.sh          encode new MP4s to HLS
       └─ gen_banners.py --overlays-only   apply title overlays to thumbnails
```
Log: `logs/run.log`

## Schedule Format (schedule.json)
- v2: blocks with `media` key; filler blocks use `"start": "after"`
- v3: blocks with `package` key referencing `packages.json`
- Priority: `dates[YYYY-MM-DD]` > `defaults[DayOfWeek]` > `defaults[every-day]`
