Skip to content

Prepare 0.2.0: livebot restream, live auth, hardening, retention; remove transcription and TTS - #23

Merged
Blackwellcode merged 37 commits into
masterfrom
feat/nachtsilo-backport
Nov 25, 2026
Merged

Blackwellcode merged 37 commits into
masterfrom
feat/nachtsilo-backport

Conversation

@Blackwellcode

@Blackwellcode Blackwellcode commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Prepares 0.2.0: ad-filtered live restream, direct live routes behind a login check, privacy and request hardening, an optional retention script, working quick starts, and the removal of Whisper transcription and the TTS overlay.

+recorder/livebot.py        demand-driven restream (MPEG-TS fan-out + HLS, -c copy), 127.0.0.1:8085
+recorder/ts_fanout.py      GOP/PAT/PMT cache, bounded queues per viewer
 twitch_watch player        start buffer, rebuffering, reconnect at stream end, TS -> HLS -> WebUI playlist
 nginx                      auth_request for live routes, no query strings in logs, 2 MB bodies except admin uploads
 webui                      1 MiB body limit before authentication, log escaping, strict live channel names
+WEBUI/gunicorn_logging.py  percent-encoded access log
+scripts/vod_retention.py   dry run by default; keeps VODs in use or without a confirmed cloud copy
 install.sh                 keeps edited nginx sites, rolls back when nginx -t fails, livebot unit, git history for updates
 docker-compose.yml         runs from a fresh clone, livebot program
-Whisper transcription, TTS overlay, stalker leftovers

Evidence

  • CI on this branch: Python 3.10/3.11/3.12 (678 tests), shell scripts, Docker stack (nginx -t, smoke test through nginx, all programs running), installer (smoke test, streamvault update, rollback of a failing nginx -t, edited site kept), upgrade from 0.1.1, README demo.
  • The new jobs found and now cover: the recorder could not start in Docker from a fresh clone, the installer aborted when nginx was stopped, .env.example was missing from the installed checkout, the recorder crashed once when it started before the WebUI.
  • The live pipeline is tested with an FFmpeg generator in place of Streamlink. Not tested: a real Twitch stream, Safari, FFmpeg 4.4/5.1 with a live stream.

Merge Danger

Door: two-way for the code; operators must follow the breaking changes in CHANGELOG.md.

Blast Radius: deployments. New service livebot (without it there is no live playback), new nginx locations, changed minimum dependency versions, removed features and environment variables.

Known and left open: root runs the CLI from a directory owned by the service user (unchanged); no per-user quota for live channels; hls.js and noUiSlider still come from a CDN.

Checks

  • ruff check . passes
  • python -m unittest discover -s tests passes
  • New behaviour has a test
  • Operator-visible changes are in CHANGELOG.md

🤖 Generated with Claude Code

Blackwellcode and others added 30 commits November 19, 2026 10:21
scripts/vod_retention.py deletes archive VODs older than --days N. It is a
dry run unless --enforce is passed. Deletion goes through the WebUI delete
path (deleted_media tombstone, thumbnail, HLS, chapters, shares) and removes
the VOD's metadata, chat log and chat chunks. Folders with an active
recording or remux (worker guards) are skipped; files with a .part or
.remux.lock sibling and the file an active recording points to are kept.
Optional offload channels are only deleted when listed in an offload
manifest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Example service (dry run by default) and daily timer in scripts/systemd/,
INSTALL.md section "VOD retention", optional env variables in .env.example
and a CHANGELOG entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mpegts.js fetches inside a blob: worker without a base URL, so the
relative /live/<channel>.ts failed with "Failed to parse URL". Build an
absolute URL. The MPEG-TS fan-out is an optional external livebot: after
two failures before the first frame the player stays on LL-HLS. Native
HLS (iOS/Safari) plays the session-checked Flask playlist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The player requests /live/<channel>.ts and /live/<channel>/stream.m3u8
with seg_N.ts, but nginx had no locations for them: the .ts request
reached the Flask live_view and was redirected to the watch page.

