Active Topics

 



Notices


Reply
Thread Tools
Cptnodegard's Avatar
Posts: 170 | Thanked: 40 times | Joined on Dec 2007 @ Norway
#1
This is far from perfect and has its flaws, but it works.
What the mirc script basically does is take the llast played song on last.fm and echos it to IRC. That means half the song has to have played for it to work :/ Even so, it's nice IMO.

Code:
alias lastfm {
  if ($1 == -s) { echo -ag Username set to $2 | hadd -m lastfm user $2 | return }
  if (!$hget(lastfm,user)) { echo -ag No Username set. Try /lastfm -s <Username> | return }
  if ($1 == -t) { set -u5 %lastfm.url /toptracks.txt  }
  else { set -u5 %lastfm.url /recenttracks.txt }
  sockopen $+(lastfm.,$r(0,42)) ws.audioscrobbler.com 80
}
on *:sockopen:lastfm.*:{
  if ($sockerr) || (!$sock($sockname)) return
  sockwrite -n $sockname GET /1.0/user/ $+ $hget(lastfm,user) $+ %lastfm.url HTTP/1.1
  sockwrite -n $sockname Host: ws.audioscrobbler.com
  sockwrite -n $sockname $crlf
}
on *:sockread:lastfm.*:{
  var %lastfm.read | sockread %lastfm.read | tokenize 32 %lastfm.read
  if (!$1) return
  ; For debugging purposes:
  ;echo -s $1-
  if ($chr(44) isin $1-) && (%lastfm.go) {
    var %time = $gettok($1-,1,44)
    var %track = $gettok($1-,2,44)
    .signal -n lastfm %time %track
  }
  if (*ont*yp* iswm $1-) {
    set -u3 %lastfm.go 1
    ;### You might want to edit here ###
    echo -sg Listing %lastfm.url
  }
}
on *:signal:lastfm:{
  ;sick utf8 ****:
  var %track = $replace($2-,–,-)

  ;### ...and especially here ###
  if (%lastfm.url == /recenttracks.txt) { var %time = $asctime($1) | /msg #CHANNEL NAME HERE Nokia N800 Canola2 Now Playing: 1 %track | sockclose lastfm.* }
  else { echo -s %time > %track }

}

The code is slightly modified version of http://www.mircscripts.org/comments.php?cid=3687 by ChosenOne, modified with the help of Sephiroth at Quakenet.
Usage: Paste it in mirc scripts editor, and edit CHANNEL NAME HERE to the channel name you want to output (it doesnt automatically spit out wheere you use it, $chan doesnt work). First time you do /lastfm you'll be asked for account name. Password not necessary. Follow the instructions to set user name and next time you do /lastfm you'll spit out " Nokia N800 Canola2 Now Playing: artist - title". Of ocurse this works with other thigns scrobbling to last.fm but i did it for the purpose of canola.

Enjoy

Last edited by Cptnodegard; 2008-06-04 at 08:50.
 
handful's Avatar
Posts: 1,412 | Thanked: 594 times | Joined on Aug 2005 @ Recife, Brazil
#2
Hi this is nice if you want to dig, I think you would be able to do something in Canola because Last.fm code is open, so you can actually see how it get's the playing music and do the same for you and then just send to your script maybe via a interface for mirc?

Marcelo
__________________
Marcelo Eduardo
www.marceloeduardo.com
----------------------------
OpenBossa Labs @ INdT, Recife Brazil
http://openbossa.indt.org
 
Cptnodegard's Avatar
Posts: 170 | Thanked: 40 times | Joined on Dec 2007 @ Norway
#3
Sure its possible, just not for me since i dont know anythign at all about coding :/
 
Reply


 
Forum Jump


All times are GMT. The time now is 20:19.