Last.fm Info (API)

By hxck
Platform:  mIRC
Published  Oct 15, 2011
Updated  May 15, 2013
EDIT: I made an alias version of just the now playing command. Use /lfm to spam. Here (Change line 6 to your username)

Last.fm Info via API. Thanks to ES for helping me out with this and just generally being a bro.

!lfmhelp - for this list of commands

---Adding yourself to the bot
--
!lfma username :: Add yourself to the bot
!lfmd username :: Remove yourself from the bot
--
---Basic information
!lfm [username] :: Now Playing info
!lfmu [username] :: Profile information on the specified user
--
---Advanced information
!lfmc user1 [user2] :: Taste-O-Meter rating with another nick. Type !lfmhelp compare for more information.
!lfms artist :: 10 artists similar to the one specified
!lfmnr <1-10/username> [1-10] :: Recommended new album(s) based on your listening history. Type !lfmhelp nr for more information.
!lfmta :: Top 10 overall artists on the Last.fm charts
!lfmuta <overall|7day|3month|6month|12month> [username] :: Top 10 Artists for a specific period/user
!lfmn [username] :: Top 10 recommended Neighbors for the specified user

Values in [ ] are optional.

-------------------------------------Examples

(11:35:27 pm) <~hxck> !lfm [name]
(11:35:28 pm) <~Victoria> Last.fm » Moonlit Sailor - Sunbeams (Played 53 times) <3 [05:29]

The Now Playing command will show artist - song, how many times the track has been played, if its a loved track and the length.

-------------------------------------

(11:11:57 pm) <~hxck> !lfmu [name]
(11:11:59 pm) <~Victoria> Last.fm » User: fleshis4zombies » ID: 10339776 » Subscriber? No » Type: user
(11:12:01 pm) <~Victoria> Last.fm » Real Name: DJ Jazzy Jeff » Name: fleshis4zombies » Age: 24 » Gender: Male » Country: US
(11:12:01 pm) <~Victoria> Last.fm » Plays: 18884 » Image: http://userserve-ak.last.fm/serve/126/66169924.png » http://last.fm/user/fleshis4zombies

The User Info command displays profile information on specified nick.

-------------------------------------

(04:23:56 pm) <~hxck> !lfmc ohaitharu
(04:23:57 pm) <~Victoria> Last.fm » fleshis4zombies's compatibility with ohaitharu is Low (28.5%). Artist(s) they have in common include(s) Victoria Justice, Ferry Corsten, Ariana Grande, Skrillex, From Autumn to Ashes.

The Taste-O-Meter Comparison command takes 2 users and compares their tastes together, same as its done automatically when you visit a person's profile on the site. Gives percentage and 5 similar artists.

-------------------------------------

(11:11:10 pm) <~hxck> !lfms Fear Before The March of Flames
(11:11:11 pm) <~Victoria> Last.fm » Similar Artists: Fear Before, Heavy Heavy Low Low, The Number Twelve Looks Like You, ORBS, The Jonbenet, Duck Duck Goose, Trophy Scars, The Blood Brothers, Poison The Well, United Nations.

The Similar Artists command grabs 10 similar artists to the one you supply, same as visiting an artist page on the website.

-------------------------------------

(05:32:11 pm) <~hxck> !lfmnr [name] 5
(05:32:13 pm) <~Victoria> Last.fm » New Album Releases for fleshis4zombies are: Greatest Hits 1 & 2 - Journey, Cinematic Attractions - A Static Lullaby, Empros - Russian Circles, Low Level Owl, Vol. 1 + 2 - The Appleseed Cast, Shoulders & Giants - Collapse Under the Empire.

The New Releases command grabs up to 10 new releases of bands you've listened to based on your history.

-------------------------------------

(11:08:49 pm) <~hxck> !lfmta
(11:08:50 pm) <~Victoria> Last.fm » Top of the Last.fm Charts: Coldplay, Radiohead, Adele, The Beatles, Rihanna, Florence + The Machine, Red Hot Chili Peppers, Muse, Lady Gaga, Nirvana.

The Top Artists command shows the top 10 artists on the Last.fm charts.

-------------------------------------

(07:39:00 am) <~hxck> !lfmuta [name] 7day
(07:39:04 am) <~Victoria> Last.fm » Top 5 Artists for fleshis4zombies » Period: Last 7 Days: C418, I See Stars, Rosaline, Emery, Glassjaw,

