Skip to main content

listenbrainz-scrobbler

CI PyPI Python License: MIT

Automatically submit Apple Music listens on macOS to ListenBrainz, including streamed songs outside your library.

Setup

On macOS, install uv, then install the PyPI package with Python 3.13:

uv tool install --python 3.13 listenbrainz-scrobbler
lb-scrobbler install --dry-run
lb-scrobbler status

For a declaratively managed service, use Nix / Home Manager.

Play a song and allow the background Python process to control Music when macOS asks. Check status for fresh observations and an advancing playback position. If access is denied, enable it in System Settings → Privacy & Security → Automation, then reinstall the agent. A successful foreground probe may still require a separate permission for the background service.

After the dry run works, quit other scrobblers to avoid duplicate submissions. Save your ListenBrainz token in the login Keychain:

lb-scrobbler auth
lb-scrobbler install

For an existing SmashTunes setup, lb-scrobbler auth --from-smashtunes validates its stored ListenBrainz token and copies it into this service's Keychain entry. Neither command prints the token.

install starts the service immediately and at future logins. The agent runs the uv tool's Python environment, so keep that installation in place and never run install from a temporary uvx environment. A Python upgrade may require fresh macOS Automation or Keychain consent.

To upgrade, restart the agent against the updated tool environment:

lb-scrobbler stop
uv tool upgrade listenbrainz-scrobbler
lb-scrobbler install

Operation

lb-scrobbler probe       # Read Music without submitting
lb-scrobbler status      # Last observation and submission queue
lb-scrobbler stop        # Stop until reinstalled or the next login
lb-scrobbler uninstall   # Remove the launch agent
lb-scrobbler retry       # Retry retained failures after fixing their cause

lb-scrobbler run --dry-run runs in the foreground. Stop the LaunchAgent first, since only one process may own the playback tracker.

State and logs live in ~/Library/Application Support/listenbrainz-scrobbler/. Queued listens are stored there with user-only permissions. The submission token is held separately in login Keychain under xyz.hakula.listenbrainz-scrobbler. Uninstalling the agent preserves both the queue and Keychain entry.

The current song appears on ListenBrainz as soon as playback is observed. Pausing or stopping playback clears this service's playing-now notification. These temporary updates are not saved as listening history and are discarded when playback changes. If the service is stopped or offline, an existing notification remains until ListenBrainz expires it.

A listen is submitted after observing half a track or four minutes of playback, whichever comes first, following ListenBrainz's submission rule. Pauses, seeks, and observation gaps longer than ten seconds do not contribute listening time. Starting the service halfway through a song does not credit playback it did not observe.

Failed submissions stay queued with their original timestamps. Network and server errors are retried automatically. Inspect other failures with status, fix their cause, then run retry. After changing the token, run lb-scrobbler install to restart a manual installation. A crash during submission can occasionally cause a duplicate listen.

Limits

Only playback observed on this Mac is captured. There is no history import or iPhone synchronization.

Polling cannot distinguish a natural repeat from manually seeking from the very end to the very beginning. It also cannot identify different recordings with identical title, artist, and album metadata. Track-start timestamps are estimated from the observed position, so seeking before the first observation can skew that estimate. Missing metadata is skipped.

Nix / Home Manager

Add a versioned flake input such as github:hakula139/listenbrainz-scrobbler/v0.3.0, then import the module in your Home Manager configuration:

imports = [ inputs.listenbrainz-scrobbler.homeModules.default ];
services.listenbrainz-scrobbler.enable = true;

Home Manager replaces the manual installer's LaunchAgent under the same label while preserving the queue and Keychain token. Activate Home Manager, then check lb-scrobbler status to confirm the agent loaded and observations are fresh. The package path changes, so macOS may request Automation or Keychain access again. Use lb-scrobbler auth if no token is stored yet. After the module is active, remove the manual installation with uv tool uninstall listenbrainz-scrobbler.

The LaunchAgent starts at user login after a reboot, when Music and the login Keychain are available. Home Manager owns its lifecycle after migration, so use it for configuration changes instead of the manual install and uninstall commands. install refuses to run from the Nix package, because the interpreter that the manual installer records cannot import the package. install and uninstall also refuse when the existing agent runs the module's lb-scrobbler executable from the Nix store. Agents recorded by a uv, checkout, or older Nix-package install do not match that shape, so they can still be replaced or removed. After changing the token, restart the loaded agent with launchctl kickstart -k "gui/$(id -u)/xyz.hakula.listenbrainz-scrobbler". Disable the module and reactivate Home Manager to remove it. The existing Keychain entry keeps credentials outside the Nix store.

Releases

Releases follow the versioning policy, and the changelog lists each release's changes. GitHub releases also provide wheels, source archives, and checksums.

License

Copyright (c) 2026 Hakula. Licensed under the MIT License.

Metadata

Release files for listenbrainz-scrobbler 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for listenbrainz-scrobbler 0.3.0
File Size Uploaded Provenance Actions
listenbrainz_scrobbler-0.3.0.tar.gz 22.9 kB Without provenance Details for listenbrainz_scrobbler-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for listenbrainz-scrobbler 0.3.0
File Interpreter ABI Platform Actions
listenbrainz_scrobbler-0.3.0-py3-none-any.whl Python 3 none any Details for listenbrainz_scrobbler-0.3.0-py3-none-any.whl

Total release size: 41.6 kB

Release files / listenbrainz_scrobbler-0.3.0.tar.gz

Download URL listenbrainz_scrobbler-0.3.0.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cddf9bb655cf98bd14c7bbb3e836bc63e85df6e8bb3d61c1ec58b4392ce77fc0
BLAKE2b-256 checksum
How to use checksums
298ff816f39a4609bae8badcbce54d623a45386ac067a515aba3c29d4538ca19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / listenbrainz_scrobbler-0.3.0-py3-none-any.whl

Download URL listenbrainz_scrobbler-0.3.0-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1a2a7482a24c0b29f4e5b5c95f197e456c1bb4de88b6cdeb770352cc765e2e1
BLAKE2b-256 checksum
How to use checksums
14c7f9b7cd91fbd993d79041c5d7d3a311a662134678af32b67271ecef311551
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for listenbrainz-scrobbler 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page