Gamers.IRC board

Support board for Gamers.IRC

[ Gamers.IRC WebsiteBoard indexeMail support ]
             
It is currently 08.09.2010 03:13




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Lyrics Search for Winamp
New postPosted: 05.04.2009 21:44 
Offline
Administrator
User avatar

Joined: 24.10.2003
Posts: 1542
Highscores: 22
Status: Gamers.IRC Coder
This Gamers.IRC add-on tries to find and display your currently played song's lyrics.

You'll need Winamp for it, of course. :grin:

Code:
dialog tblLyricsearch {
  title "Lyrics Search"
  size -1 -1 226 176
  option dbu
  edit "", 1, 1 13 182 163, multi read vsbar
  button "close", 2, 185 13 39 12, default flat ok cancel
  button "refresh", 3, 185 26 39 12, flat
  text "playing:", 4, 2 2 20 8
  edit "", 5, 23 1 202 10, read
}

on *:dialog:tblLyricsearch:init:*:{
  updateLyrics
}

on *:dialog:tblLyricsearch:sclick:*:{
  if ($did == 3) {
    updateLyrics
  }
}

alias lyricsearch { dialog $iif($dialog(tblLyricsearch), -x, -md) tblLyricsearch tblLyricsearch }
menu channel,status,query,menubar {
  Lyric Search:lyricsearch
}

alias unicodetomsl {
  var %i = 1, %html = $remove($1-,&#), %b
  var %n = $numtok(%html,59)
  while (%i <= %n) {
    if ($gettok(%html,%i,59) == 32) {
      %b = $+(%b,$chr($gettok(%html,%i,59)),$chr($gettok(%html,$calc(%i + 1),59)))
      inc %i 2
    }
    else {
      %b = $+(%b,$chr($gettok(%html,%i,59)))
      inc %i
    }
  }
  return %b
}

alias -l updateLyrics {
  if ($dll(gIRC.dll) && ($winampstats(running) == $true) && $dialog(tblLyricsearch)) {
    if ($winampstats(running) != $true) {
      did -ra tblLyricsearch 5 Winamp isn't running!
    }
    else {
      did -ra tblLyricsearch 5 Winamp running; looking for lyrics...
     
      if ($sock(scLyricsearch)) { sockclose scLyricsearch }
      sockopen scLyricsearch lyrics.wikia.com 80
    }
  }
}

on *:sockopen:scLyricsearch:{
  if ($sockerr) { did -ra tblLyricsearch 5 Socket creation error! | halt }
  sockwrite -n $sockname GET / $+ $replace($winampinfo(artist),$chr(32),_) $+ : $+ $replace($winampinfo(title),$chr(32),_) HTTP/1.1
  sockwrite -n $sockname Host: lyrics.wikia.com
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.2) Gecko/2008082714 Firefox/3.0.2
  sockwrite -n $sockname $crlf
}

on *:sockread:scLyricsearch:{
  sockread %x
  if ('lyricbox' isin %x && rtMatcher !isin %x) {
    %x = $replace($replace(%x,<br />,$chr(128)),<br/>,$chr(128))
    did -ra tblLyricsuche 6 $winampinfo(artist) - $winampinfo(title)
    var %lyRegex = $regex(%x,/<div class=\'lyricbox\'>(.*)<!--/)
    %x = $regml(1)
    did -r tblLyricsuche 1
    var %i = 1
    while (%i <= $numtok(%x,128)) {
      did -a tblLyricsuche 1 $unicodetomsl($gettok(%x,%i,128))
      if (%i != $numtok(%x,128)) { did -a tblLyricsuche 1 $crlf }
      inc %i
    }
    did -f tblLyricsuche 1
    sockclose $sockname
  }
  elseif (</html> isin %x) {
    did -ra tblLyricsearch 5 Couldn't find lyrics! :/
    sockclose $sockname
  }
}

on *:unload:{
  if ($sock(scLyricsearch)) { sockclose scLyricsearch }
}


To run this script, use the new context menu entry Lyric Search.

_________________
^\__/
..O.o

This is Einkaufswagen. Copy Einkaufswagen into your signature to help him on his way to world domination.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group