Skip to content

Latest commit

 

History

History
142 lines (99 loc) · 5.51 KB

getting-started.md

File metadata and controls

142 lines (99 loc) · 5.51 KB

Getting started

This tutorial takes a Docker host from an empty folder to a channel playing in Plex, the Sofa King app or an M3U player. It uses three free services that need no account, and a small lineup policy. It takes about fifteen minutes, plus the time the server needs to verify the first channels.

Replace SERVER_HOST with the host's LAN address and PLEX_SERVER_IP with the address of your Plex server. The server answers on port 9193.

What you need

  • A Linux host, amd64 or arm64, with Docker Engine and Docker Compose 2.24 or later.
  • A copy of this repository on the host.
  • JDK 21 to build the image, or access to the private image package to pull the published one.
  • jq and openssl for the shell steps.

1. Start the server

From backend/, build the server and start it:

./gradlew :server:installDist
mkdir -p deploy/config
cd deploy
docker compose up -d --build

With access to the published image, you can skip the build. Pull the image and tag it with the name compose.yaml runs:

docker login ghcr.io -u GITHUB_USER
docker pull ghcr.io/jamesarich/sofa-king-backend:main
docker tag ghcr.io/jamesarich/sofa-king-backend:main sofa-king-backend:local
mkdir -p deploy/config
cd deploy
docker compose up -d --no-build

The remaining steps run in deploy. Check that the server is up:

curl --fail http://SERVER_HOST:9193/readyz

It answers ready. If the container exits at once instead, docker compose logs says why; troubleshooting lists the common causes.

2. Sign in

The first start generated an API token and an admin token and stored them in config/secrets.json. Print them, and keep them in shell variables for the later steps:

docker compose exec sofa-king-backend cat /config/secrets.json
SOFA_API_TOKEN=$(jq -r .apiToken config/secrets.json)
SOFA_ADMIN_TOKEN=$(jq -r .adminToken config/secrets.json)

Open http://SERVER_HOST:9193/admin and sign in with the adminToken. The overview lists what needs attention. For now it says there are no providers.

3. Add three services

Write the source file. It lists Whale TV+, Tubi and Pluto TV, three native providers that need no account:

cat > config/sources.json <<'EOF'
{
  "providers": [
    { "id": "whale", "type": "native", "service": "whale" },
    { "id": "tubi", "type": "native", "service": "tubi" },
    { "id": "pluto", "type": "native", "service": "pluto" }
  ],
  "guides": []
}
EOF
docker compose restart

After a minute, the portal's Providers page lists each service with its channel count. The same counts come from the API:

curl --fail -H "Authorization: Bearer $SOFA_API_TOKEN" http://SERVER_HOST:9193/api/v1/providers

Each native service brings its own guide, so guides stays empty.

4. Build the lineup

The services list channels, but the server serves none until a lineup policy builds the lineup. This policy takes every channel of the three services, Whale first, and puts whatever nothing else groups in Entertainment:

cat > config/policy.json <<'EOF'
{
  "providers": [{ "id": "whale" }, { "id": "tubi" }, { "id": "pluto" }],
  "groups": { "default": "Entertainment" }
}
EOF
docker compose restart

The server builds one station per channel. When two services carry the same channel, the first one listed leads and the other becomes its fallback. A station comes on once one of its sources has played in a probe, so the Channels page fills over the next hour or more.

To start from a full lineup of all 17 services instead, grouped and numbered in blocks, follow build a starter lineup.

5. Watch

Plex and M3U players reach the guide and the streams with an output token. Add one to .env and apply it:

printf 'SOFA_OUTPUT_TOKEN=%s\n' "$(openssl rand -hex 16)" >> .env
docker compose up -d

The portal's Plex page shows the playlist and guide URLs with this token once you choose to reveal it.

Plex

Turn on the HDHomeRun emulation for your Plex server, then apply it:

printf 'SOFA_HDHR_ENABLED=true\nSOFA_HDHR_ALLOW=PLEX_SERVER_IP\n' >> .env
docker compose up -d

Then add the tuner at SERVER_HOST:9193 and the guide at http://SERVER_HOST:9193/output/guide.xml?token=OUTPUT_TOKEN in Plex, with the token from .env, as steps 2 to 5 of Plex Live TV describe. Keep Plex in step lets the server update Plex's channel maps itself.

The Sofa King app

Install the Sofa King app and give it the server address, http://SERVER_HOST:9193, and the API token. The portal's Settings page reveals the API token too. The app reads the lineup and its programs, and plays through the server. To use the web app, serve it as serve the web app describes.

An M3U player

Add the playlist to the player, and the guide as its EPG or XMLTV source:

http://SERVER_HOST:9193/output/playlist.m3u?token=OUTPUT_TOKEN
http://SERVER_HOST:9193/output/guide.xml?token=OUTPUT_TOKEN

Players that read the playlist header pick up the guide on their own. Third-party players has the details.

Next steps