Pretty basic Youtube searcher. When you trigger it, it searches for what you put in, then gets the info and URL of the first result of the first vid.
20:03 <@BluePrint> (Youtube Search) Title: (Akon - Beautiful ft. Colby O'Donis, Kardinal Offishall)(25,179,890 views) Duration: (3:50) Rating: (5.0) Date uploaded: (June 16, 2009)
20:03 <@BluePrint> (Link) (http://www.youtube.com/watch?v=rSOzN0eihsE)
on $*:TEXT:/^[!@.]y(ou)?t(ube)?/Si:#:{
if (!$($+(%,flood,$nick),2)) && (!$sock(yt)) {
set -u3 $+(%,flood,$nick) on
sockopen yt www.youtube.com 80
sockmark yt $+($iif($left($1,1) == @,msg #,.notice $nick),>,$replace($$2-,$chr(32),+),>)
}
}
on *:sockopen:yt:{
sockwrite -nt $sockname GET $+(/results?search_query=,$token($sm(yt),2,62)) HTTP/1.1
sockwrite -nt $sockname Host: $+(www.youtube.com,$str($crlf,2))
}
on *:sockread:yt:{
if ($sockerr) { $token($sm(yt),1,62) $logo(Error) $sock(yt).wsmsg }
var %yt
sockread %yt
if (*No videos found* iswm %yt) {
$token($sm(yt),1,62) $logo(Youtube Search) 14Search query not found. Try again.
sockclose yt
}
if ($regex(%yt,/qlicon="(.*)" alt=.*/)) { set -u3 %link 12(14 $+ $+(http://www.youtube.com/watch?v=,$regml(1)) $+ 12) }
if ($regex(%yt,/rel="nofollow">(.*)<\/a>/)) { set -u3 %title 14Title: 12(14 $+ $htmlentities($htmlfree($regml(1))) $+ 12) }
if ($regex(%yt,/class="video-view-count">(.*)<\/span>/)) { set -u3 %views 12(14 $+ $regml(1) $+ 12) }
if ($regex(%yt,/class="hovercard-duration">(.*)<\/span> /)) { set -u3 %dur 14Duration: 12(14 $+ $regml(1) $+ 12) }
if ($regex(%yt,/ratingVS ratingVS-.*" title="(.*)"><\/button>/)) { set -u3 %rate 14Rating: 12(14 $+ $regml(1) $+ 12) }
if ($regex(%yt,/class="hovercard-upload-date">(.*)<\/span>/)) {
$token($sm(yt),1,62) $logo(Youtube Search) %title %views %dur %rate 14Date uploaded: 12(14 $+ $regml(1) $+ 12)
$token($sm(yt),1,62) $logo(Link) %link
sockclose yt
}
}
alias sm { if ($isid) { return $sock($$1).mark } }
alias logo { if ($isid) { return 12(14 $+ $$1- $+ 12) } }
alias htmlfree {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
alias htmlentities {
var %i = $1, %a = 1
while $regex(*,%i,/(&#(\d+?);)/) {
if $regml(*,1).pos < %a { return %i }
%i = $replace(%i,$regml(*,1),$chr($regml(*,2)))
inc %a
}
return $replace(%i,&,&,",")
}