Commits
0463cca
.forgejo
contrib
examples
packaging
src
.dockerignore 17 B
.gitignore 14 B
Cargo.lock 59.8 KiB
Cargo.toml 2.9 KiB
LICENSE.md 33.9 KiB
README.md 6.5 KiB

Scropple (Linux)

Scrobbles what your Linux media players play. It follows players over MPRIS on the session bus — Spotify, Strawberry, Rhythmbox, Elisa, VLC, mpv (with its mpris script), and anything else that speaks it — and sends what you play to any number of backends at once:

  • Scropple servers: final_track, ircd’s ScrobbleServ, anything that takes the Scropple HTTP backend’s JSON;
  • ListenBrainz, or another server speaking its API;
  • Last.fm.

The desktop sibling of scropple-android, with the same rules for what counts as a play.

Install

From the forge’s package repositories

Every push to master builds a .deb (Debian trixie/forky) and an .rpm (EL9 and newer, Fedora, openSUSE) and publishes them to this repository’s package registries; a vX.Y.Z tag publishes a release.

# Debian / Ubuntu
curl -fsSL https://gg.neiam.co/pkg/_keys/deb/neiam | sudo tee /etc/apt/keyrings/neiam.asc >/dev/null
echo "deb [signed-by=/etc/apt/keyrings/neiam.asc] https://gg.neiam.co/pkg/deb/neiam/scropple-linux $(lsb_release -cs) main" \
  | sudo tee /etc/apt/sources.list.d/scropple.list
sudo apt update && sudo apt install scropple

# Fedora / RHEL / openSUSE: /etc/yum.repos.d/scropple.repo
#   [scropple]
#   name=scropple
#   baseurl=https://gg.neiam.co/pkg/rpm/neiam/scropple-linux
#   enabled=1
#   repo_gpgcheck=1
#   gpgcheck=0
#   gpgkey=https://gg.neiam.co/pkg/_keys/rpm/neiam
sudo dnf install scropple

The package installs /usr/bin/scropple and the user unit; then, as you:

scropple init                                    # config + empty token file
$EDITOR ~/.config/scropple/config.toml           # your backend(s)
scropple login finaltrack                        # and each other backend
scropple check
systemctl --user enable --now scropple

From source

cargo build --release
install -Dm755 target/release/scropple ~/.local/bin/scropple

scropple init                                    # the example config, and an empty token file (0600)
$EDITOR ~/.config/scropple/config.toml           # your backend(s)
scropple login finaltrack                        # paste a token from its Scrobbling page

scropple check                                   # config and tokens readable?

install -Dm644 contrib/scropple.service ~/.config/systemd/user/scropple.service
systemctl --user daemon-reload
systemctl --user enable --now scropple
journalctl --user -u scropple -f

Backends

Each [[backend]] in the config gets every scrobble, with its own queue. type says what it speaks (scropple when left out), and scropple login NAME signs it in, saving the token to its token_file (0600):

type url Signing in
scropple required: the server paste a token from its Scrobbling page
listenbrainz defaults to https://api.listenbrainz.org paste your user token from listenbrainz.org/settings; it’s checked before it’s saved
lastfm defaults to Last.fm’s API Last.fm opens in your browser to allow Scropple; the session key is saved. No password is involved.
[[backend]]
name = "listenbrainz"
type = "listenbrainz"
token_file = "listenbrainz.token"

[[backend]]
name = "lastfm"
type = "lastfm"
token_file = "lastfm.session"

Last.fm calls are signed with an API key and secret belonging to an application registered at last.fm/api/account/create. A build can carry them, from SCROPPLE_LASTFM_API_KEY and SCROPPLE_LASTFM_API_SECRET at compile time; otherwise (or to use your own) set api_key and api_secret_file (or api_secret) on the backend. scropple check says which it’s using.

A backend that isn’t signed in yet keeps its scrobbles queued until it is (restart scropple after login). Last.fm may accept a call but ignore some plays (more than two weeks old, say); those are logged, not retried.

What counts as a play

As on Android (and Last.fm): a track scrobbles once it’s been played for half its length or 4 minutes, whichever is less; tracks of 30 seconds or less never do. Paused time doesn’t count. A player that doesn’t report a length gets the 4-minute rule. “Now playing” goes out as a track starts.

Each scrobble is kept in a queue (~/.local/state/scropple/queue.sqlite) per backend until that backend takes it, retried with backoff (a minute, doubling, at most 6 hours), so plays made offline arrive later. A server that refuses a play outright (a 4xx such as 422) has it dropped; a network error, a 5xx, a 429 or a 401/403 is retried.

Which players

MPRIS doesn’t say whether something is music or a video, so, as on Android, it’s by player. By default these are never scrobbled:

  • browsers (Firefox, Chromium, Chrome, Brave, Vivaldi, Opera, Edge, LibreWolf, Plasma Browser Integration) — every YouTube video would count;
  • KDE Connect and GSConnect — they relay your phone’s playback, which Scropple on the phone already scrobbles;
  • playerctld — it re-announces the other players.

[filter] in the config replaces that list (deny) or scrobbles only what you name (allow).

Commands

scropple / scropple run the daemon
scropple players every player on the bus, what it’s playing, whether it would scrobble
scropple init [--force] write the example config to the config path, and an empty private token file
scropple check the config, and whether each backend is signed in
scropple login NAME sign a backend in, saving its token
scropple queue scrobbles waiting, per backend

--config PATH for another config. RUST_LOG=scropple_linux=debug logs every track and state change.

Development

cargo test
cargo clippy --all-targets -- -D warnings
cargo run --example fake_player -- "Pink Floyd" "Time" 40   # a pretend player
cargo run -- players

# the packages, as CI builds them
podman build --target packages --output type=local,dest=./dist -f packaging/Dockerfile .
engine what counts as a play: Session (one player’s timing, ported from scropple-android’s ScrobbleSession, with its tests), Filter, Engine
mpris following players on the bus, metadata → tracks
backend scropple (the Scropple HTTP contract), listenbrainz, lastfm (signing, error codes, the desktop sign-in flow)
queue scrobbles waiting, in SQLite
daemon the wiring

License

GPL-3.0, as scropple-android.