This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
M4 Sport Stream is a containerized Node.js service that scrapes the M4 Sport Hungarian live stream HLS manifest URL using Playwright and serves it via HTTP. Clients (VLC, IPTV apps, browsers) connect to get a redirect to the live stream.
# Install dependencies (requires Node 24+)
npm install
# Install Playwright Chromium browser
npm run install-playwright
# Run locally
npm start
# Run with Docker
docker compose up -dThere are no tests, linter, or build step configured.
The app has two phases that run sequentially on startup (src/main.js):
- Scheduler (
src/scheduler.js) — readsconfig/manifest.jsonand decides what to do: if missing/stale (>24h), runs the scraper immediately and awaits it; if fresh, schedules the next scrape for when it will go stale. Either way, sets up a 24h interval for subsequent re-scrapes. - HTTP server (
src/server.js) — plainnode:httpserver serving three endpoints:/(hls.js web player),/stream(302 redirect to manifest URL),/playlist.m3u(M3U playlist). Started after the initial scrape so/streamdoesn't 503 during boot.
Uses Playwright (headless Chromium) to:
- Navigate to
https://m4sport.hu/elo - Find the player iframe (
player.php) - Extract the HLS manifest URL from the frame content via regex
- Write result to
config/manifest.jsonas{ manifestUrl, updatedAt }
All config is via environment variables with defaults:
PORT(3000),MANIFEST_FILE_PATH("./config/manifest.json")- Scraping constants (PAGE_URL, PLAYER_FRAME_URL, MANIFEST_URL_PATTERN, MANIFEST_URL_MAX_AGE_MS) are hardcoded.
- Requires a Hungarian IP address to access the M4 Sport stream.
PLAYWRIGHT_BROWSERS_PATH=0must be set when running Playwright commands locally (installs browser alongside the package rather than in a shared location).- Docker image is based on
node:24.15.0-slimand publishes toghcr.io/balintsoos/m4sport.