Advertisement
wollux

last.fm

Feb 2nd, 2015
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.43 KB | None | 0 0
  1. ;use /last to see the song the selected user is listening to
  2. ;use /lset to set the last.fm username
  3. ;by flyinv1490
  4. ; #: Modified by n0cht
  5. alias lset { set %luser $1 | echo -a $1 set as user }
  6. alias lfm {
  7.   if %luser == $null { echo -a please set a username first. /lset <username> | halt }
  8.   else {
  9.     if ($1) { set %lf.chan $1 }
  10.     else { set %lf.chan $active }
  11.   }
  12.   sockopen lastfm ws.audioscrobbler.com 80
  13. }
  14. on *:sockopen:lastfm: {
  15.   if $sockerr > 0 { echo -a Error With Server. | sockclose lastfm }
  16.   sockwrite -n $sockname GET /2.0/?method=user.getrecenttracks&user= $+ %luser $+ &api_key=ffa17ba0cdaf2817067b300a08c72196 HTTP/1.1
  17.   sockwrite -n $sockname Host: ws.audioscrobbler.com
  18.   sockwrite -n $sockname $crlf
  19. }
  20. on *:sockread:lastfm: {
  21.   if $sockerr > 0 { echo -a Error With Server. | sockclose lastfm }
  22.   sockread %lf.temp
  23.   if (<error code="6">Invalid user name supplied</error> isin %lf.temp) { msg %lf.chan Error Username Does Not Exist | halt }
  24.   if (</lfm> isin %lf.temp) { msg %lf.chan %luser is currently not listening to any music | sockclose lastfm | unset %lf.* }
  25.   if (<artist isin %lf.temp) { set %lf.artist $nohtml(%lf.temp) }
  26.   if (<name> isin %lf.temp) { set %lf.song $nohtml(%lf.temp) | me 12,15#07,15 %lf.artist - %lf.song  | sockclose lastfm | unset %lf.* }
  27. }
  28. alias nohtml { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | var %x = $replace(%x, ,$chr(32),°,$chr(176),°,$chr(176)) | return %x }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement