Skip to content

Route scrobbles through Multi-Scrobbler instead of Last.fm

jedmund requested to merge jedmund/multi-scrobbler into main

Summary

Send scrobbles and now-playing updates to the self-hosted Multi-Scrobbler instance instead of talking to Last.fm directly, so album-sort listens flow through the same pipeline as Plex and whatever else is downstream of MS (custom site, etc.) — one source of truth, one dedupe/retry surface.

  • New src/lib/server/api/multiscrobbler.ts posts to ${MULTI_SCROBBLER_URL}/1/submit-listens (ListenBrainz-compatible ingress) with Authorization: Token ${MULTI_SCROBBLER_TOKEN}. Submission client tagged album-sort. Completed listens use listen_type: "single" with listened_at; now-playing uses listen_type: "playing_now".
  • Routes moved api/lastfm/*api/scrobble/{now-playing,submit,status}. OAuth flow (auth/callback/disconnect) removed — no per-user session needed when MS handles the forwarding.
  • Deleted src/lib/server/api/lastfm.ts (API signing, exchangeToken, session helpers). LASTFM_API_KEY / LASTFM_API_SECRET env vars no longer used by album-sort.
  • Settings UI collapsed to a "configured / not configured" indicator referencing MULTI_SCROBBLER_URL and MULTI_SCROBBLER_TOKEN.
  • Orphan lastfm_session_key / lastfm_username rows in the settings KV are harmless and left in place (nothing reads them anymore).

Deploy notes (homelab repo)

  1. In roles/album_sort/templates/env/album-sort.env.j2: drop LASTFM_API_KEY / LASTFM_API_SECRET, add:
    MULTI_SCROBBLER_URL=http://multi-scrobbler:9078
    MULTI_SCROBBLER_TOKEN={{ album_sort_multi_scrobbler_token }}
  2. In roles/media_consumption/templates/config/multi-scrobbler/config.json.j2, add a new source alongside Plex:
    {
      "type": "listenbrainz",
      "name": "album-sort",
      "data": { "token": "{{ multi_scrobbler_album_sort_token }}" }
    }
    (Both sides share the same token — it's the ingress auth.)
  3. Restart multi-scrobbler before redeploying album_sort so the new source is live.

Both containers are already on the shared Docker network, so http://multi-scrobbler:9078 is reachable container-to-container — no compose changes needed.

Test plan

  • pnpm run build passes (verified locally)
  • With MULTI_SCROBBLER_URL / MULTI_SCROBBLER_TOKEN unset, playback works and scrobble requests short-circuit (204/empty success) — no errors in logs
  • After deploy, play a track in album-sort and confirm it appears as a "now playing" in Multi-Scrobbler's dashboard, then as a completed listen after ~50% / 30s
  • Confirm the Multi-Scrobbler → Last.fm forwarding fires for album-sort listens (same scrobble appears on Last.fm)
  • Settings page shows "Configured" when env vars are present, "Not configured" when missing

Merge request reports

Loading