You sometimes want announce what music you’re playing on IRC, but when using irssi on a remote server this becomes something of a problem. Therefore I wrote a script for irssi that track info for the currently playing track from last.fm, and prints it to the current channel.
To use the script:
1. Get it and place it in your ~/.irssi/scripts folder.
2. Optionally place a symlink to it in ~/.irssi/scripts/autorun directory to load it automatically when you start irssi.
3. Edit the file and change the $lastfmuser variable to your Last.fm username.
4. Load the script in irssi: /RUN npScriptLastFm.pl
5. You can now use the script by using the command /np
As written in the file itselft it’s distributed under the MIT license.
Hope you’ll find it useful.
Update 2: It is no longer recommended to use this script. See this comment for details and a better alternative.
Update 1: Thanks to Salminen (see comments), the script should now be working, I’ve updated the link so it points to the working version.
Hi, when I run the script I get this in my status window:
18:51:05 Irssi: Loaded script npScriptLastFm
18:51:08 Irssi: Not enough parameters given
18:51:08 Irssi:
Any idea why?
Thank You :)
https://blog.ryara.net/wp-content/uploads/2007/09/npscriptlastfm.pl says 404 :(
Sorry about that, the link should be working now. However the script seems to be broken, I’ll look over it sometime when I get time for it.
Yeah, I get the same “not enough parameters” problem as Ozzee
Nice script indeed.
First I had “not enough parameters” errors, but I got this working on my server by changing
grep -A 1 “”
to
grep -A 1 ”
So wordpress doesn’t like quatation marks?
http://huono.info/npScriptLastFm.pl <
thx for this script!!!
i took a few changes, for me its much faster.
http://nopaste.info/2d65ee835c.html
The changes you made does more than speeding it up, you change the functionality as well. The command you provided ( curl –silent http://ws.audioscrobbler.com/1.0/user/$lastfmuser/recenttracks.txt | head -n1 | sed ‘s,^………..,,;’ | recode utf-8..iso-8859-1 ) fetches the last song you’ve finished listening to, not the one you’re currently listening to.
“Add this track to your playlist” part doesn’t work with “eq” on my computer, changed it to “==” and now it works.
I don’t know if this feature has something to do with different perl versions.
@Salminen
Ummm….
Using == is BAD for strings. Comparing any two strings with == will return true. If you don’t believe me, try
perl -e 'print "true\n" if ("Add this track to your playlist" == "hi")'
That said, if you have the same script I downloaded, changing it to == should NEVER work, but will only print “Nothing playing!” every time you use the command.
@Possum
My computer says “Add this track to your playlist” to the channel if I use “eq” but with “==” it says what I’m playing and when not playing it echos me “Nothing playing!”.
So why not use somethind “bad” if it works when the original doesn’t?
here is my tweaked version. shows artist and track. so if not playing right now, shows the last one played.
creds to the original creator :)
http://slug.dy.fi/npScriptLastFm.pl
Instead of using my script (or any modified version of it) I would recommend to use http://soy.se/code/lastfm.pl instead – it has many more features, and uses a better mechanism to fetch the data (Last.fm API instead of screen scraping).