Simple Editing of the Simple Last.fm Scrobbler

I recently installed a GNU FM instance to scrobble my listened tracks to. Over the past four years, I've mostly used last.fm just for the data collection to see what my listening habits are like. And considering I like to control my own data, GNU FM is a perfect fit for me.

The only issue with running your own GNU FM server is that client support is really lacking. While you'll find quite a lot of last.fm clients, a few libre.fm (which is powered by GNU FM) clients, there aren't many that support a personal server. For the most part though, this isn't an issue for me. I use MPD for the majority of the time and the client that I use (mpdscribble) allows for personal servers. The other times that I listen to music, I generally use VLC or the native Android music player (Apollo on Cyanogenmod). If you dig into the settings in VLC, you can easily point it where ever you need to.

editing 1

However, with Android, I couldn't find anything that would work for me. The only option that I found was to add an entry to my hosts file, pointing the libre.fm scrobble point to my IP address at home. Once that is in place, you can use any scrobbler that works with libre.fm, just using the credentials for your server. This works well however, seeing that I flash my devices with fresh roms often, the hosts file gets wiped out often. Bummer.

I found an even better solution. I've grabbed the source for the Simple Last.fm Scrobbler app and modified it to point to my server. Turns out it was quite easy to do, even though I'm not experienced with hacking on Android apps.

First, I pulled the source via git.

git clone git://github.com/tgwizard/sls.git

There is only one file that needs to be edited. I edited it from the command line but, could have used Eclipse just as well. The file needing the edit is

src/com/adam/aslfms/service/NetApp.java

Starting with line 28 there is the last.fm and libre.fm details and I just added a jpope.org section to the array.

public enum NetApp {
LASTFM(
0x01, "Last.fm", "http://post.audioscrobbler.com/?hs=true", "",
"https://www.last.fm/join", "http://www.last.fm/user/%1"), //
LIBREFM(
0x02, "Libre.fm", "http://turtle.libre.fm/?hs=true", "librefm",
"http://libre.fm/", "http://libre.fm/user/%1"),
JPOPEDOTORG(
0x03, "jpope.org", "http://post.scrobble.jpope.org/?hs=true", "jpopedotorg",
"http://scrobble.jpope.org/", "http://scrobble.jpope.org/user/%1");

And then I opened up Eclipse which I already had set up for Android development. I then started a new project pointing to the downloaded code. (File>New>Other>Android Project from Existing Code). Once opened, I opened the AndroidManifest.xml file and used the Export Wizard to export and sign the apk. I loaded this apk onto my devices and am now able to scrobble to three places at once. Of course, I don't need to be scrobbling to all three at once but, I can if I wanted or needed to.

editing 2

editing 3

Hot damn, no hosts file editing will be needed any more. \o/

Now, go out and scrobble something.

EDIT 2013-01-09: I found an error in my previous code which caused me to be logged out of my GNU FM instance and Libre.fm. The code edit above now reflects my current settings. The line previously read:

0x03, "jpope.org", "http://post.scrobble.jpope.org/?hs=true", "librefm",

and I changed it to:

0x03, "jpope.org", "http://post.scrobble.jpope.org/?hs=true", "jpopedotorg",

Now, all seems good.


Have a response to this post? Please use this link.