Advertisement
Ford

Youtube Advanced search for mIRC

Jan 12th, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 5.14 KB | None | 0 0
  1. ;Youtube advanced search by Ford_Lawmower irc.GeekShed.net #Script-Help
  2. alias -l GetYoutube {
  3.   var %MaxResults 3
  4.   var %TitleColor $+($chr(3),$chr(2))
  5.   var %TextColor $+($chr(2),$chr(3),04)
  6.   var %LinkColor $+($chr(3),$chr(31))
  7.   var %logo $+($chr(2),$chr(3),01,$chr(44),00You,$chr(3),00,$chr(44),04Tube,$chr(2))
  8.   $1-2 %logo %TitleColor Searching Youtube........  
  9.   var %sockname $+(YoutubeAdvancedSearch,$network,$2,$ticks), %yt.url $replace($3-,$chr(32),+)
  10.   if ($left($3,1) == -) {
  11.     if ($3 == -h || !$4) {
  12.       $1-2 Syntax is !Youtube search words here. Optionally, you can change the search type by adding a search flag directly after !youtube and before The search word(s)
  13.       $1-2 Valid search flags are -n (newest) -o (oldest) -v (view count) -r (rating) . Ex. !Youtube -n jimi hendrix  <<-- Will show the 3 newest posts with jimi hendrix in them.
  14.       $1-2 You can also use the @ trigger to message the channel if you have halfops or higher. Ex. @Youtube jimi hendrix
  15.       return
  16.     }  
  17.     elseif ($3 == -n) { var %SearchType &search_sort=video_date_uploaded }
  18.     elseif ($3 == -o) { var %SearchType &search_sort=video_date_uploaded_reverse }
  19.     elseif ($3 == -v) { var %SearchType &search_sort=video_view_count }
  20.     elseif ($3 == -r) { var %SearchType &search_sort=video_avg_rating }
  21.     %yt.url = $replace($4-,$chr(32),+) $+ %SearchType
  22.   }
  23.   var %yt.url $replace($iif(- isin $3,$4-,$3-),$chr(32),+) $+ %SearchType
  24.   sockopen %sockname www.youtube.com 80
  25.   sockmark %sockname $1-2 $+(/results?search_type=&aq=f&search_query=,%yt.url,&hl=en) %MaxResults %TitleColor %TextColor %LinkColor %logo
  26. }
  27. menu Channel,Status {
  28.   .$iif($group(#Youtube) == On,$style(1)) Youtube Trigger
  29.   ..$iif($group(#Youtube) == On,$style(2)) On: .enable #Youtube
  30.   ..$iif($group(#Youtube) == Off,$style(2)) Off: .disable #Youtube
  31. }
  32. #Youtube on
  33. On $*:Text:/^(\+|-|!|@)Youtube.*/Si:#: {
  34.   var %action $regml(1)
  35.   if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
  36.     if (%action == +) {
  37.       if ($istok(%YoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the Youtube script }
  38.       else {
  39.         .enable #Youtube
  40.         Set %YoutubeChanList $addtok(%YoutubeChanList,$+($network,$chan),32)
  41.         .msg $chan $nick has activated the Youtube script for $chan .
  42.       }
  43.     }
  44.     else {
  45.       if (!$istok(%YoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the Youtube script }
  46.       else {
  47.         Set %YoutubeChanList $remtok(%YoutubeChanList,$+($network,$chan),1,32)
  48.         .msg $chan $nick has deactivated the Youtube script for $chan .
  49.       }
  50.     }
  51.   }
  52.   elseif (!$timer($+(Youtube,$network,$nick))) && ($istok(%YoutubeChanList,$+($network,$chan),32)) {
  53.     .timer $+ $+(Youtube,$network,$nick) 1 6 noop
  54.     var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  55.     GetYoutube %method $strip($2-)
  56.   }
  57. }
  58. #Youtube end
  59. On *:sockopen:YoutubeAdvancedSearch*: {
  60.   if (!$sockerr) {
  61.     sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
  62.     sockwrite -n $sockname Host: www.youtube.com
  63.     sockwrite -n $sockname $crlf
  64.   }
  65.   else { echo -st Socket Error $nopath($script) | youtube.cleanup }
  66. }
  67. On *:sockread:YoutubeAdvancedSearch*: {
  68.   if ($sockerr) { echo -st Socket Error $nopath($script) | youtube.cleanup }
  69.   else {
  70.     var %Youtube | sockread %Youtube
  71.     if (No video results isin %Youtube) {
  72.       $gettok($sock($sockname).mark,1-2,32) No results were found for your search!
  73.       youtube.cleanup
  74.     }
  75.     if ($regex(%Youtube,/item-title="(.*?)"\s?data/i)) hadd -m $sockname title $fix($xchr($fix($regml(1))))
  76.     if ($regex(%Youtube,/item-id="(.*?)"\s?data/i)) hadd -m $sockname id $regml(1)    
  77.     if ($regex(%Youtube,/item-user="(.*?)"\s?data/i)) hadd -m $sockname user $regml(1)
  78.     if ($regex(%Youtube,/item-views="(.*?)"\s?data/i)) hadd -m $sockname views $regml(1)    
  79.     if ($regex(%Youtube,/&bull;</span>(.*?)<span\sclass/i)) {
  80.       hadd -m $sockname date $regml(1)
  81.       hinc $sockname count      
  82.       var %s $sockname
  83.       tokenize 32 $sock(%s).mark
  84.       $1-2 $8- $+($5,Title:,$6) $hget(%s,title) $+($5,User:,$6) $hget(%s,user) $+($5,Added:,$6) $hget(%s,date) $+($5,Views:,$6) $hget(%s,views) $+($7,http://www.youtube.com/watch?v=,$hget(%s,id))
  85.       if ($hget(%s,count) >= $4) youtube.cleanup      
  86.     }
  87.   }
  88. }
  89. On *:sockclose:YoutubeAdvancedSearch*: youtube.cleanup
  90. alias -l youtube.cleanup {
  91.   if ($hget($sockname)) hfree $v1
  92.   sockclose $sockname
  93.   return
  94. }
  95. alias Youtube { GetYoutube echo -a $1- }
  96. alias -l Xchr {
  97.   var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2});/g,$chr(\1))
  98.   return $replacecs(%return,&ndash;,–,&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,&uuml;,ü,&Aacute;,Á,&aacute;,á,&Eacute;,$&
  99.     É,&eacute;,é,&Iacute;,Í,&iacute;,í,&Oacute;,Ó,&oacute;,ó,&Ntilde;,Ñ,&ntilde;,ñ,&Uacute;,Ú,&uacute;,ú,&nbsp;,$chr(32),$&
  100.     &aelig;,æ,&quot;,",&lt;,<,&gt;,>)
  101. }
  102. alias -l fix { return $regsubex($remove($replace($1-,&amp;,&,&quot;,"),amp;,<b>,</b>),/&#([0-9]{2});/gi,$chr(\t)) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement