Tuesday, February 2, 2010

How to gobble (GNU scrobble) to Libre.FM using Amarok2

Remember my Last.FM rant? Ever since, I have not used their service anymore. In the meantime, I found a more open alternative for the ones who like to keep track of their listening habits – it is called Libre.FM and it keeps growing.

One does not scrobble on Libre.FM, but gobbles instead.

It would have all been nice if there wouldn't have been so many issues with clients with poor or no support at all. I discontinued using my Libre.FM account when I switched to Amarok2, which offered no support for Libre.FM. Not any more! It is now possible to submit the metadata in your tracks to your Libre.FM account, even from Amarok2.


Here's a step-by-step guide.

1. Go to Libre.FM and create an account.

2. Configure Amarok: Go to Settings -> Configure Amarok... -> Internet Services -> tick the "Last.fm" check box and click the settings icon next to it. Enter here your Libre.FM username and your Libre.FM password and untick the "Submit tracks" and "Retrieve similar artists" check boxes, then click "OK".

3. Install
lastfmsubmitd. If you are using (K)Ubuntu, use this command in a terminal:
sudo aptitude install lastfmsubmitd
When asked, enter audio as the group.

4. Edit /etc/lastfmsubmitd.conf and add the following:
[server]
url=http://turtle.libre.fm/
5. Make these directories accessible:
sudo chmod -R 777 /var/spool/lastfm
sudo chmod -R 777 /var/log/lastfm
6. Download the Amarok2LibreFM script for Amarok2 (no need to unpack it, just leave it as it is).

7. Configure Amarok to use this script: Tools -> Script Manager -> Install Script, then choose the Amarok2LibreFM.amarokscript.tar.gz that you just downloaded.

8. Restart Amarok and you should be able to scrobble/gobble the tracks that you listen to.

Don't know about you, but I'm very glad that Libre.FM is "usable" again.

4 comments:

  1. Do you, by any chance, know a way to make Banshee work with libre.fm? There's some sort of /etc/hosts domain name spoof workaround, but it renders last.fm useless and some people (loosely translated: I) use that one too.

    I mean. Any option besides the „write a plugin yourself, lazy bum” one.

    ReplyDelete
  2. Hello spyked,

    I haven't tried out Banshee (I had a very short time of fooling around with Gnome and I really hated it, whoops).

    I imagine that the /etc/hosts spoof you're talking about must associate the host post.audioscrobbler.com with turtle.libre.fm's IP. It would be a line like

    89.16.177.55 post.audioscrobbler.com

    but that would mean, as you say, that you couldn't scrobble to last.fm at the same time.

    An ugly workaround, as I see it, would be to use this daemon that can be configured with Libre.FM credentials... and... *cough* a script ran each few minutes with cron. There would roughly be two steps in this process:

    1. install lastfmsubmitd and edit the /etc/lastfmdaemond.conf file:

    [account]
    user = your_libre.fm_username
    password = your_libre.fm_password

    [server]
    url=http://turtle.libre.fm

    (Don't forget to set chmod 777 on /var/spool/lastfm and /var/log/lastfm.)

    2. Write a bash script that finds out (uses CLI parameters provided by banshee?) the track title, the track album, the track artist and the track length and sends this information to turtle.libre.fm using lastfmsubmitd, then add it in your user's crontab.

    The lastfmdaemond syntax would be:

    /usr/lib/lastfmdaemond/lastfmsubmitd --encoding "UTF-8" --artist "$ARTIST" --album "$ALBUM" --title "$TITLE" --length "$LENGTH"

    I'm sorry I can't come up with an actual no-script solution.

    ReplyDelete
  3. Thanks, the script might actually be trivial to write. After crawling through the banshee manpages, I found that I can print most of the information I need about the current playing song:

    spyked@spaicd-lap:~$ banshee-1 --query-artist --query-album --query-title --query-position --query-duration
    artist: Meshuggah
    album: Nothing [Re-Issue]
    title: Rational Gaze
    position: 51.694
    duration: 326.671

    The problem is: I don't know if the lengths are in the same format and I'm not sure how to sync the querying with the actual submitting (submitting at the end of the song, for example - the Amarok2LibreFM thingie does that in a more orthodox way). Other than that, it shouldn't be too hard.

    ReplyDelete
  4. The output is nice, except for the duration.

    A solution would be to "parse" that output yourself (lastfmsubmit expects the track length in the format "mm:ss", if I'm not mistaking). First off, install bc. Then, try something like the following:

    # suppose d_line="duration: 326.671"
    trunc="$( echo "$d_line" | awk '{ print $2 }' | awk -F. '{ print $1 }' )" # trunc is "326"
    minutes="$( echo $trunc/60 | bc )" # minutes is "5"
    seconds="$( echo $trunc-$minutes*60 | bc )" # seconds is "26"
    length="$minutes:$seconds"

    And now you just have to use $length as argument for the "--length" parameter in the lastfmsubmit command.

    ReplyDelete