From Indie IT Wiki
Jump to: navigation, search

HOWTO: Show Top Artists Via Command Line

I wanted to write my own Tweekly-type script to automatically tweet my Top 3 Artists each week.

  1. Find out where the charts are
  2. Find the handy XML feed
  3. Write a PERL script to parse the XML and output
  4. Install a Ruby script to tweet via BASH
  5. Write a BASH script to combine it all
  6. Add that BASH script to my weekly cron job on my Linux server (always on)

Here we go...

RUBY Script


PERL Script (


# load perl modules
use LWP::Simple qw(!head);
use XML::Simple;
use utf8;

# create URL object
$urlcurrent = get('');

# create XML object
$xml = new XML::Simple;

# read XML file and set key attribute
$data = $xml->XMLin("$urlcurrent",KeyAttr=>1);

# show artists
foreach $entry (@{$data->{artist}}) {
print "My Top 3 #lastfm Artists: $artists[0] ($playcounts[0]), $artists[1] ($playcounts[1]), $artists[2] ($playcounts[2])";

# exit nicely

BASH Script (

LASTFM=$(/home/paully/Bin/ | strings |tr -d '\n')
/usr/local/bin/tweet update "$LASTFM"


@weekly ~/Bin/

Total time taken: 1 hour  :-)

HOWTO: Scrobble With MPD Music Player Daemon

Install the background mpdscribble daemon...

sudo aptitude install mpdscribble

Now stop the system service version...

sudo service mpdscribble stop
sudo update-rc.d -f mpdscribble remove

Create your own configuration file...

mkdir ~/.mpdscribble
nano ~/.mpdscribble.conf
 host = localhost
 port = 6600
 log = /home/user/.mpdscribble/mpdscribble.log
 verbose = 2
 sleep = 1
 musicdir = ~/Music
 proxy = none
 url =
 username = user
 password = 34534524524tefevdfgaseRQ
 journal = /home/user/.mpdscribble/lastfm.journal

Start the daemon...


Add it to your Desktop's Startup and Session in XFCE

Applications > Settings Manager > System > Session and Startup > Application Autostart > Add > mpdscribble

HOWTO: Scrobble With VLC Media Player

Install the background scrobbler daemon...

sudo aptitude install -y lastfmsubmitd
sudo update-rc.d lastfmsubmitd defaults
sudo service lastfmsubmitd restart

In VLC...

Tools > Preferences > Show Settings > All
Interface > Control Interfaces > Tick 'Submission of played songs to'
Audioscrobbler > Username + Password + Scrobbler URL -
Restart VLC