Advertisement
illpastethat

YouTube Script (Parse Vids and Search) v2.1

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