Searches and grabs the first search result for lyrics at www.lyrics.com
19:35 <@root-> @lyrics SOS
19:36 <@BluePrint> (Lyrics) First result for: (SOS) (Rihanna - SOS) (http://www.lyrics.com/sos-lyrics-rihanna.html)
on $*:TEXT:/^[!@.]lyrics/Si:#: {
if (!$($+(%,flood,$nick),2)) && (!$sock(lyrics)) {
set -u3 $+(%,flood,$nick) on
sockopen lyrics www.lyrics.com 80
sockmark lyrics $+($fix($$2-),>,$iif($left($1,1) == @,msg #,.notice $nick))
}
}
on *:sockopen:lyrics: {
sockwrite -nt $sockname GET $+(/search.php?keyword=,$token($sm(lyrics),1,62),&what=all&submit.x=0&submit.y=0&submit=1) HTTP/1.1
sockwrite -nt $sockname Host: $+(www.lyrics.com,$str($crlf,2))
}
on *:SOCKREAD:lyrics: {
if ($sockerr) { $token($sm(lyrics),2,62) $logo(Error) $sock(lyrics).wsmsg }
var %ly
sockread %ly
if ($regex(%ly,/href="(.*)">(.*)<\/a><\/td>/)) {
set -u3 %link $regml(1)
set -u3 %title $regml(2)
sockread %ly
}
if ($regex(%ly,/href="http:\/\/www\.lyrics\.com\/(.*)\.html">(.*)<\/a><\/td>/)) {
$token($sm(lyrics),2,62) $logo(Lyrics) $+($chr(3),14,First result for:,$chr(3)) $logo($unfix($token($sm(lyrics),1,62))) $logo($regml(2) - %title) $logo(%link)
sockclose lyrics
}
}
alias unfix { return $replace($$1-,+,$chr(32),$+(%,26),&) }
alias fix { return $replace($$1-,$chr(32),+,&,$+(%,26)) }
alias sm { return $sock($$1).mark }
alias logo { if ($isid) { return 12(14 $+ $$1- $+ 12) } }
Nice script, added to my bots collection.
One thing tho ide like to ask about regx, and this post/script might be a good example. How do I change the color of regx scripts? the old way was easy all i had to do was look out for the text or stings like this:
12[14 Lyrics 12] 14 $+ $qt(12 $+ $3 $+ 14) - 14Songname:12 %song - 14Artist:12 %artist - 14URL:12 %link
but now with more scripts using regx im finding it hard to customise the colors, ive no idea what im ment to be looking for.
TheNitelyfe original code is the only one here i can get to work, but his is the the only one i cant customise the colors on.
@WorldDMT as i said in my comment "it's just one of many ways to do this script" his is one way mine is another as well is ur's. So no need to say no need for regex, cuz one can say say no need for $wildtok as well no need for setting global vars. It's just ur opinion nothing more.
@drcheese load it into the remotes of ur bot or you can load it in ur remotes for others to trigger.
hi
no need for regex
on $*:TEXT:/^([!@.])lyrics\s(.+)/Si:#:{
if (!$($+(%,lyricsflood,$nick),2)) {
set -u3 $+(%,lyricsflood,$nick) 1
if !$sock(lyrics) {
sockopen lyrics www.lyrics.com 80
sockmark lyrics $+(www.lyrics.com,`,$replace($2-,$chr(32),+),`,$2-,`,$iif($regml(1) == @,msg #,.notice $nick))
}
else msg # plz wait $nick ...
}
}
on *:sockopen:lyrics:{
tokenize 96 $sock(lyrics).mark
sockwrite -n $sockname GET $+(/search.php?keyword=,$2,&what=all&x=0&y=0) HTTP/1.1
sockwrite -n $sockname Host: $1
sockwrite -n $sockname $crlf
}
on *:SOCKREAD:lyrics: {
var %lyrics | sockread %lyrics
if $findtok(%lyrics,td>,1,60) {
if ($wildtok(%lyrics,http://www.lyrics.com/artists/name/*,1,34)) {
var %artist $remove($gettok(%lyrics,3,62),</a)
tokenize 96 $sock(lyrics).mark
$4 12[14 Lyrics 12] 14 $+ $qt(12 $+ $3 $+ 14) - 14Songname:12 %song - 14Artist:12 %artist - 14URL:12 %link
unset %song %link
sockclose lyrics
}
if ($wildtok(%lyrics,http://www.lyrics.com/artists/lyric/*,1,34)) {
set %song $remove($gettok(%lyrics,3,62),</a)
set %link $v1
}
}
}
nice work
you can also do it like this as well
on $*:TEXT:/^([!@.])lyrics\s(.+)/Si:#: {
if (!$($+(%,lyricsflood,$nick),2)) {
set -u3 $+(%,lyricsflood,$nick) on
sockopen lyrics www.lyrics.com 80
sockmark lyrics $+($replace($regml(2),$chr(32),+),|,$iif($regml(1) == @,msg #,.notice $nick))
}
}
on *:sockopen:lyrics: {
sockwrite -nt $sockname GET $+(/search.php?keyword=,$gettok($sock(lyrics).mark,1,124),&what=all&x=0&y=0) HTTP/1.1
sockwrite -nt $sockname Host: $+(www.lyrics.com,$str($crlf,2))
}
on *:SOCKREAD:lyrics: {
var %lyrics | sockread %lyrics
if ($regex(%lyrics,/<td><a href="http:\/\/www.lyrics.com\/artists\/lyric\/(.+)">(.+)<\/a><\/td>/)) { sockmark lyrics $addtok($sock(lyrics).mark,12 $chr(91) 14Lyrics12 $chr(93) 12 $replace($qt($gettok($sock(lyrics).mark,1,124)),+,$chr(32)) - 14Songname:12 $regml(2) $chr(124) - 14URL:12 $+(http://www.lyrics.com/artists/lyric/,$regml(1)),124) }
if ($regex(%lyrics,/<td><a href="http:\/\/www.lyrics.com\/artists\/name\/.+">(.+)<\/a><\/td>/)) { $gettok($sock(lyrics).mark,2,124) $gettok($sock(lyrics).mark,3,124) - 14Artist:12 $regml(1) $gettok($sock(lyrics).mark,4,124) | sockclose lyrics }
}
just one of many ways to do this script.