Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 2.14 KB

File metadata and controls

52 lines (34 loc) · 2.14 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

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.

Commands

# 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 -d

There are no tests, linter, or build step configured.

Architecture

The app has two phases that run sequentially on startup (src/main.js):

  1. Scheduler (src/scheduler.js) — reads config/manifest.json and 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.
  2. HTTP server (src/server.js) — plain node:http server serving three endpoints: / (hls.js web player), /stream (302 redirect to manifest URL), /playlist.m3u (M3U playlist). Started after the initial scrape so /stream doesn't 503 during boot.

Scraper (src/scraper.js)

Uses Playwright (headless Chromium) to:

  1. Navigate to https://m4sport.hu/elo
  2. Find the player iframe (player.php)
  3. Extract the HLS manifest URL from the frame content via regex
  4. Write result to config/manifest.json as { manifestUrl, updatedAt }

Configuration (src/config.js)

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.

Key Constraints

  • Requires a Hungarian IP address to access the M4 Sport stream.
  • PLAYWRIGHT_BROWSERS_PATH=0 must 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-slim and publishes to ghcr.io/balintsoos/m4sport.