🎵 Last.fm scrobbler
A Last.fm scrobbler via MPRIS2 in Linux, implemented via pylast and mpris2
Modified based on dbus-scrobbler
Features
-
scrobble music to Last.fm if one of the conditions are met:
- played for 4 mins
- played for half the length
-
update now playing status
-
offline scrobble cache support
What is MPRIS2?
MPRIS (Media Player Remote Interfacing Specification) is a standard D-Bus (Desktop Bus) interface that allows applications to communicate with and control media players running on a Linux desktop environment.
Thus, this scrobbler is a general-purpose one under the Linux desktop environment, supporting scrobble music from media players without a built-in Last.fm scrobbling feature.
Check if your media player supports MPRIS2 via (make sure the player is running):
lastfm-mpris2-scrobbler --list-players
The uri names of players will be shown
Installation
Prerequisite libraries: libglib2.0-dev and libdbus-1-dev, as mentioned in this issue
There're two options available now:
-
grab the stand-alone binary from release page
-
or, via PyPI
pip install lastfm-mpris2-scrobbler
Configurations
The program expects a config.yaml file and can be placed wherever you like, for example ~/.config/lastfm-mpris2-scrobbler/
Example and detailed information can be found in config.yaml.example:
# username for that service
user_name: foo
# md5 hash of your password (obtained via `echo -n password | md5sum`)
password_hash: abc123492abccf4f1997f7ccaabc123b
# last.fm api, which can be created via https://www.last.fm/api/account/create
api_key: 11111111111111111111111111111111
api_secret: 11111111111111111111111111111111
# the app's uri you want to scrobble
# use `lastfm-mpris2-scrobbler --list-players` to check the uri name
application_whitelist: [ "org.mpris.MediaPlayer2.harmonoid", "org.mpris.MediaPlayer2.chromium.*" ]
# by default, scrobbler will upload if the track has been played for 4 * 60 seconds or half the total length
scrobble_time_threshold: 240
# app's log level
log_level: DEBUG
Usage
lastfm-mpris2-scrobbler -c PATH_TO_YOUR_CONFIG/config.yaml
For more options, see:
lastfm-mpris2-scrobbler --help
If you want to run it as a daemon service, here's a systemd service in user space for reference:
[Unit]
Description=Last.fm scrobbler via MPRIS2
Documentation=https://github.com/Ladbaby/lastfm-scrobbler
[Service]
ExecStart=PATH_TO_YOUR_BIN/lastfm-mpris2-scrobbler -c PATH_TO_YOUR_CONFIG/config.yaml
[Install]
WantedBy=default.target
You'll have to place the service file under ~/.config/systemd/user/ and name it like scrobbler.service
To run the daemon:
systemctl --user start scrobbler.service
To run at user login:
systemctl --user enable scrobbler.service
Alternatives
If you'd like a scrobbler similar to this, there're some choices. I recommand taking a look at scrobblez. It additionally provides Spotify related improvement, but doesn't provide stand-alone binary build for installation.
Also, although rescrobbled may also work, in my case it raised "Dbus error: argument type mismatch".
Known Issues
-
If the music title contains unwanted substring (like.mp3), then Last.fm won't accept the scrobbleThe program can now remove some of the unwanted substrings, including:
.mp3.ogg.wav.acc.flac
Metadata
Release files for lastfm-mpris2-scrobbler 1.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lastfm_mpris2_scrobbler-1.0.8.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lastfm_mpris2_scrobbler-1.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.6 kB
Release files / lastfm_mpris2_scrobbler-1.0.8.tar.gz
| Download URL | lastfm_mpris2_scrobbler-1.0.8.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb52306f79f166c430ad112f4f01a49fa17db5bb6375be3df03797d848a66156
|
|
BLAKE2b-256 checksum How to use checksums |
11fb64b8c97105c0f4a5a431267b43afa86f29fafe75d78070d8e799b618ced8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / lastfm_mpris2_scrobbler-1.0.8-py3-none-any.whl
| Download URL | lastfm_mpris2_scrobbler-1.0.8-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a688bcf5f243dbab3a043e695900998a444ddc079d8ecbbbdc6335e5b16ac8a1
|
|
BLAKE2b-256 checksum How to use checksums |
6a95f062dac91e04796e68e51f56c7a2ef22b6823aca99be0110bac6dfd97efb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|