Note: it's easily tweaked for LibreFM etc.
This is project developed for myself to pull external scrobbles to LastFM into the Rhythmbox playcount. If anyone else finds it useful they're welcome to try it out.
It works by connecting to the LastFM api and pulling your recently scrobbled songs. Hopefully those scrobbles came from a music player using the songs from your Rhythmbox library (e.g., on your phone), otherwise it won't be able to find a match. It then edits your Rhythmbox database and updates the playcount accordingly.
Note: Sometimes the matching doesn't work. I've been tweaking the script to try handling cases when they appear, but some may still escape matching.
sync.py
with the appropriate directory structure. All commands assume linux/gnu, edit as appropriate on your own OS.git clone
the repo; cd
to the repo directory.pip install -r requirements.txt
rbsync.yaml
; you can use sample_config.yaml
as a template (e.g., cp sample_config.yaml rbsync.yaml
)rhythmdb.xml
database file, probably in ~/.local/share/rhythmbox/rhythmdb.xml
rbsync.yaml
(or you can use the default values):
a. backup: boolean whether to backup the rhythmbox database file before editing it
b. limit: maximum number of items to pull from LastFM
c. rhythmdb: the path you located in step (4)
d. last_update: the epoch time you want to start syncing from
> date +%s -d'Jan 1, 2020 03:30:00'
limit
items)sync.py
is executable: > chmod u+x sync.py
> ./sync.py
; you probably want to quit Rhythmbox before you sync so that your changes register correctly. though it might update automatically?secrets.yaml
file adjacent to rbsync.yaml
. don't share or git-sync this since it'll store your LastFM api key and password hash (rainbow table attacks?)rhythmdb.xml.backup-(date)
file adjacent to your original rhythmdb.xml file. Note: it won't clean old versions, so if you run it often, you'll spam backup files that can get quite large. suggest cleaning out old backups periodically.sync.py
around l40 and change logging.INFO
to something else, probably logging.WARNING
so you'll still see actual warnings or errors.Set up the configuration file rbsync.yaml
as described above.
Run sync.py
from the command line however you're most comfortable running python scripts.
For example: > ./sync.py
(assuming it's been chmodded to execute)
This was to get rid of a dependency and streamline everything about the configuration file.
To convert:
rbsync.cfg
key = val
to key: val
rbsync.yaml
v2.0.0: (breaking changes) Overhaul the configuration file setup and fix album matching
v1.1.1: update dependencies
v1.1.0: (breaking changes) Add configuration file
v0.1.0: Initial commit
see LICENSE
(it's GPLv3)