Advertisement
illpastethat

YouTube Script (Parse Vids and Search) v1.0

May 31st, 2011
1,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 6.84 KB | None | 0 0
  1. ;Made by nick1
  2. ;Last edit april 25 2011
  3. raw 408:*: msg $2 $remove($strip($13-),$chr(9))
  4. on $*:text:/^[!@]y(outube|t|tsearch|search|ousearch|outubesearch)/Si:*:{
  5.   if ($($+(%,botflood.,$nick),2)) {
  6.     if ($($+(%,botflood.,$nick),2) >= 50) { ignore -u60 $address($nick,0) | msg $chan $+($nick,$chr(44)) You Have Been Put On Ignore For 60secs For Abusing The Bot. | halt }
  7.     elseif ($($+(%,botflood.,$nick),2) >= 40) { msg $chan $+($nick,$chr(44)) Please Do Not Abuse The Bot. | inc -z $+(%,botflood.,$nick) 20 | halt }
  8.     else { inc -z $+(%,botflood.,$nick) 25 }
  9.   }
  10.   else { inc -z $+(%,botflood.,$nick) 25 }
  11.   if ($sock(ysearch)) { msg $chan $nick $+ : Please wait, already searching. | halt }
  12.   elseif ($2) {
  13.     set %ysearch.msgtype $iif($left($strip($1),1) == @,msg $chan,notice $nick)
  14.     set %ysearch.search $replace($2-,$chr(32),+)
  15.     sockopen ysearch youtube.com 80
  16.   }
  17.   elseif ($2 == $null) { msg $chan $+(4,$nick,,$chr(44)) 10Incorrect Syntax: Try ! or @ 4YOUTUBE10 <search term> }
  18. }
  19. on *:input:*:{
  20.   if (($remove($1,$left($strip($1),1)) == ysearch) || ($remove($1,$left($strip($1),1)) == ytsearch) || ($remove($1,$left($strip($1),1)) == yt) || ($remove($1,$left($strip($1),1)) == youtube) || ($remove($1,$left($strip($1),1)) == youtubesearch)) {
  21.     set %ysearch.msgtype msg $active
  22.     set %ysearch.search $replace($2-,$chr(32),+)
  23.     sockopen ysearch youtube.com 80
  24.   }
  25.   elseif (*youtube.com* iswm $1-) {
  26.     set %i 1
  27.     while (%i <= $numtok($1-,32)) {
  28.       if (*youtube.com* iswm $($+($,%i),2)) {
  29.         set %youtube.url $($+($,%i),2)
  30.         set %youtube.tag $remove($($+($,%i),2),http://,www.,youtube.com)
  31.       }
  32.       inc %i
  33.     }
  34.     set %youtube.msgtype msg $active
  35.     set %youtube.nick $nick
  36.     set %youtube.chan $chan
  37.     set %youtube.network $network
  38.     sockopen youtube youtube.com 80
  39.   }
  40.   elseif (($1 == !youtubelinks) || ($1 == !youtubefetch)) {
  41.     set %youtubefetch $addtok(%youtubefetch,$iif(($2),$2,$chan),44)
  42.     echo -ac info I will message $iif(($2),$2,$chan) with youtube info...
  43.   }
  44.   elseif (($1 == !noyoutubelinks) || ($1 == !noyoutubefetch)) {
  45.     set %youtubefetch $remtok(%youtubefetch,$iif(($2),$2,$chan),44)
  46.     echo -ac info I wont message $iif(($2),$2,$chan) with youtube info...
  47.   }
  48. }
  49.  
  50. alias checkifsockopen {
  51.   if ($sock(%checksockname)) { sockclose %checksockname
  52.     if (%youtube.msgtype) %youtube.msgtype $+(12[4,YOUTUBE,12])10 Error Encountered! | unset %youtube.*
  53.   }
  54. }
  55.  
  56.  
  57. on *:sockopen:ysearch: {  
  58.   set %checksockname $sockname
  59.   .timerCheck 1 5 checkifsockopen
  60.   sockwrite -nt $sockname GET /results?search_query= $+ %ysearch.search HTTP/1.1
  61.   sockwrite -nt $sockname Host: www.youtube.com
  62.   sockwrite -nt $sockname $crlf
  63. }
  64.  
  65. alias nohtml { return $regsubex($$1-,/^[^<]*>|<[^>]*>|<[^>]*$/g,) }
  66.  
  67.  
  68. on *:SOCKREAD:ysearch: {
  69.   if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
  70.   sockread %sockreader
  71.   if (*<h3>* iswm %sockreader) {
  72.     set %ysearch.title $regsubex($nohtml($replace($remove(%sockreader,|),<b>,,</b>,,&quot;,")),/&#(\d\d?\d?\d?);/g,$chr(\1))
  73.     tokenize 34 %sockreader
  74.     set %ysearch.tag $2
  75.   }
  76.   elseif (*</div><h3* iswm %sockreader) {
  77.     set %ysearch.title $regsubex($nohtml($replace($remove(%sockreader,|),<b>,,</b>,,&quot;,",&amp;,-)),/&#(\d\d?\d?\d?);/g,$chr(\1))
  78.     tokenize 34 %sockreader
  79.     set %ysearch.tag $4
  80.   }
  81.   elseif (*<span class="video-time">* iswm %sockreader) {
  82.     set %ysearch.time $nohtml($remove(%sockreader,Add to,Added,to,queue))
  83.   }
  84.   elseif (*<span class="username-prepend">* iswm %sockreader) {
  85.     set %ysearch.user $remove($nohtml(%sockreader),by)
  86.   }
  87.   elseif (*<span class="viewcount">* iswm %sockreader) {
  88.     set %ysearch.viewcount $remove($nohtml(%sockreader),|,views)
  89.     %ysearch.msgtype 1,0You0,4Tube 10Link:4 http://youtube.com $+ %ysearch.tag 10Title:4 %ysearch.title 10Length:4 %ysearch.time 10Views:4 %ysearch.viewcount 10User:4 %ysearch.user
  90.     sockclose $sockname
  91.     unset %ysearch.*
  92.   }
  93. }
  94.  
  95.  
  96.  
  97. on $*:text:/youtube.com/Si:*: {
  98.   if ($($+(%,botflood.,$nick),2)) {
  99.     if ($($+(%,botflood.,$nick),2) >= 50) { ignore -u60 $address($nick,0) | msg $chan $+($nick,$chr(44)) You Have Been Put On Ignore For 60secs For Abusing The Bot. | halt }
  100.     elseif ($($+(%,botflood.,$nick),2) >= 40) { msg $chan $+($nick,$chr(44)) Please Do Not Abuse The Bot. | inc -z $+(%,botflood.,$nick) 20 | halt }
  101.     else { inc -z $+(%,botflood.,$nick) 10 }
  102.   }
  103.   else { inc -z $+(%,botflood.,$nick) 10 }
  104.   set %i 1
  105.   if ($sock(youtube)) {
  106.     msg $chan $nick $+ : Please wait, already working on a vid.
  107.     halt
  108.   }
  109.   while (%i <= $numtok($1-,32)) {
  110.     if (*youtube.com* iswm $($+($,%i),2)) {
  111.       set %youtube.url $($+($,%i),2)
  112.       set %youtube.tag $remove($($+($,%i),2),http://,www.,youtube.com)
  113.     }
  114.     inc %i
  115.   }
  116.   if (($me == Mafbot) || ($nick($chan,$me,@&~)) || ($istok(%youtubefetch,$chan,44))) {
  117.     set %youtube.msgtype msg $chan
  118.   }
  119.   elseif (($me != Mafbot) && (!$nick($chan,$me,@&~)) && (!$istok(%youtubefetch,$chan,44))) {
  120.     set %youtube.msgtype echo -a
  121.   }
  122.   if (%youtube.tag != %_youtube.last) {
  123.     set %youtube.nick $nick
  124.     set %youtube.chan $chan
  125.     set %youtube.network $network
  126.     sockopen youtube youtube.com 80
  127.   }
  128. }
  129.  
  130. on *:sockopen:youtube: {
  131.   .timerSet 1 4 set %checksockname $sockname
  132.   .timerCheck 1 5 checkifsockopen
  133.   sockwrite -nt $sockname GET %youtube.tag HTTP/1.1  
  134.   sockwrite -nt $sockname Host: www.youtube.com
  135.   sockwrite -nt $sockname $crlf
  136. }
  137.  
  138. on *:SOCKREAD:youtube: {
  139.   if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
  140.   else {
  141.     var %sockreader
  142.     sockread %sockreader
  143.     if (*<meta name="title"* iswm %sockreader) {
  144.       tokenize 32 %sockreader
  145.       set %youtube.title $replace($remove(%sockreader,<meta name="title" content=",">),&amp;quot;,",&amp;#39;,',&quot;,",&amp;,&,&#39;,')
  146.     }
  147.     elseif (*<span class="watch-view-count">* iswm %sockreader) {
  148.       set %youtube.viewcheck on
  149.     }
  150.     elseif (*<a id="watch-username" class="inline-block" rel="author" href="/user/* iswm %sockreader) {
  151.       set %youtube.user $nohtml(%sockreader)
  152.     }
  153.     elseif (*<a id="watch-userbanner" class="inline-block" rel="author" href="/user/* iswm %sockreader) {
  154.       tokenize 34 %sockreader
  155.       set %youtube.user $10
  156.     }
  157.     elseif ((*<strong>* iswm %sockreader) && (%youtube.viewcheck == on)) {
  158.       set %youtube.viewcount $nohtml(%sockreader)
  159.       if (%youtube.msgtype == echo -a) %youtube.msgtype 12[4 $+ %youtube.chan $+ 12] 1,0You0,4Tube 10Title:4 %youtube.title 10Views:4 %youtube.viewcount 10User:4 %youtube.user 12From4 %youtube.nick 10on12 %youtube.network    
  160.       else { %youtube.msgtype 1,0You0,4Tube 10Title:4 %youtube.title 10Views:4 %youtube.viewcount 10User:4 %youtube.user }
  161.       sockclose youtube
  162.       set %_youtube.last %youtube.tag
  163.       unset %youtube.*
  164.     }
  165.   }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement