maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Multimedia (https://talk.maemo.org/forumdisplay.php?f=32)
-   -   [Canola] How to: Show "now playing" info from Canola in IRC (mIRC script) (https://talk.maemo.org/showthread.php?t=20666)

Cptnodegard 2008-06-03 19:19

[Canola] How to: Show "now playing" info from Canola in IRC (mIRC script)
 
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

handful 2008-06-03 19:35

Re: How to: Show "now playing" info from Canola in IRC (mIRC script)
 
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

Cptnodegard 2008-06-03 19:36

Re: How to: Show "now playing" info from Canola in IRC (mIRC script)
 
Sure its possible, just not for me since i dont know anythign at all about coding :/


All times are GMT. The time now is 14:54.

vBulletin® Version 3.8.8