Archive

Archive for the ‘Fixes’ Category

Last.FM submissions with Audacious

June 9th, 2010 5 comments

Some time ago the good folks behind my favorite media player Audacious decided to abandon in-built support for Last.FM submissions.

The reasoning behind this seems to be that the Last.FM API was becoming a little too much to maintain which I suppose is fair enough in its quest to remain just a music player i.e. not a screen-hogging iTunes clone like so many others.

Heres how to put Last.FM support back into Audacity.

I’m going to assume you are a sensible person and using a Debian based system rather than Fedora. If you are one of these hat loving deviants, substitute ‘yum’ for apt-get below and feel free to voyage though the countless pains required to get Yum to actually do its job.

Installing LastFMSubmitD

I’m not sure on the capitalization of the daemon process LastFMSubmitD so that might be the wrong name entirely.

Anyway, first install pretty much the only component we need:

apt-get install lastfmsubmitd

OPTIONAL – Set up the HTTP_PROXY

For some reason the daemon does not get proxy details right. This is easily fixed by opening /etc/init.d/lastfmsubmitd in your favorite editor and inserting the following line somewhere near the top (I put it after the ‘GROUP=’ line which should be the last bit of the daemon config area).
If you have no idea what a proxy is or why you should be doing this you can probably skip this section.

export http_proxy="http://whatever.stupid.proxy.edu.au:8080/"

Parse Audacious output

Dump the following script somewhere you can find it. For this example I will use /home/user/bin/scrobble

?Download scrobble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
if [ ! -x '/usr/lib/lastfmsubmitd/lastfmsubmit' ]; then
	echo "LastFMSubmitD does not appear to exist on this machine"
	echo "You can install it using Apt or Yum"
	exit 1
fi
if [ "$#" == 0 ]; then
	echo 'Usage: scrobble "<artist> - <song>" "<length>"'
	exit 1
fi
 
ARTIST=${1%% - *}
SONG=${1##* - }
LENGTH=$[ $2 / 1000 ]
echo "ARTIST = [$ARTIST]"
echo "SONG = [$SONG]"
echo "LENGTH = [$LENGTH]"
 
/usr/lib/lastfmsubmitd/lastfmsubmit --artist "$ARTIST" --title "$SONG" --length "$LENGTH"

Pointing Song Change at your script

First make sure you have the Song Change plugin enabled in Audacious first.

Now point the command Audacious is to run when starting a new song at the script in the following way:

/home/user/bin/scrobble "%s" "%l"

All done. Now any tracks played via Audacious will be passed to the script which will parse the incoming song title into a format that the LastFMSubmitD daemon can use.

Categories: Fixes Tags: , ,

Converting Null

April 24th, 2009 2 comments

Simple shell script fix this week – convert all newlines to null characters.

Since most Linux shells have a major problem with doing this in a sensible way, the following (on my box called simply ‘0’) takes any input (either from files or via a pipe) and converts the characters.

1
2
3
4
5
6
7
#!/usr/bin/perl
# From: http://hashbang.net/2009/04/converting-nullconverting-null/
# Author: Matt Carter <m@ttcarter.com>
while (<>) {
	s/\n/\x00/g;
	print;
}

So now commands like:

find -type f | 0 | xargs -0 | mplayer

work perfectly (in the above case to play all files in directories recursively.

You may well ask why I don’t use the simple ‘-print0′ argument for the find program – because it doesn’t work when using later pipes.

For example if i wanted to sort the above, ‘sort’ would see the null symbol as a regular character.

So ‘0’ works nicely in this case:

find -type f | 0 | sort | xargs -0 | mplayer

Or even:

find -type f | 0 | shuffle | xargs -0 | mplayer

To play all files recursively, in random order. See the article on shuffle for the source code of that filter.

Categories: Fixes, HowTo's Tags: , , ,