The User Top Artists command shows the top 5 artists for a specified period/user. Possible periods include Overall, 7day, 3month, 6month and 12month.

-------------------------------------

(10:52:54 pm) <~hxck> !lfmn [name]
(10:52:55 pm) <~Victoria> Last.fm » Top 10 Neighbors: SkaterKuehl96, Wes2theG, charliestrouse3, brainlessbrook, wendy-clear, oceanfloorgrave, danielg2112, mts5424, laurenelysse, skyisthelimit13. http://www.last.fm/user/fleshis4zombies/neighbours

The Neighbors command gives you the top 10 users recommended as friends based on Taste-O-Meter compatibility. On *:START: {
if (!$hget(lastinfo)) { hmake lastinfo 20 }
hload -s lastinfo lastinfo.hsh
}

On *:LOAD: {
if (!$hget(lastinfo)) { hmake lastinfo 20 }
hload -s lastinfo lastinfo.hsh
}

on *:TEXT:!lfmhelp*:#: {
if ($2 == nr) {
.query $nick The New Releases command works 4 ways:
.query $nick 1. !lfmnr - This will show 5 (Default) recommended new albums based on the person who triggered it
.query $nick 2. !lfmnr <1-10> - This will show 1-10 (depending on what you chose) recommended new albums based on the person who triggered it
.query $nick 3. !lfmnr [username] - This will show 5 (default) recommended new albums based on username
.query $nick 4. !lfmnr [username] <1-10> - This will show 1-10 (depending on what you chose) recommended new albums based on username
}
if ($2 == compare) {
.query $nick The Taste-O-Meter works 2 ways:
.query $nick !lfmc user1 - This will compare user1 with the person who triggered it (assuming that person has added their Last.fm nick to the bot)
.query $nick !lfmc user1 user2 - This will compare user1 with user2
}
if (!$2) {
.query $nick !lfmhelp - for this list of commands

.query $nick 3---Adding yourself to the bot
.query $nick --
.query $nick !lfma username :: Add yourself to the bot
.query $nick !lfmd username :: Remove yourself from the bot
.query $nick --
.query $nick 3---Basic information
.query $nick !lfm [username] :: Now Playing info
.query $nick !lfmu [username] :: Profile information on the specified user
.query $nick --
.query $nick 3---Advanced information
.query $nick !lfmc user1 [user2] :: Taste-O-Meter rating with another nick. Type !lfmhelp compare for more information.
.query $nick !lfms artist :: 10 artists similar to the one specified
.query $nick !lfmnr <1-10/username> [1-10] :: Recommended new album(s) based on your listening history. Type !lfmhelp nr for more information.
.query $nick !lfmta :: Top 10 overall artists on the Last.fm charts
.query $nick !lfmuta <overall|7day|3month|6month|12month> [username] :: Top 10 Artists for a specific period/user
.query $nick !lfmn [username] :: Top 10 recommended Neighbors for the specified user
}
}

on *:TEXT:!lfm*:#: {
if ($sock(lfm)) { sockclose lfm }

; ===================
; Add or Remove Users
; ===================

if ($1 == !lfma) {
hadd lastinfo $nick $2
msg # Added! Use !lfm or !lfmu
}
if ($1 == !lfmd) {
hdel lastinfo $nick $2
msg # User removed.
}

; =================
; Set method 'Info'
; =================

if ($1 == !lfmu) {
if ($sock(lfm)) { sockclose lfm }
set %methodd info
if (!$2) {
if (!$hget(lastinfo, $nick)) {
msg $chan No such nick regged with the bot, please add one using !lfma <Last.FM Nick>
halt
}
if $hget(lastinfo, $nick) {
set %username $hget(lastinfo, $nick)
set %method /2.0/?method=user.getinfo&user= $+ %username $+ &limit=1&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
}
}
if ($2) {
set %username $iif($hget(lastinfo, $2),$hget(lastinfo, $2),$2)
set %method /2.0/?method=user.getinfo&user= $+ %username $+ &limit=1&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
}
sockopen lfm ws.audioscrobbler.com 80
sockmark lfm msg # 4Last.fm »
}

; ===============
; Set method 'NP'
; ===============

