Last.FM - Latest Songs

By PowerScripters on Jan 09, 2010

#############################################

Okay, another [bad coded] Socket-Script.
Well, for all of you:

The PowerScripters is a Clan, where everybody can post Scripts, and I.. hm
I am the only who make the Socket-Scripts, i don't know what the others do, but hey
don't be soooo hard with us. - we are just kids.

Our Scripts aren't well coded, but they work and that makes us Happy.

Thanks.
So take a look at this:

Image

So you can use !lastfm [weekly]

Added WEEKLY-Support. - Shows the Weekly-Top Artists.

alias lastfm-connection { 
sockopen lastfm audioscrobbler.com 80 }
on *:SOCKOPEN:lastfm:{

  ; connection
  sockwrite -n $sockname GET %lastfm-c HTTP/1.1

  ; Write Connection Details
  sockwrite -n $sockname Host: ws.audioscrobbler.com
  sockwrite -n $sockname User-Agent: IRCSpider/mIRC $version
  sockwrite -n $sockname $crlf 

}
on *:SOCKREAD:lastfm:{
var %mirc.temp local^^
  sockread %mirc.temp
  if (%lastfm-source == /recenttracks.rss) {
    if ((%lastfm-x != $iif(%lastfm-maxposts == $null,6,$calc(%lastfm-maxposts + 1))) && (<docs> !isin %mirc.temp)) {
      if (%lastfm-x == $iif(%lastfm-maxposts == $null,5,%lastfm-maxposts)) { msg %lastfm-chan RSS-Feeds for %lastfm-user $+ : http://ws.audioscrobbler.com/1.0/user/ $+ %lastfm-user $+ /recenttracks.rss | inc %lastfm-x }
      if (<title> isin %mirc.temp) {
        msg %lastfm-chan $remove(%mirc.temp,<title>,</title>)
        inc %lastfm-x
      }
    }
  }
  else { 
    if ((%lastfm-x != $iif(%lastfm-maxposts == $null,6,$calc(%lastfm-maxposts + 1))) && (<docs> !isin %mirc.temp)) {
      if (<name> isin %mirc.temp) {
        set %lastfm-name $remove(%mirc.temp,<name>,</name>)
      }
      elseif (<playcount> isin %mirc.temp) {
        set %lastfm-count $remove(%mirc.temp,<playcount>,</playcount>)
      }
      elseif (</artist> isin %mirc.temp) {
        msg %lastfm-chan %lastfm-name (Played: %lastfm-count $+ times)
        unset %lastfm-name
        unset %lastfm-count
        inc %lastfm-x
      }
    }
  }
}

on *:SOCKCLOSE:lastfm:{ unset %lastfm-* }
on *:TEXT:!lastfm*:#:{
  if (!$2) { msg $chan 00,04LastFM: !lastfm <username> <posts> | halt }
  %lastfm-source = $iif($4 == weekly,/weeklyartistchart.xml,/recenttracks.rss)
  sockclose lastfm
  set %lastfm-maxposts $3
  set %lastfm-user $2
  msg $chan 00,04LastFM: $iif(%lastfm-source == /weeklyartistchart.xml,Weekly-Top ,Latest)  $iif(%lastfm-maxposts == $null,5,%lastfm-maxposts)  Songs by $2
  set %lastfm-chan $chan
  var %i 1
  set %lastfm-c /1.0/user/ $+ $2 $+ %lastfm-source
  lastfm-connection 
}

Comments

Sign in to comment.
PowerScripters   -  Jan 09, 2010

fixed.

 Respond  
FordLawnmower   -  Jan 09, 2010

If you aren't going to declare %mirc.temp as a local variable, then you should change it to %lastfm-temp so it gets unset and it doesn't conflict with the other scripts you posted with the same global variable.

 Respond  
Shanker09   -  Jan 09, 2010

It's alright but, In all you don't need a "|" in it because it' takes longer for mIRC to process

So...

alias lastfm-connection { 
sockopen lastfm audioscrobbler.com 80 }
on *:SOCKOPEN:lastfm:{

  ; connection
  sockwrite -n $sockname GET %lastfm-c HTTP/1.1

  ; Write Connection Details
  sockwrite -n $sockname Host: ws.audioscrobbler.com
  sockwrite -n $sockname $crlf 

}
on *:SOCKREAD:lastfm:{
  sockread %mirc.temp
  if ((%lastfm-x != $iif(%lastfm-maxposts == $null,6,$calc(%lastfm-maxposts + 1))) && (<docs> !isin %mirc.temp)) {
    if (%lastfm-x == $iif(%lastfm-maxposts == $null,5,%lastfm-maxposts)) { msg %lastfm-chan RSS-Feeds for %lastfm-user $+ : http://ws.audioscrobbler.com/1.0/user/ $+ %lastfm-user $+ /recenttracks.rss 
 inc %lastfm-x
 }
    if (<title> isin %mirc.temp) {
      msg %lastfm-chan $remove(%mirc.temp,<title>,</title>)
      inc %lastfm-x
    }
  }
}

on *:SOCKCLOSE:lastfm:{ unset %lastfm-* }
on *:TEXT:!lastfm*:#:{
  if (!$2) { msg $chan 00,04LastFM: !lastfm <username> <posts> 
 halt
 }
  sockclose lastfm
  set %lastfm-maxposts $3
  set %lastfm-user $2
  msg $chan 00,04LastFM: Latest  $iif(%lastfm-maxposts == $null,5,%lastfm-maxposts)  Songs by $2
  set %lastfm-chan $chan
  var %i 1
  set %lastfm-c /1.0/user/ $+ $2 $+ /recenttracks.rss
  lastfm-connection 
}

& Also Works with no errors so Nice :)

•»04:57:38:am«• <&DDoS> !lastfm
•»04:57:38:am«• <~shanker> LastFM: !lastfm <username> <posts>
•»04:57:43:am«• <&DDoS> !lastfm lol @You
•»04:57:43:am«• <~shanker> LastFM: Latest  @You  Songs by lol
•»04:57:44:am«• <~shanker> John Williams – The Droids Are Captured
•»04:57:44:am«• <~shanker> D12 – My Band
•»04:57:44:am«• <~shanker> Akira Yamaoka – Theme of Laura (acoustic)
•»04:57:44:am«• <~shanker> Akira Yamaoka – locked
•»04:57:44:am«• <~shanker> Marilyn Manson – The Death Song
•»04:57:44:am«• <~shanker> John Williams – Luke's Nocturnal Visitor
•»04:57:44:am«• <~shanker> Akira Yamaoka – White Noiz
•»04:57:44:am«• <~shanker> Vangelis – Come to Me
•»04:57:44:am«• <~shanker> John Williams – Brother and Sister, Father and Son, The Fleet Enters Hyperspace, Heroic Ewok
•»04:57:44:am«• <~shanker> Eminem – Lose Yourself
 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.