Last.fm Now Playing
Platform: mIRC
Published Mar 05, 2009
Updated May 29, 2009
I know there are tons of now playing scripts, but because last.fm now shows the currently playing song I figured I'd make this one for last.fm. Also I really wanted to make one for Pandora but couldn't figure out how to (if anyone can/does please let me know) and this works while I listen to Pandora because of a Firefox add-on I have.
Anyway, please give me suggestions/feedback :)
By the way: Last.fm will randomly not update the currently playing song every once in a while. If the script gets the song wrong it's because of last.fm, not the script. It grabs whatever is on your last.fm profile at the moment you use the /np alias.
To use:
-Set your username when you load the script or use the alias /lastfm nickname to set it
-Use the alias /np to describe your current song according to last.fm
;Last.fm Now Playing
;by tv3636
;Grabs the currently playing song from last.fm (if applicable) and describes it to the active window
;Takes a few seconds to grab the data
on *:LOAD:/lastfm $?="Enter your last.fm username."
alias np {
if ($sock(lastfm)) .sockclose lastfm
if (%last.fm.username) {
sockopen lastfm www.last.fm 80
set -u10 %last.fm.active $active
}
else echo $active 08,01Error, no username found. To set your username use /lastfm <username>
}
alias lastfm { set %last.fm.username $1 }
on *:SOCKOPEN:lastfm: {
sockwrite -nt $sockname GET /user/ $+ %last.fm.username HTTP/1.1
sockwrite -nt $sockname Host: www.last.fm
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:lastfm: {
var %last.fm
sockread %last.fm
if (imageMedium isin %last.fm) {
sockread %last.fm | sockread %last.fm | sockread %last.fm
describe %last.fm.active np: ♪ $regsubex(%last.fm,/(?:<(?:.*?)>)([^<]+)(?:<(?:.*?)>)(?:[^<]+)(?:<(?:.*?)>)([^<]+).+/,\2 by \1) ♪
sockclose lastfm
}
elseif (</body> isin %last.fm) echo %last.fm.active 08,01Last.fm error, no currently playing song detected.
}