I recently made the switch to cmus for playing my music collection and have been very happy with it. It is quite fast and uses hardly any resources, but one of the first things I needed to accomplish was being able to scrobble my music to Libre.fm.

I was a long time user of Last.fm, but I feel it has become too much of a monster (and a dying one at that), and this prompted me to switch to Libre.fm. I really only scrobble my music so I can go back later and see my listening habits, however, I also like being able to share that history with others.

Cmus allows you to scrobble your music using status display programs. I initially tried a few listed on their website, but I was unable to get any of them working. I tried again and eventually got CmuScrobbler working with Libre.fm perfectly.

CmuScrobbler is written in Python and supports scrobbling to Last.fm and Libre.fm. It is currently unmaintained, but in its current state, it does work fine. It even cached all of my listens during the recent Libre.fm outage and scrobbled everything when the site came back up. It requires just a little configuration to get it up and running, but it takes no time at all.

The first thing you’ll want to do is head over to the GitHub page for CmuScrobbler and download cmuscrobbler.py. Open it up in your favorite text editor and make the appropriate changes at the beginning of the file. If you are using Libre.fm like me, you’ll want to comment out the lines for Last.fm and uncomment the lines for Libre.fm. You should have something like the following:

{ 'username':      'USERNAME',
  'password':      '5f4dcc3b5aa765d61d8327deb882cf99',
  'cachefile':     '/home/user/.cmus/cachefile',
  'scrobbler_url': 'http://turtle.libre.fm/',
  'pidfile':       '/home/user/.cmus/pidfile',
},

Your password will not be entered in plain-text, Instead, you will need to enter a hashed version of it. There are instructions on how to do this below the configuration in cmuscrobbler.py. You will need to open up a terminal and launch Python. Then enter the following two lines:

>>> from hashlib import md5
>>> md5('password').hexdigest()

You should get a hashed version of your password. Copy this over to the password line in cmuscrobbler.py.

Looking at the INSTALL guide in GitHub, you will also see you will need an additional Python library to get things working. The author says you need a patched version of the Python library scrobbler until his patches get accepted upstream. I have no idea if they ever were, so I went ahead and decided to just install his patched version. If you are on Debian/Ubuntu, you might need the python-setuptools package, but you can install it using the following:

sudo easy_install https://noahduffy.me/files/scrobbler-1.0.0a2_patch-py2.7.egg

I moved cmuscrobbler.py into the .cmus directory in my home folder, but you can really move it anywhere you prefer. You will need to make the program executable:

chmod a+x cmuscrobbler.py

Then in cmus, set it to be the status display program:

:set status_display_program=/path/to/cmuscrobbler.py

If you configured everything correctly, you should now be scrobbling to the service of your choice! Feel free to reach out to me if you come across any issues.