Last.fm v1.1.1

Platform:  mIRC
Published  Oct 04, 2009
Updated  Oct 04, 2009
Simple socket script. Takes a username, returns last track played by him/her, providing they scrobble their music ;_)

usage:

!last.fm lastplayed <username> [N]

(where N is amount of recent played tracks to show, max of 5 to not flood channels over).

This is just a small start. Eventually it'll become something massive ;_)


(credit for $striphtml goes out to ayon)

version history:

v1.0 - initial release

v1.1 - added support for getting multiple results for recent tracks
- cleaned up code

v1.1.1 - fixed a small unicode bug. :x alias last.fm {
set %lf.chan $1
set %lf.method $2
set %lf.user $3
set %lf.total $4
set %lf.count 1
sockopen last.fm ws.audioscrobbler.com 80
}

on *:TEXT:!last.fm *:#zomgwtfbbq: {
if (%lf_flood. [ $+ [ $nick ] ] == $null) {
set -u10 %lf_flood. [ $+ [ $nick ] ] 1
if (($2 == lastplayed) && ($3 != $null)) {
if (($4 <= 5) || ($4 == $null)) {
last.fm $chan $2 $3 $iif($4 == $null, 1, $4)
}
else {
msg $chan You can only show up to 5 recent tracks.
}
}
}
}

on *:SOCKOPEN:last.fm: {
if (%lf.method == lastplayed) {
sockwrite -nt $sockname GET $+(/2.0/user/,%lf.user,/recenttracks.rss) HTTP/1.1
}
sockwrite -nt $sockname Host: ws.audioscrobbler.com
sockwrite -nt $sockname $crlf
}

on *:SOCKREAD:last.fm: {
sockread %lf.temp
var %lf.temp $utfdecode(%lf.temp)
; echo -s %lf.count $(|) %lf.temp
if (%lf.method == lastplayed) {
if ((<title> isin %lf.temp) && (<docs> !isin %lf.temp)) {
var %lf.title. [ $+ [ %lf.count ] ] %lf.temp
.timer 1 %lf.count msg %lf.chan $striphtml(%lf.title. [ $+ [ %lf.count ] ])
inc %lf.count
if (%lf.count > %lf.total) {
sockclose $sockname
unset %lf.*
}
}
}
}




alias striphtml {
noop $regsub($1-,/(<(?:.+?)>)/g,$null,%string)
return %string
}

Comments

Sign in to comment.
Jethro   -  Aug 21, 2011
KillerX, you dug up an old thread and sweated the small stuff....
 Respond  
KilllerX   -  Aug 21, 2011
another way to display the $null check is using a ! before your check so the

if (%lf_flood. [ $+ [ $nick ] ] == $null)

could be changed to

if (!%lf_flood. [ $+ [ $nick ] ] )

and it will work the same. Personally I prefer using the ! as it saves space and works easier on my eyes. But this depends on the user/writer. each has a preference they use. So either (identifier == $null) or (!identifier)
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.