- Go 99.7%
- Dockerfile 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| bot | ||
| config | ||
| dist | ||
| fixtures | ||
| helios | ||
| logging | ||
| metrics | ||
| notify | ||
| rotten | ||
| server | ||
| state | ||
| .gitignore | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| main_test.go | ||
| README.md | ||
| session | ||
cinemapremierebot
Notifies (ntfy and/or SMTP mail) when a new movie joins the schedule of a Helios cinema. Any number of locations can be configured; announcements from lower-priority locations are limited to titles that are unique to them.
Uses Helios' own JSON API:
| Endpoint | Used for |
|---|---|
GET /api/cinema |
resolve the cinema by city/name |
GET /api/cinema/{id} |
resolve by explicit cinema id |
GET /api/cinema/{id}/screen |
halls; feature: "IMAX" / "Dream" |
GET /api/cinema/{id}/screening |
screenings (screenId, movieId, screeningTimeFrom, printType, speakingType) |
GET /api/movie |
movie facts: original title, premiere dates, genres, length, director, trailer |
Ratings from Rotten Tomatoes are scraped- no other way to get them.
State as of December 2026- might be changed in future.
You can find default config and example kubernetes maniests inside dist folder.
Locations and the uniqueness rule
locations is an ordered list; index 0 is the primary location. Each entry
picks a cinema (cinemaId, or cinemaCity + optional cinemaName) and a hall
filter:
halls |
link for more information |
|---|---|
imax |
https://helios.pl/szczecin/helios-outlet-park/sale-imax |
dream |
https://helios.pl/poznan/kino-helios/sale-dream |
any (also all, empty) |
every hall of the cinema |
A movie is announced when its movieId is on the schedule of a location and
missing from the state kept in Valkey cache. Locations are processed in priority order, and a title that is already on the schedule of
a higher-priority location is never announced from a lower-priority one — a
secondary location therefore reports only what is unique to it. Skipped duplicates
are counted (skipped in /status, helios_new_movies_total is not incremented).
If a city has more than one Helios cinema, cinemaCity is ambiguous — set
cinemaId on the entry (and optionally cinemaName for the log line).
- First run on clean cache is silent
- Movies still playing get their TTL refreshed, so a title is remembered for
valkey.ttlDaysafter its last sighting; expired keys are dropped and pruned from the index. runtime.maxNewPerCheckcaps announcements per check (the rest are still recorded).- A failing channel never aborts the run: the state write still happens and the
failure is logged and counted in
helios_notifications_total.
Ratings (Rotten Tomatoes)
Rotten Tomatoes: https://www.rottentomatoes.com/m/dune_part_two
Critics score: 83% (certified fresh)
Audience score: 90%
How the scraping works:
GET /search?search=<title>— the server-rendered<search-page-media-row>elements carry the slug, the title and the Tomatometer.- the best row is picked (exact normalised title match wins, a row with a score beats a row without one);
GET /m/<slug>— the embeddedwindow.__RT__blob carriescriticsScore(Tomatometer, certified flag, review count) andaudienceScore.
Disable with ratings.enabled: false.
Configuration
Env vars prioritized over yaml config.
| Key | Env | Meaning |
|---|---|---|
source.apiBase |
HELIOS_API_BASE |
API root, default https://restapi.helios.pl/api |
source.acceptLanguage, userAgent |
HELIOS_ACCEPT_LANGUAGE, HELIOS_USER_AGENT |
request headers |
source.lookAheadDays, graceHours |
HELIOS_LOOKAHEAD_DAYS, HELIOS_GRACE_HOURS |
watched window (1–365 days, ≥0 hours) |
source.timeoutSeconds, retries |
HELIOS_TIMEOUT_SECONDS, HELIOS_RETRIES |
HTTP timeouts; 429/5xx/transport errors retried with backoff |
ratings.enabled, base, userAgent, timeoutSeconds, retries |
RATINGS_ENABLED/BASE/USER_AGENT/TIMEOUT_SECONDS/RETRIES |
Rotten Tomatoes lookup; userAgent falls back to source.userAgent |
locations[].name/cinemaCity/cinemaName/cinemaId/halls/pageUrl |
HELIOS_CITY, HELIOS_CINEMA_NAME, HELIOS_CINEMA_ID, HELIOS_HALLS, HELIOS_PAGE_URL |
env overrides apply to the primary (first) location only; add locations in YAML |
valkey.url, prefix, ttlDays, db, username, password |
VALKEY_URL/PREFIX/TTL_DAYS/DB/USERNAME/PASSWORD |
Valkey connection and state retention |
runtime.intervalMinutes |
CHECK_INTERVAL_MINUTES |
check cadence |
runtime.logLevel |
LOG_LEVEL |
error/warn/info/debug |
runtime.maxNewPerCheck, startupDelaySec |
— | yaml only |
http.listen |
LISTEN_ADDR |
address for /up, /metrics, /status |
notify.ntfy.* |
NTFY_ENABLED/SERVER/TOPIC/TOKEN/PRIORITY |
ntfy channel |
notify.mail.* (port default 465) |
MAIL_ENABLED/HOST/PORT/FROM/TO/USER/PASSWORD |
SMTP channel, implicit TLS |
debug.enabled, debug.token |
DEBUG_ENABLED, DEBUG_TOKEN |
switch + bearer token for /debug/notify-test, off by default |
Validation runs at startup: at least one location (each with cinemaId or
cinemaCity, a known halls value, no duplicated cinema), at least one enabled
channel, ntfy topic matching [A-Za-z0-9_-]{1,64} and priority 1–5, a non-empty
valkey.prefix of [A-Za-z0-9_-:.], valkey.ttlDays ≥ 1 and valkey.db in 0–1023,
and a debug.token of at least 16 characters whenever debug.enabled is true.
State in Valkey
The bot keeps its memory of already-announced movieIds in Valkey
(github.com/valkey-io/valkey-go).
| Key | Type | Contents |
|---|---|---|
<prefix>:seen |
set | every movieId currently remembered (the index) |
<prefix>:movie:<movieId> |
string | JSON entry: MovieID, Location, Title, FirstFrom, LastSeen, with a TTL |
- Every check refreshes the TTL of the titles still on the schedule, so a title
stays remembered for
valkey.ttlDaysafter its last sighting. - Expired values are removed from the index on the next check (
SREM), so the number of stored keys does not grow without bound. - Data loss is tolerated. If the stored keys disappear (flushed Valkey, restart without persistence, eviction), the next check sees an empty index and fills it again quietly instead of announcing the whole schedule a second time. The cost is that titles which appeared while the state was gone are not announced.
- One replica only: two pods would race on the same keys and could announce the same premiere twice.
Channels
ntfy — POST {server}/{topic} (official ntfy REST API) with Title,
Priority, Tags, Markdown and optional Actions headers; Authorization: Bearer
when a token is set. Movie titles are stripped of CR/LF before they become header
values. Works with a self-hosted server (server: https://ntfy.example.com) or ntfy.sh.
mail — wneessen/go-mail over implicit TLS (SMTPS) on notify.mail.port,
465 by default; LOGIN AUTH when username and password are set, To may be a list.
Each notification is a multipart/alternative message (plain text + HTML).
Subjects name the hall when a location watches exactly one hall
(New in {hall} at {cinema}: {title}) and the cinema alone when several halls
are watched (New at {cinema}: {title}).
Testing notifications
Use debug.enabled: true and a debug.token config options. Then http GET /debug/notify-test
creates one fake announcement (subject prefixed [TEST], movie id notify-test)
and pushes it through every enabled channel.
curl -s -H 'Authorization: Bearer <debug.token>' app.local/debug/notify-test
The response lists the channels, the rendered message and a per channel verdict:
ok: ... when all of them accepted it, otherwise failed channels: ... plus the
errors.
HTTP endpoints
| Path | Purpose |
|---|---|
/up |
health check for Kubernetes, answers ok |
/metrics |
Prometheus exposition |
/status |
human-readable summary (locations, halls, tracked movies, last check) |
/debug/notify-test |
sends one fake announcement to every channel and reports per channel results; only registered when debug.enabled, requires Authorization: Bearer <debug.token> |
/ |
index of the endpoints above |
Metrics
helios_checks_total, helios_check_outcome_total{outcome},
helios_check_duration_seconds, helios_last_check_timestamp_seconds,
helios_new_movies_total{location}, helios_tracked_movies,
helios_locations, helios_screens{location},
helios_screenings_observed{location},
helios_api_requests_total{endpoint,status},
helios_api_request_duration_seconds{endpoint},
helios_api_errors_total{endpoint},
helios_notifications_total{channel,status},
helios_state_writes_total, helios_state_errors_total,
helios_bot_info{build} (commit date stamped at build time).
Location label values are normalized: lowercased, Polish diacritics folded to
ASCII, anything else becomes _ (e.g. Some Cinema Name → some_cinema_name).
Deployment
docker build -t cinemapremierebot .
docker run --rm -p 9730:9730 \
-v ./config.yaml:/config.yaml:ro \
-e NTFY_TOPIC=my-secret-topic \
-e VALKEY_URL=redis://valkey.internal:6379/0 \
cinemapremierebot
dist/k8s.yaml contains example kubernetes manifest.
Development
gofmt -w .
go vet ./...
go build -o cinemapremierebot .
go test ./...
mkdir -p coverage
go test -coverprofile=coverage/coverage.out -coverpkg=./... ./...
go tool cover -func=coverage/coverage.out | tail -1
Tests cover schedule building and hall filters, Valkey state (marking, reading back, TTL refresh, expiry, index cleanup, reconnecting clients, wiped data), config parsing and validation (including the location list), API client retries and metric labels, ntfy request shape, mail message construction, formatters, the check flow (first run, running twice without repeating announcements, per-check cap, channel failures, second location) and the HTTP endpoints.
The state tests need a reachable Valkey; they use database 15 and a unique
prefix, delete their keys afterwards, and skip when the connection fails. Point
them elsewhere with VALKEY_TEST_URL (default redis://127.0.0.1:6379/15).