Youtube Search **UPDATED**

By TheNitelyfe on Jun 10, 2009

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> &nbsp;/)) { 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,&nbsp;)
  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,&amp;,&,&quot;,")
}

Comments

Sign in to comment.
sunslayer   -  Mar 27, 2010

@Tatonka use @yt and it will msg the chan

 Respond  
Tatonka   -  Mar 27, 2010

Mmmh... how can i show result on the chan ? and not with a notice.

sockmark yt $+($iif($left($1,1) == @,msg #,.notice $nick)
sockmark yt $+($iif($left($1,1) == @,msg #,.say) don't work :/ (i'm noob, i know.)

 Respond  
TheNitelyfe   -  Jan 03, 2010

updated looks better i guess

 Respond  
TheNitelyfe   -  Jul 30, 2009

np sir

 Respond  
VinX   -  Jul 30, 2009

thanks TNL

 Respond  
sunslayer   -  Jun 10, 2009

ahh ty ES :p

 Respond  
ES   -  Jun 10, 2009

sunslayer
you're thinking of
Sean Paul - Temperature
;)

 Respond  
sunslayer   -  Jun 10, 2009

neatly coded :p

and lol @ sean kingston isnt he the guy that did that song that was like hot or temperature or something?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.