Top

Last.fm v1.1.1


mIRC Code
+ 1 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Oct 04, 2009
Last Updated  Oct 04, 2009
Tags  last.fm  now  np  playing  socket 

Introduction

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

Grab the Code

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

  (0)  RSS

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom