- Statement latency by operation and connection-pool gauges via
SQLAlchemy events
- Users, active users (1h/24h/7d) and now-playing gauges computed at
scrape time, cached for 60s, from a NullPool engine that is safe in
the gunicorn master; exports nothing (not an error) if the DB is down
- gunicorn.conf.py: multiprocess metrics aggregated across workers and
served by the master on METRICS_PORT, stale files cleared at start,
dead workers marked
- Tests cover labels, in-flight gauge, DB metrics, the collector and a
real two-worker gunicorn aggregation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
- /2.0/ and /api/auth/ are described from the Last.fm method registry:
method enum, per-method parameter tables, auth requirements, notes,
request schemas and XML example responses
- Readable tags (Auth, Apps, Sessions, Tokens, Stats, Last.fm)
- docs/openapi.json is exported with `flask openapi write`; tests fail
if it drifts from the code, if any route is undocumented, or if a UI
route is missing its bearer-auth security declaration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
- Plain HTML + vanilla JS modules, no build step; talks to /api/v1 with
a bearer token and only ever inserts server data as text
- Overview: now-playing dot-matrix display with live progress, totals,
30-day plays meter, top artists/tracks by period, recent plays
- History (paged, grouped by day), Apps (create/delete, reveal/copy
keys, player setup details), Sessions (revoke), sign-in approval page
for the Last.fm desktop auth flow, sign in and registration
- Light and dark themes, responsive to phone widths, vendored fonts
(SIL OFL) so the UI has no third-party requests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
- Stats service shared by both APIs: recent scrobbles, top artists,
albums and tracks over Last.fm periods, per-day/week/month counts
(with empty days filled) and totals
- Case-insensitive grouping that displays the most common spelling
- user.getInfo, user.getRecentTracks (now playing first, from/to),
user.getTopArtists/Albums/Tracks with Last.fm paging attributes
- /api/v1/me: now-playing, recent, top/{artists,albums,tracks},
counts and summary
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
- track.scrobble: batches of up to 50 (array params or a single track),
Last.fm ignore rules (empty artist/track, too old, too new), duplicate
submissions accepted but stored once
- track.updateNowPlaying: upserted per user, expiring after the track's
duration; cleared when the same track is scrobbled
- Scrobble result, ignore reason, batch size, lag and now-playing metrics
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- auth.getMobileSession (username + password), auth.getToken and
auth.getSession with Last.fm error codes 4/14/15
- /api/auth/ redirects clients' approval links to the web UI's
approve page; /api/v1/tokens lets the UI show and approve a token
- Tokens expire after an hour, are single use and bound to their app
- The legacy md5 authToken form is deliberately unsupported (it needs
unsalted password hashes)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- flask-smorest API under /api/v1 with a uniform JSON error shape;
spec at /api/openapi.json, Swagger UI at /api/docs, ReDoc at /api/redoc
- Register/login/logout/me with hashed, expiring bearer tokens,
documented as an OpenAPI bearer security scheme
- API application and client-session management endpoints
- CORS restricted to the configured UI origin(s)
- Flask no longer serves static files: it is API-only
- Login and registration metrics
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- /2.0/ dispatcher backed by a method registry that declares each
method's params and signature/session requirements
- api_sig verification per the Last.fm auth spec
- XML (default) and Last.fm-style JSON rendering, including error shapes
and HTTP statuses per error code
- Last.fm request, error and auth-failure metrics with bounded labels
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Flask app factory with env-driven config (.env loaded at import)
- SQLAlchemy models: users, API apps, UI tokens, Last.fm auth tokens,
sessions, scrobbles (deduplicated) and now-playing
- Initial Alembic migration; CI checks migrations match the models
- Prometheus metric definitions, per-endpoint RED hooks with bounded
labels, and a standalone metrics server
- docker compose Postgres with a test database; CI test job runs
against a Postgres service container
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Rename the project to "scrobbler" with a src/ layout (hatchling)
- ruff + pytest dev tooling and a smoke test
- CI workflow (lint, test) that reports every run to ntfy via a
reusable composite action
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>