if ($1 == !lfm) {
if ($sock(lfm)) { sockclose lfm }
set %lfmnametemp 0
set %lfmartisttemp 0
set %lfmalbumtemp 0
set %methodd np
if (!$2) {
if (!$hget(lastinfo, $nick)) {
msg $chan No such nick regged with the bot, please add one using !lfma <Last.FM Nick>
halt
}
if ($hget(lastinfo, $nick)) {
set %username $hget(lastinfo, $nick)
set %method /2.0/?method=user.getrecenttracks&user= $+ %username $+ &limit=1&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
}
}
if ($2) {
set %username $iif($hget(lastinfo, $2),$hget(lastinfo, $2),$2)
set %method /2.0/?method=user.getrecenttracks&user= $+ %username $+ &limit=1&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
}
sockopen lfm ws.audioscrobbler.com 80
set %lfm.chan #
}

;=====================
; Set method 'Compare'
;=====================

if ($1 == !lfmc) {
set %methodd compare
if (!$2) { msg # You must provide a nickname to compare with. | halt }
if (!$3) {
if (!$hget(lastinfo,$nick)) { msg # You're not regged with the bot, please add one using !lfma <Last.FM Nick>, or do !lfmc <Last.FM Nick 1> <Last.FM Nick 2> | halt }
else {
set %lfmcu1 $hget(lastinfo,$nick)
set %lfmcu2 $iif($hget(lastinfo,$2),$hget(lastinfo,$2),$2)
}
}
if ($3) {
set %lfmcu1 $iif($hget(lastinfo,$2),$hget(lastinfo,$2),$2)
set %lfmcu2 $iif($hget(lastinfo,$3),$hget(lastinfo,$3),$3)
}
set %method $+(/2.0/?method=tasteometer.compare&type1=user&type2=user&value1=,%lfmcu1,&value2=,%lfmcu2,&api_key=bdf34b247ee7ee2ccd8e856a675bb82d)
sockopen lfm ws.audioscrobbler.com 80
sockmark lfm msg # 4Last.fm 4»
}

;=====================
; Set method 'Similar'
;=====================

if ($1 == !lfms) {
set %methodd similar
if (!$2) { msg # You must provide an artist. | halt }
set %method /2.0/?method=artist.getsimilar&artist= $+ $replace($2-,$chr(32),$chr(43)) $+ &autocorrect=1&limit=10&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
sockopen lfm ws.audioscrobbler.com 80
sockmark lfm msg # 4Last.fm 4»
}

;==========================
; Set method 'New Releases'
;==========================

if ($1 == !lfmnr) {
if (($2) && (!$3)) {
if ($2 isnum) {
if ($2 > 10) { msg # Sorry, but that'll be too many releases, please choose a number between 1 and 10 | halt }
if ($2 isnum 1-10) {
if (!$hget(lastinfo,$nick)) { msg $chan You're not regged with the bot, please add one using !lfma <Last.FM Nick> | halt }
set %lfmnrout $2
set %username $hget(lastinfo,$nick)
}
}
else {
set %lfmnrout 5
set %username $iif($hget(lastinfo,$2),$hget(lastinfo,$2),$2)
}
}
if (!$2) {
if (!$hget(lastinfo,$nick)) { msg $chan You're not regged with the bot, please add one using !lfma <Last.FM Nick> | halt }
else {
set %lfmnrout 5
set %username $hget(lastinfo,$nick)
}
}
if ($3) {
set %username $iif($hget(lastinfo,$2),$hget(lastinfo,$2),$2)
if ($3 > 10) { msg # Sorry, but that'll be too many releases, please choose a number between 1 and 10 | halt }
if ($3 isnum 1-10) { set %lfmnrout $3 }
}
set %methodd lfmnr
set %lfmnametemp 0
set %lfmnrtemp 0
set %method $+(/2.0/?method=user.getnewreleases&user=,%username,&api_key=bdf34b247ee7ee2ccd8e856a675bb82d)
sockopen lfm ws.audioscrobbler.com 80
sockmark lfm msg # 4Last.fm 4»
}

;===============================
; Set method 'Chart Top Artists'
;===============================

if ($1 == !lfmta) {
set %methodd lfmta
set %method http://ws.audioscrobbler.com/2.0/?method=chart.gettopartists&limit=10&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
sockopen lfm ws.audioscrobbler.com 80
sockmark lfm msg # 4Last.fm 4»
}

;==============================
; Set method 'User Top Artists'
;==============================

if ($1 == !lfmuta) {
set %methodd lfmuta
if (!$2) { msg # You must provide a period of time. Acceptable inputs are: Overall, 7day, 3month, 6month and 12month. | halt }
if (($2) && (!$3)) {
if ($2 == overall) || ($2 == 7day) || ($2 == 3month) || ($2 == 6month) || ($2 == 12month) {
set %period $2
if (!$hget(lastinfo,$nick)) { msg # You're not regged with the bot, please add one using !lfma <Last.FM Nick> | halt }
set %username $hget(lastinfo,$nick)
set %method http://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user= $+ %username $+ &period= $+ %period $+ &limit=10&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
}
else { msg # 4Last.fm 4» Acceptable inputs are: Overall, 7day, 3month, 6month and 12month. | halt }
}
if (($2) && ($3)) {
if ($2 == overall) || ($2 == 7day) || ($2 == 3month) || ($2 == 6month) || ($2 == 12month) {
set %period $2
set %username $iif($hget(lastinfo,$3),$hget(lastinfo,$3),$3)
set %method http://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user= $+ %username $+ &period= $+ %period $+ &limit=10&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
}
else { msg # 4Last.fm 4» Acceptable inputs are: Overall, 7day, 3month, 6month and 12month. | halt }
}
if ($sock(lfm)) { sockclose lfm }
sockopen lfm ws.audioscrobbler.com 80
sockmark lfm msg # 4Last.fm 4»
}

;============================
; Set method 'User Neighbors'
;============================

if ($1 == !lfmn) {
set %methodd lfmn
if (!$2) {
if (!$hget(lastinfo,$nick)) { msg # You're not regged with the bot, please add one using !lfma <Last.FM Nick> | halt }
set %username $hget(lastinfo,$nick)
set %method http://ws.audioscrobbler.com/2.0/?method=user.getneighbours&user= $+ %username $+ &limit=10&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
}
if ($2) {
set %username $iif($hget(lastinfo,$2),$hget(lastinfo,$2),$2)
set %method http://ws.audioscrobbler.com/2.0/?method=user.getneighbours&user= $+ %username $+ &limit=10&api_key=bdf34b247ee7ee2ccd8e856a675bb82d
}
if ($sock(lfm)) { sockclose lfm }
sockopen lfm ws.audioscrobbler.com 80
sockmark lfm msg # 4Last.fm 4»
}
}

; ==================
; Connect the Socket
; ==================

on *:sockopen:lfm: {
sockwrite -n $sockname GET %method HTTP/1.1
sockwrite -n $sockname Host: ws.audioscrobbler.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}

; ===============
; Read the Socket
; ===============

on *:sockread:lfm: {

if ($sockerr) { $sock(lfm).mark Socket Error: $sock(lfm).wsmsg }
var %lfmtemp
sockread %lfmtemp

; =============
; Set 'NP' vars
; =============

if (%methodd == np) {
if ((<name> isin %lfmtemp) && (%lfmnametemp == 0)) {
set %lfmname $replace($nohtml(%lfmtemp),&amp;,&,&quot;,")
set %lfmnametemp 1
}
if ((<artist isin %lfmtemp) && (%lfmartisttemp == 0)) {
set %lfmartist $replace($nohtml(%lfmtemp),&amp;,&,&quot;,")
set %lfmartisttemp 1
}
if ((<album isin %lfmtemp) && (%lfmalbumtemp == 0)) {
set %lfmalbum $replace($nohtml(%lfmtemp),&amp;,&,&quot;,")
set %lfmalbumtemp 1
}
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}

; ==============
; Set 'NP2' vars
; ==============

if (%methodd == np2) {
if (<duration> isin %lfmtemp) { set %lfm.length $nohtml(%lfmtemp) }
if (<userloved> isin %lfmtemp) {
if (<userplaycount> isin %lfmtemp) {
set %lfm.playcount $gettok($nohtml(%lfmtemp),1,32)
set %lfm.loved $gettok($nohtml(%lfmtemp),2,32)
}
else { set %lfm.loved $gettok($nohtml(%lfmtemp),1,32) }
}
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}


; ===============
; Set 'Info' vars
; ===============

if (%methodd == info) {
if (<realname> isin %lfmtemp) { set %lfm.realname $remove(%lfmtemp,<realname>,</realname>) }
if (<country> isin %lfmtemp) { set %lfm.country $remove($gettok(%lfmtemp,1,32),<country>,</country>) }
if (<name> isin %lfmtemp) { set %lfm.name $remove($gettok(%lfmtemp,1,32),<name>,</name>) }
if (<age> isin %lfmtemp) { set %lfm.age $remove($gettok(%lfmtemp,1,32),<age>,</age>) }
if (<id> isin %lfmtemp) { set %lfm.id $remove($gettok(%lfmtemp,1,32),<id>,</id>) }
if (size="large" isin %lfmtemp) { set %lfm.image $remove($gettok(%lfmtemp,2,32),size="large">,</image>) }
if (<gender> isin %lfmtemp) { set %lfm.gender $remove($gettok(%lfmtemp,1,32),<gender>,</gender>) }
if (<playcount> isin %lfmtemp) { set %lfm.plays $remove($gettok(%lfmtemp,1,32),<playcount>,</playcount>) }
if (<subscriber> isin %lfmtemp) { set %lfm.subscriber $remove(%lfmtemp,<subscriber>,</subscriber>) }
if (<type> isin %lfmtemp) { set %lfm.type $remove(%lfmtemp,<type>,</type>) }
set %lfm.url http://last.fm/user/ $+ %username
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}

; ==================
; Set 'Compare' vars
; ==================

if (%methodd == compare) {
if (<score> isin %lfmtemp) { set %lfm.score $round($calc($nohtml(%lfmtemp)*100),1) }
if (<name> isin %lfmtemp) { set %lfm.artists $+(%lfm.artists,$chr(32),$replace($nohtml(%lfmtemp),&amp;,&,&quot;,"),$chr(44)) }
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}

; ==================
; Set 'Similar' vars
; ==================

if (%methodd == similar) {
if (<name> isin %lfmtemp) {
set %lfm.similar $+(%lfm.similar,$chr(32),$nohtml(%lfmtemp),$chr(44))
}
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}

; =======================
; Set 'New Releases' vars
; =======================

if (%methodd == lfmnr) {
if ((<name> isin %lfmtemp) && (%lfmnametemp == 0) && (%lfmnrtemp < %lfmnrout)) { set %lfmrecsout %lfmrecsout $replace($nohtml(%lfmtemp),&amp;,&,&quot;,") - }
if ((<name> isin %lfmtemp) && (%lfmnametemp == 1) && (%lfmnrtemp < %lfmnrout)) {
set %lfmrecsout %lfmrecsout $replace($nohtml(%lfmtemp),&amp;,&,&quot;,") $+ ,
set %lfmnametemp 0
inc %lfmnrtemp
}
if (<artist> isin %lfmtemp) { set %lfmnametemp 1 }
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}

; ============================
; Set 'Chart Top Artists' vars
; ============================

if (%methodd == lfmta) {
if (<name> isin %lfmtemp) {
set %lfm.topartists $+(%lfm.topartists,$chr(32),$nohtml(%lfmtemp),$chr(44))
}
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}

; ===========================
; Set 'User Top Artists' vars
; ===========================

if (%methodd == lfmuta) {
if (<name> isin %lfmtemp) {
set %lfm.usertop $+(%lfm.usertop,$chr(32),$nohtml(%lfmtemp),$chr(44))
}
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}

; ========================
; Set 'User Neighbor' vars
; ========================

if (%methodd == lfmn) {
if (<name> isin %lfmtemp) {
set %lfm.neighbors $+(%lfm.neighbors,$chr(32),$nohtml(%lfmtemp),$chr(44))
}
if (<error isin %lfmtemp) { var %err $remove(%lfmtemp,<error code=",</lfm>,</error>,">) | $sock(lfm).mark $remove(%err,$left(%err,1)) | unset %lfm.* | sockclose lfm }
}
}

; ===============================
; Close socket and message output
; ===============================

on *:sockclose:lfm: {
if (%methodd == np2) {
msg %lfm.chan 4Last.fm » %lfmartist - %lfmname $chr(91) $+ %lfmalbum $+ $chr(93) $iif(%lfm.playcount,$+($chr(40),Played %lfm.playcount times,$chr(41))) $iif(%lfm.loved,4&#9829;) $iif(%lfm.length,$+([,$gettok($duration($calc(%lfm.length / 1000),3),2-,58),]))
unset %lfm* | unset %lfmcu* | unset %method | unset %methodd
}
if (%methodd == np) {
set %methodd np2
set %method $+(/2.0/?method=track.getinfo&api_key=bdf34b247ee7ee2ccd8e856a675bb82d&artist=,$urlencode(%lfmartist),&track=,$urlencode(%lfmname),&username=,%username)
if ($sock(lfm)) { sockclose lfm }
sockopen lfm ws.audioscrobbler.com 80
}
if (%methodd == info) {
$sock(lfm).mark User: %username 4» ID: $iif(%lfm.id == $null,Not Specified,%lfm.id) 4» Subscriber? $replace(%lfm.subscriber,0,No,1,Yes) 4» Type: %lfm.type $+ 
$sock(lfm).mark Real Name: $iif(%lfm.realname == $null,Not Specified,%lfm.realname) 4» Name: $iif(%lfm.name == $null,Not Specified,%lfm.name) 4» Age: $iif(%lfm.age == $null,Not Specified,%lfm.age) 4» Gender: $iif(%lfm.gender == $null,Not Specified,$replace(%lfm.gender,m,Male,f,Female,n,Unknown)) 4» Country: $iif(%lfm.country == $null,Not Specified,%lfm.country)
$sock(lfm).mark Plays: %lfm.plays 4» Image: $iif(%lfm.image == $null,Not Specified,%lfm.image) 4» %lfm.url
unset %lfm* | unset %lfmcu* | unset %method | unset %methodd | unset %username
}
if (%methodd == compare) {
$sock(lfm).mark %lfmcu1 $+ 's compatibility with %lfmcu2 is $iif(%lfm.score == 0,Unknown.,$compat(%lfm.score) $+($chr(40),%lfm.score,$chr(37),$chr(41),$chr(46)) Artist(s) they have in common include(s) $gettok(%lfm.artists,1- $+ $calc($gettok(%lfm.artists,0,44) - 2),44) $+ .)
unset %lfm* | unset %lfmcu* | unset %method | unset %methodd | unset %username
}
if (%methodd == similar) {
$sock(lfm).mark Similar Artists: $replace($gettok(%lfm.similar,1-10,44) $+ .,&amp;,&)
unset %lfm* | unset %lfmcu* | unset %method | unset %methodd | unset %username
}
if (%methodd == lfmnr) {
$sock(lfm).mark New Album Releases for %username are: $gettok(%lfmrecsout,1- %%lfmnrout,44) $+ .
unset %lfm* | unset %method | unset %methodd | unset %username
}
if (%methodd == lfmta) {
$sock(lfm).mark Top of the Last.fm Charts: $gettok(%lfm.topartists,1-10,44) $+ .
unset %lfm* | unset %method | unset %methodd | unset %username
}
if (%methodd == lfmuta) {
$sock(lfm).mark Top 10 Artists for %username 4» Period: $replace(%period,overall,Overall:,7day,Last 7 Days:,3month,Last 3 Months:,6month,Last 6 Months:,12month,Last 12 months:) $gettok($replace(%lfm.usertop,&amp;,&),1-10,44) $+ .
unset %lfm* | unset %method | unset %methodd | unset %username | unset %period
}
if (%methodd == lfmn) {
$sock(lfm).mark Top 10 Neighbors: $gettok(%lfm.neighbors,1-10,44) $+ . http://www.last.fm/user/ $+ %username $+ /neighbours
unset %lfm* | unset %method | unset %methodd | unset %username
}
}

alias nohtml {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
return %x
}

alias urlencode {
var %a = $regsubex($$1,/([^\w\s])/Sg,$+(%,$base($asc(\t),10,16,2)))
return $replace(%a,$chr(32),$chr(43))
}

alias -l compat {
if ($1 isnum 00.0-16.6) { return Very Low }
if ($1 isnum 16.6-33.3) { return Low }
if ($1 isnum 33.3-50.0) { return Medium }
if ($1 isnum 50.0-66.6) { return High }
if ($1 isnum 66.6-83.4) { return Very High }
if ($1 isnum 83.4-100) { return Super }
}

On *:EXIT: {
hsave lastinfo lastinfo.hsh
hfree lastinfo
}

Comments

Sign in to comment.
hxck   -  10 days ago
Updated to add album to output like Artist - Title [Album] cause I was bored.
 Respond  
illhawkthat   -  Feb 23, 2013
@hxck
The API key (public) that was listed here has been deprecated.
You have to sign up for an API key from last.fm to get this script to work again. Just letting you know so you can edit the script a little and maybe put a note in the description.
hxck  -  Mar 06, 2013
Thanks man, I was having some PC trouble so I was offline for a while but I just edited the snippet with my own API key. Appreciate the heads up.
Sign in to comment

hxck   -  Sep 14, 2012
You would need to add an on:INPUT event.
 Respond  
liriel   -  Sep 14, 2012
How can I set this up so I can trigger it myself? Thanks for any help :)
 Respond  
hxck   -  Jul 12, 2012
Good lookin out @Jethro, I threw those edits up.
 Respond  
Jethro   -  Jul 10, 2012
DisposableHero, that's because the hash file hasn't been made yet so there's nothing to load. A check needs to be added to keep the error at bay:

Quote

On *:START: {
if (!$hget(lastinfo)) { hmake lastinfo 20 }
if ($isfile(lastinfo.hsh)) { hload -s lastinfo lastinfo.hsh }
}
same for the load event.
 Respond  
DisposableHero   -  Jul 10, 2012
/hload: unable to open file 'C:\Users\Nick\AppData\Roaming\mIRC\lastinfo.hsh' (line 3, script5.ini)

i get 2 of thsee when i first start the script???
 Respond  
chachin   -  Jul 08, 2012
thanks Jethro this worked like a charm.. there was only 1 "hadd lastinfo $nick $2" :D
 Respond  
Jethro   -  Jul 08, 2012
chachin, locate all of these bits of code:

Quote

hadd lastinfo $nick $2
and add a -m switch to every one of them like so:

Quote

hadd -m lastinfo $nick $2
Many times people utilize hash tables and have 'em created upon on load, start or connect...and many times users just copy and paste the entire snippet directly into their remote without going through those events first. It's a good idea to add the -m switch to be on the safe side.
 Respond  
chachin   -  Jul 08, 2012
* /hadd: no such table 'lastinfo' (line 54, lastFM.mrc)
-
My last.fm nick is FightingNavyman but on IRC I use chachin. and when i do !lfma nothing happends.. only that ^ with the bot..
 Respond  
hxck   -  Nov 24, 2011
Thanks, appreciated.

Added a Neighbors command to get the top 10 Neighbors, finished some error checking, bumped the hard limits to 10 from 5 and removed colors because I hate working them. I'll readd them in the final revision.
 Respond  
Jethro   -  Nov 24, 2011
Nice effort for keeping up at it. I've bumped up your score for your dedication, along with a like.
 Respond  
hxck   -  Nov 23, 2011
Added more information to the !lfmu command and added some error checking for User Top Artists.
 Respond  
hxck   -  Nov 23, 2011
Added 2 new commands to get the top 5 artists on the Last.fm charts and the top 5 artists on User charts according to period (overall, 7day, 3month, 6month, 12month.)
Added color codes as a lot of people seem to like them.
Overhauled the help section.
 Respond  
ES   -  Nov 22, 2011
Just to clarify:

There are 4 possible triggers for the !lfmnr function.:

1. !lfmnr - This will show 5 (Default) recommended new albums based on the person who triggered it
2. !lfmnr <1-10> - This will show 1-10 (depending on what you chose) recommended new albums based on the person who triggered it
3. !lfmnr [username] - This will show 5 (default) recommended new albums based on username
4, !lfmnr [username] <1-10> - This will show 1-10 (depending on what you chose) recommended new albums based on username
 Respond  
hxck   -  Nov 22, 2011
Updated with a new command for getting New Releases. The New Releases command grabs up to 10 new releases of bands you've listened to based on your history.
 Respond  
hxck   -  Nov 21, 2011
Updated with a new command for getting Similar Artists. Still needs a tad bit of cleaning up and error checking, will be done soon.
 Respond  
ES   -  Nov 20, 2011
NB. the !lfmc can work in 1 of 2 ways:

1: !lfmc user1 - this will compare user1 with the person who triggered it
2. !lfmc user1 user2 - this will compare user1 with user2
 Respond  
hxck   -  Nov 20, 2011
Big update: Added a few more commands I wrote myself, and the !lfmc tasteometer command thanks to ES.
 Respond  
Jethro   -  Oct 15, 2011
There is a public API key available at your disposal, posted by a former staff member named jr:

Quote

b25b959554ed76058ac220b7b2e0a026
There's no need to register for one.

I made a socket script a while ago using their API to display the info about Last.fm NOW PLAYING. It's a part of my snippet collection.

P.S. your socket script can only be triggered one at a time. If one person tries to trigger it while the socket is getting the request for another person, it won't respond. You may need to make your socket dynamic.
 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.