nginx.conf, install.sh and the INSTALL.md example now serve these paths
directly (LL-HLS from LIVE_HLS_DIR, .ts from an optional livebot
fan-out) after auth_request /_live_auth -> GET /api/live/auth. The
endpoint answers 204 for a session that may view the channel, 401
without a valid session and 403 for hidden channels or other paths. It
is exempt from rate limiting (about one subrequest per viewer and
second). The access log switches to a cookie-free "timed" format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Twitch player embed plays ads and sends the viewer's IP address to
Twitch. With LIVE_TWITCH_EMBED off (default) every device plays the
server stream, ?embed=/?proxy= have no effect, player_url,
watch_embed_url and embed_parents stay out of the template context, no
iframe is rendered and the CSP frame-src/child-src no longer list
player.twitch.tv or www.twitch.tv. LIVE_TWITCH_EMBED=true restores the
previous behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…overs

Transcription: drop run_transcribe.py, the /vod/transcribe* and
/vod/transcript/* routes, the transcript panel on the VOD page, the
worker's ASR pool and the recorder's automatic transcribe task.
A transcribe task still queued by an older release is claimed by the IO
pool and failed once with a warning (RETIRED_TASK_TYPES), so it neither
crashes the worker nor stays pending. No schema change.

TTS: drop core/tts_service.py, core/tts_bot.py, the /tts/* routes and the
TTS overlay files. The alert overlay stays; it reads ALERT_OVERLAY_TOKEN
and falls back to TTS_OVERLAY_TOKEN with a one-time deprecation warning.
Only the X-Alert-Token header is accepted.

Stalker: remove the dead page-stalk* CSS, sidebar endpoints, the
/admin/stalk guard and unused constants.

Tests for the removed features are dropped; test_removed_features.py
checks the routes return 404, the retired task handling and the token
fallback. Catalogs refreshed, packaging extras and CI compile list
updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README, CLAUDE.md (section 6 now documents STREAMVAULT_IMPORT_ONLY for
CLI scripts that import the web UI), CONTRIBUTING, .env.example
(ALERT_OVERLAY_TOKEN) and a CHANGELOG "Removed" entry listing the env keys
and packages operators can drop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- An expired file whose stem is shared by another media file (x.mkv next
  to a kept x.mp4) is removed alone: chat log, chat chunks, metadata,
  thumbnail, HLS cache and the chat tombstone belong to the kept file.
- Extensions are matched case-sensitively like resolve_media_path;
  X.MP4 is skipped with a warning instead of failing every run (exit 1).
- Offload manifest entries are <channel>/<file>; bare file names are
  ignored with a warning, so a same-named VOD of another offload channel
  is never released.
- .env.example: comment of VOD_RETENTION_OFFLOAD_MANIFEST on its own line
  (systemd EnvironmentFile does not strip trailing comments).
- Tests: shared stem, extension case, manifest format, recording started
  after the scan, symlinked/outside sidecars, clips, alias mismatch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- /api/live/auth answers 404 unless nginx marks the auth subrequest with
  X-StreamVault-Live-Auth: 1; every location proxying to the WebUI clears
  that header so clients cannot inject it (nginx.conf, install.sh,
  INSTALL.md).
- The original URI is cut at "?" and matched with fullmatch instead of
  urlsplit (which read "//host/live/x.ts" as netloc plus a valid path).
- Live maintenance mode (with the usual bypass) and the mobile live switch
  apply to the direct live routes as well (403).
- Access log format uses "$request_method $uri $server_protocol" instead of
  "$request", so ?token= and other query values are not logged.
- Tests set the marker header like nginx and cover the marker, path-only
  parsing, maintenance, mobile, the cleared header in every app location
  and a log format without $request/$request_uri/$args/$http_cookie.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/alerts/api/next returned audio_url with ?token=, which put the secret into
access logs. The overlay (overlay_common.js createAudio) already fetches
the audio with the X-Alert-Token header and plays it from a blob URL, so
the plain path is enough. Test: audio_url has no token, the audio endpoint
answers 401 without and 200 with the header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fixes

Unreleased listed /tts/api/ack, /tts/overlay and the run_transcribe.py
cancel fix although "Removed" drops both features. Breaking changes now
point to the removal and to the new nginx live-auth header; the retention,
live-auth, access-log and alert audio fixes are documented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Visitors' browsers no longer contact fonts.googleapis.com/fonts.gstatic.com
(GDPR: no visitor IP to Google). Inter 4 (variable, wght) and IBM Plex Mono
400/500/600 from Fontsource 5.3.0 (SIL OFL 1.1, latin + latin-ext) ship in
WEBUI/static/fonts with their licence texts; fonts.css mirrors the former
Google CSS (one @font-face per weight, font-display: swap, Fontsource
unicode-range values), so the rendering stays the same.

- UI_FONTS_HREF now points at the versioned local fonts.css; base.html
  preloads the Inter latin file and drops the preconnect/print-media loader;
  mobile_index.html uses UI_FONTS_HREF instead of a hard-coded Google link.
- Register font/woff2 with mimetypes (unknown to Python < 3.13).
- CSP: drop fonts.googleapis.com from style-src and fonts.gstatic.com from
  font-src.
- tokens.css: the mono stacks name IBM Plex Mono first; JetBrains Mono was
  never loaded, so they fell back to Courier New.
- New tests/test_self_hosted_fonts.py; README licence note, CHANGELOG entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gunicorn's default access format logs %(r)s, the full request line with
?token=. Every gunicorn start (install.sh and INSTALL.md systemd units,
docker-worker.conf supervisor program) now passes --access-logformat with
the path %(U)s instead; "%" is doubled because systemd and supervisor
expand it. Tests check every gunicorn start line in the shipped configs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When an expired x.mp4 is removed while x.mkv stays (or the other way
round), write the deleted_media tombstone for exactly that file name,
remove its share links and chapters file and clear the WebUI listing
caches. Stem-keyed files (chat log, chunks, metadata, thumbnail, HLS,
chat tombstone) still stay for the kept file. Test: mp4 expired, mkv kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… styles

- live_watch_diag.append_client_debug: call os.chown only where it exists;
  on Windows POST /api/live/client-debug failed with AttributeError (500).
- fonts.css is linked once from components/styles.html, so standalone pages
  (mobile streamer/player/live, clip editor, HLS, live, chat export) load
  Inter and IBM Plex Mono too; the per-template links are gone. OBS overlays
  keep their system fonts.
- The Inter preload uses the same URL as fonts.css (no ?v=), so Chrome no
  longer fetches it twice ("preloaded but not used").
- code/kbd/samp/pre use the mono token via a zero-specificity :where() rule.
- The mobile live page (page-twitch-watch-mobile) gets the wait card and
  chat placeholder styles; desktop selectors keep their specificity.
- Tests: tests/test_live_watch_client_debug.py, standalone-page and CSS
  checks in tests/test_self_hosted_fonts.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Retake the VOD player (no transcript button), channel archive, system
status, cloud storage and phone layout in English at the previous pixel
sizes (1920x1140 desktop, 780x1688 phone). The dashboard and chat event
images keep their content and are only recompressed losslessly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lead with a hero screenshot and a quick start (demo seed, installer,
Docker), group the features into recording, watching, archive and
storage, access and privacy, and operations, and add sections for
privacy defaults, upgrading from 0.1 and requirements. Drop the
text-to-speech overlay and mention live route auth_request, the optional
Twitch embed (off by default), self-hosted fonts, the VOD retention
script with offload manifest and access logs without query strings. The
privacy section states that chat emotes and badges still load from
third-party services.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…copy, follow VOD_RETENTION_DAYS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…JSON-encode template values

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce units; CI runs Docker, installer and README demo

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
recorder/livebot.py runs streamlink -> ffmpeg (copy) only for channels with a
fresh watch marker of the WebUI and serves them as MPEG-TS fan-out and HLS.
The live player gets a start buffer, rebuffering, end detection and HLS
fallbacks. Rows created by watching are marked notify=0, so livebot removes
only those and never a configured live-only channel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eep /api/live/ready alive without Twitch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… keeps edited sites, livebot end of stream, retention without database)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blackwellcode and others added 3 commits November 25, 2026 00:52
…r streamvault update

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ck, small nginx bodies, channel name limit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Blackwellcode Blackwellcode changed the title Backport live auth, privacy hardening and VOD retention; remove transcription and TTS Prepare 0.2.0: livebot restream, live auth, hardening, retention; remove transcription and TTS Nov 25, 2026
Blackwellcode and others added 4 commits November 25, 2026 01:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rts an upgrade

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Blackwellcode
Blackwellcode merged commit d207beb into master Nov 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant