Looking For Quacks In The Pavement

Gnu FM – A self-hosted Last.fm alternative

Remember scrobbling?

Ever even heard of scrobbling?

Anyway. For the last dozen or so years I’ve configured my primary music player (current MediaMonkey) to send last-played data for songs in my library to the Last.fm website. The idea being that folks can see what I’m currently playing and/or most recently listened to. That’s entertaining in and of itself, at least to me. There’s a bonus, however. Doing big-data things to my music-listening information paired with similar information from other users results in an ability to recommend new music. The idea goes something like this:

  1. I listen to These Songs by These Bands quite a lot.
  2. A stranger on the Internet also listens to These Same Songs by These Same Bands, a lot.
  3. This stranger also listens to Some Other Songs by Some Other Bands.
  4. In theory, there’s a good chance that I might also like those Other Songs and/or Other Bands based on a commonality of musical tastes with a stranger on the Internet.

It’s a great idea. I even found some new-to-me musical artists as a result from time to time, such as Way Out West.

However. Last.fm has… degraded somewhat in usefulness over the course of this decade, and when DJ Sundog over on Mastodon recently noted that a self-hosted alternative exists, I had to try it out. Let’s be clear that I’m basically losing the “big data” part of what made Last.fm (and theoretically Libre.fm, its erstwhile replacement) valuable. Now I just want somewhere to point my data to. How I’m going to use that data is a problem for another day. I love building things!

Here’s what I’ve learned. (And, yes, I need to write about my Mastodon instance at some point as well. Please be patient; I’m out of the habit of actually blogging.)

Caveat number one: It looks like this project hasn’t been updated in a couple of years or so. If it goes awry, ain’t nobody likely to help you fix what goes kerblooey.

Start with these instructions. If you can meet the dependency requirements you’re off to a good start. (I had to use ‘apt’ to install ‘libphp-adodb’ and ‘smarty-gettext’ on my Ubuntu rig, everything else was already there.) The instructions talk about using Composer to manage requirements, I don’t have Composer and ‘apt’ did what little work was needed. So basically, follow the instructions at the preceding link in general, but skip the parts that don’t apply to you as needed.

If, like me, you’re not really hip to ‘git’, you can just go to the Gnu FM repository and grab the snapshot link for the master branch as a tarball. Extract it into a temp directory somewhere safe. You’ll only need two directories out of it anyway.

Caveat number two: All of this is going to be very specific to my setup, your mileage will vary, etc.

Gnukebox is the data collection arm of the project. Make a virtual host in your Apache rig for it with a corresponding directory path, filled with the contents of the Gnukebox subdirectory from the repository download.

One thing the documentation doesn’t mention is the need for ServerAlias directives. See, you’re going to be hacking your computer’s ‘hosts’ file later on and you need Apache to be aware of traffic coming in for two audioscrobbler.com hostnames. So my gnukebox.conf Apache 2 config looks like this:

<VirtualHost *:80>
ServerName gnukebox.greyduck.net
 ServerAlias post.audioscrobbler.com
 ServerAlias ws.audioscrobbler.com
 DocumentRoot /srv/www/gnukebox/html
 ErrorLog /srv/www/gnukebox/logs/error.log
 CustomLog /srv/www/gnukebox/logs/access.log combined

You’ll only need the audioscrobbler.com aliases for the Gnukebox virtual host, not for the Nixtape site.

The instructions linked above state that you should be capable of making a MySQL database. This is a good time to do so.

mysqladmin create gnukebox
mysql gnukebox
grant all on gnukebox.* to nameauser@localhost identified by 'goodpassword';
flush privileges;

And there you go. You’ll need the database name, username, and password when it comes time to set up both parts of the product. Both websites ask for the same database info during the web-based installation phase. Oh, and MySQL’s port is 3306. I had to look it up, now I’ve saved you that step. (Use ‘localhost’ for the server name.)

The last thing not mentioned in the instructions is the ‘hosts’ file trickery. Turns out, very few scrobbling plugins allow you to change the service you’re sending data to. Thus, what you have to do is trick your computer into thinking that those two hostnames back there in the Apache config actually live on your webserver.

Fastest way to get at your ‘hosts’ file on a Windows box in such a way that it lets you save the file directly instead of having to save it somewhere else, then copy it into its proper location? Run a command prompt as Administrator, then type:

notepad c:\windows\system32\drivers\etc\hosts

Notepad will inherit the as-Administrator-ness of that command prompt, thus the ability to save the ‘hosts’ file directly into place. No muss, no fuss. And what you enter will look something like this:

# Hijacking Last.FM to point to my Gnukebox install
w.x.y.z post.audioscrobbler.com
w.x.y.z ws.audioscrobbler.com

Obviously, replace ‘w.x.y.z’ above with the IP of your webserver. If you visit either of those hostnames in a browser you should get your Gnukebox website with a big “Please point your music player here” message at the top. Then, if you create a user in your Nixtape install and start playing some music in your scrobble-capable player, data should result!

Now all I need to do is tweak my Nixtape site to remove the Bitcoin “support” links and whatnot…

1 Comment

  1. Wonderduck

    I understood some of those words.

© 2020 greyduck.net

Theme by Anders NorenUp ↑