Advertisement
illpastethat

YouTube Script (Parse Vids and Search) v4.8

Apr 18th, 2012
1,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 19.12 KB | None | 0 0
  1. ;YouTube Script (Parse Vids and Search) v4.8
  2. ;Made by nick1
  3. ;Last edit April 18 2012
  4. ;For help type /YouTube in mIRC
  5. ;2D0 -- Download videos in a few formats [[possible?]], anything else?
  6. ;EDITS -- changed auto update for each start of mIRC and option in dialog, fixed bug for returning hawkee title instead of youtube title
  7.  
  8. alias -l yversion {
  9.   return v4.8
  10. }
  11.  
  12. menu status,channel,query {
  13.   YouTube:youtube
  14. }
  15.  
  16. alias YouTube {
  17.   dialog -m YouTube YouTube
  18. }
  19.  
  20. dialog Youtube {
  21.   title "YouTube v4.8"
  22.   size -1 -1 219 139
  23.   option dbu
  24.   icon $mircdirYoutube.ico, 0
  25.   link "View Script On Hawkee", 1, 138 2 59 8
  26.   button "Exit", 7, 72 126 72 12, cancel
  27.   tab "About", 10, 2 9 214 114
  28.   link "YouTube Script (Parse Vids and Search) v4.8 -- Post Bugs and Feature Requests Here", 24, 5 26 208 8, tab 10
  29.   text "Last updated on April 18, 2012", 19, 23 40 83 8, tab 10
  30.   text "Please post suggestions, complaints, or bugs on the hawkee link (or in chat)", 20, 7 63 188 8, tab 10
  31.   text "!commands will notice the user; @commands will be public to the channel", 13, 7 92 175 8, tab 10
  32.   text "Default behavior is to run on every channel for every nick. Use the Nick and Channel Settings Tabs to change it for invidividual channels or nicks.", 65, 7 75 208 14, tab 10
  33.   link "Click here to chat (leave a message for nick1)", 66, 47 52 110 8, tab 10
  34.   text "Use the Basic Options Tab to adjust which parts of the script will run and basic formatting options.", 23, 7 103 207 13, tab 10
  35.   button "Check for Updates", 21, 127 38 54 12, tab 10
  36.   tab "Basic Options", 2
  37.   box "Search Commands", 60, 7 52 186 20, tab 2
  38.   text "youtube <search terms>; ytsearch <search>; ysearch <search terms>", 62, 10 60 175 8, tab 2
  39.   box "Disable Options", 5, 7 23 189 27, tab 2
  40.   check "Disable Search - Disables commands below", 11, 11 29 123 10, tab 2 flat
  41.   check "Disable Parse - Disables the script from automatically sending info", 14, 11 38 175 10, tab 2 flat
  42.   box "Output Options", 9, 7 74 194 47, tab 2
  43.   check "Disable Views - Removes 'Views: <Views>'", 15, 11 81 136 10, tab 2
  44.   check "Disable Length - Removes 'Length: <Length>'", 16, 11 90 130 10, tab 2
  45.   check "Disable User - Removes 'User: <User>'", 17, 11 99 132 10, tab 2
  46.   check "Disable Formatting - Removes Colors and Bold", 22, 11 109 167 10, tab 2
  47.   tab "Channel Settings", 3
  48.   list 6, 8 56 202 59, tab 3 sort size extsel vsbar
  49.   edit "", 8, 9 26 155 25, tab 3 multi autohs autovs
  50.   text "List of channels the script will NOT run on", 12, 48 50 101 6, tab 3
  51.   button "Add", 4, 172 27 37 12, tab 3
  52.   button "Remove", 63, 172 42 37 12, tab 3
  53.   button "Click here to enter #channels ...", 64, 10 27 153 23, tab 3
  54.   tab "Nick Settings", 26
  55.   text "List of nicks the script will NOT run for", 70, 48 50 101 6, tab 26
  56.   list 71, 8 56 202 60, tab 26 sort size extsel vsbar
  57.   button "Remove", 72, 172 42 37 12, tab 26
  58.   button "Add", 73, 172 27 37 12, tab 26
  59.   edit "", 69, 9 26 155 25, tab 26 multi autohs autovs
  60.   button "Click here to enter Nicks ...", 74, 10 27 153 23, tab 26
  61.   tab "Just For Fun", 68
  62.   text "See if you can check all the checkboxes! Warning: there might not be a reward.", 27, 25 52 144 14, tab 68
  63.   check "Check Box", 44, 123 24 50 10, tab 68
  64.   check "Check Box", 43, 130 32 50 10, tab 68
  65.   check "Check Box", 53, 135 42 50 10, tab 68
  66.   check "Check Box", 42, 128 58 50 10, tab 68
  67.   check "Check Box", 51, 130 73 50 10, tab 68
  68.   check "Check Box", 41, 112 67 50 10, tab 68
  69.   check "Check Box", 35, 87 73 50 10, tab 68
  70.   check "Check Box", 34, 76 82 50 10, tab 68
  71.   check "Check Box", 39, 82 92 50 10, tab 68
  72.   check "Check Box", 55, 90 98 50 10, tab 68
  73.   check "Check Box", 38, 132 100 50 10, tab 68
  74.   check "Check Box", 47, 131 90 50 10, tab 68
  75.   check "Check Box", 37, 125 82 50 10, tab 68
  76.   check "Check Box", 54, 48 99 50 10, tab 68
  77.   check "Check Box", 49, 26 101 50 10, tab 68
  78.   check "Check Box", 40, 29 93 50 10, tab 68
  79.   check "Check Box", 56, 33 83 50 10, tab 68
  80.   check "Check Box", 33, 18 80 50 10, tab 68
  81.   check "Check Box", 48, 14 68 50 10, tab 68
  82.   check "Check Box", 50, 39 69 50 10, tab 68
  83.   check "Check Box", 52, 79 63 50 10, tab 68
  84.   check "Check Box", 46, 81 41 50 10, tab 68
  85.   check "Check Box", 36, 94 31 50 10, tab 68
  86.   check "Check Box", 45, 47 37 50 10, tab 68
  87.   check "Check Box", 31, 27 33 50 10, tab 68
  88.   check "Check Box", 30, 42 25 50 10, tab 68
  89.   check "Check Box", 28, 7 25 50 10, tab 68
  90.   check "Check Box", 29, 8 35 50 10, tab 68
  91.   check "Check Box", 32, 6 43 50 10, tab 68
  92.   check "Check Box", 75, 152 76 50 10, tab 68
  93.   check "Check Box", 76, 162 37 50 10, tab 68
  94.   check "Check Box", 77, 164 24 50 10, tab 68
  95.   check "Check Box", 78, 42 108 50 10, tab 68
  96.   check "Check Box", 79, 165 86 50 10, tab 68
  97.   check "Check Box", 80, 162 109 50 10, tab 68
  98.   check "Check Box", 81, 147 105 50 10, tab 68
  99.   check "Check Box", 82, 164 64 50 10, tab 68
  100.   check "Check Box", 83, 5 74 50 10, tab 68
  101.   check "Check Box", 84, 155 57 50 10, tab 68
  102.   check "Check Box", 85, 6 107 50 10, tab 68
  103.   check "Check Box", 86, 76 106 50 10, tab 68
  104.   check "Check Box", 87, 6 89 50 10, tab 68
  105.   text "This script created by nick1", 18, 4 2 66 8
  106. }
  107.  
  108. on *:dialog:youtube:init:0: {
  109.   FillChannelBox
  110.   FillNickBox
  111.   $iif(%_youtube.nocolor == true,did -c youtube 22,noop)
  112.   $iif(%_youtube.noviews == true,did -c youtube 15,noop)
  113.   $iif(%_youtube.nolength == true,did -c youtube 16,noop)
  114.   $iif(%_youtube.nouser == true,did -c youtube 17,noop)
  115.   $iif($group(#search) != on,did -c youtube 11,noop)
  116.   $iif($group(#parse) != on,did -c youtube 14,noop)  
  117. }
  118.  
  119. alias FillChannelBox {
  120.   did -r youtube 6
  121.   var %y 1
  122.   while (%y <= $numtok(%youtubefetch,44)) {
  123.     did -a youtube 6 $gettok(%youtubefetch,%y,44)
  124.     inc %y
  125.   }
  126. }
  127.  
  128. alias FillNickBox {
  129.   did -r youtube 71
  130.   var %y 1
  131.   while (%y <= $numtok(%nolinks,44)) {
  132.     did -a youtube 71 $gettok(%nolinks,%y,44)
  133.     inc %y
  134.   }
  135. }
  136.  
  137. on *:dialog:youtube:sclick:*: {
  138.   if (($did == 1) || ($did == 24)) {
  139.     run http://www.hawkee.com/snippet/8577/
  140.   }
  141.   elseif ($did == 66) {
  142.     run https://qchat.rizon.net/?&channels=#rsbot_help&nick=YouTube..
  143.   }
  144.   elseif ($did == 22) {
  145.     set %_youtube.nocolor $iif($did(22).state,true,false)
  146.   }
  147.   elseif ($did == 15) {
  148.     set %_youtube.noviews $iif($did(15).state,true,false)
  149.   }
  150.   elseif ($did == 16) {
  151.     set %_youtube.nolength $iif($did(16).state,true,false)
  152.   }
  153.   elseif ($did == 17) {
  154.     set %_youtube.nouser $iif($did(17).state,true,false)
  155.   }
  156.   elseif ($did == 11) {
  157.     $iif($group(#search) == on,.disable,.enable) #search
  158.   }
  159.   elseif ($did == 21) {
  160.     yupdate
  161.   }
  162.   elseif ($did == 14) {
  163.     $iif($group(#parse) == on,.disable,.enable) #parse
  164.   }
  165.   elseif ($did == 4) {
  166.     set %youtubefetch $addtok(%youtubefetch,$iif(($left($did(8),1) == $chr(35)),$did(8),$+($chr(35),$did(8))),44)
  167.     did -r youtube 8
  168.     FillChannelBox
  169.   }
  170.   elseif ($did == 73) {
  171.     set %nolinks $addtok(%nolinks,$did(69),44)
  172.     did -r youtube 69
  173.     FillNickBox
  174.   }
  175.   elseif ($did == 63) {
  176.     if ($did(8) != $null) {
  177.       set %youtubefetch $remtok(%youtubefetch,$iif(($left($did(8),1) == $chr(35)),$did(8),$+($chr(35),$did(8))),44)
  178.       did -r youtube 8
  179.     }
  180.     if ($did(6).seltext != $null) {
  181.       set %youtubefetch $remtok(%youtubefetch,$did(6).seltext,44)
  182.     }
  183.     FillChannelBox
  184.   }
  185.   elseif ($did == 3) {
  186.     did -t youtube 4
  187.   }
  188.   elseif ($did == 26) {
  189.     did -t youtube 73
  190.   }
  191.   elseif ($did == 72) {
  192.     if ($did(69) != $null) {
  193.       set %nolinks $remtok(%nolinks,$did(69),44)
  194.       did -r youtube 69
  195.     }
  196.     if ($did(71).seltext != $null) {
  197.       set %nolinks $remtok(%nolinks,$did(71).seltext,44)
  198.     }
  199.     FillNickBox
  200.   }
  201.   elseif ($did isnum 28-56) {
  202.     var %r $r(1,2)
  203.     if (%r == 1) {
  204.       $iif(($r(1,3) == 1),.timercheck -m 1 13 did -c youtube $r(75,87),.timeruncheck -m 1 13 did -u youtube $r(75,87))
  205.     }
  206.     else {
  207.       $iif(($r(1,3) == 1),.timercheck -m 1 13 did -c youtube $r(28,56),.timeruncheck -m 1 13 did -u youtube $r(28,56))
  208.     }
  209.   }
  210.   elseif ($did isnum 75-87) {
  211.     var %r $r(1,2)
  212.     if (%r == 1) {
  213.       $iif(($r(1,3) == 1),.timercheck -m 1 13 did -c youtube $r(75,87),.timeruncheck -m 1 13 did -u youtube $r(75,87))
  214.     }
  215.     else {
  216.       $iif(($r(1,3) == 1),.timercheck -m 1 13 did -c youtube $r(28,56),.timeruncheck -m 1 13 did -u youtube $r(28,56))
  217.     }
  218.   }
  219. }
  220.  
  221. raw 408:*: msg $2 $remove($strip($13-),$chr(9))
  222.  
  223. alias urlencode {
  224.   return $replacex($regsubex($$1-,/([^\w\s])/Sg,$+(%,$base($asc(\t),10,16,2))),$chr(32),+,$chr(43),%2B)
  225. }
  226.  
  227. #search on
  228. on $*:text:/^[!@]y(outube|t|tsearch|search|ousearch|outubesearch)(\s|$)/Si:*: {
  229.   $iif($istok(%youtubefetch,$chan,44),halt,noop)
  230.   $iif($istok(%nolinks,$nick,44),halt,noop)
  231.   if ($($+(%,botflood.,$nick),2)) {
  232.     if ($($+(%,botflood.,$nick),2) >= 50) {
  233.       ignore -u60 $address($nick,2)
  234.       msg $chan $+($nick,$chr(44)) You have been put on ignore for 60secs for abusing the bot.
  235.       halt
  236.     }
  237.     elseif ($($+(%,botflood.,$nick),2) >= 40) {
  238.       msg $chan $+($nick,$chr(44)) Please do not flood the bot.
  239.       inc -z $+(%,botflood.,$nick) 20
  240.       halt
  241.     }
  242.     else {
  243.       inc -z $+(%,botflood.,$nick) 25
  244.     }
  245.   }
  246.   else {
  247.     inc -z $+(%,botflood.,$nick) 25
  248.   }
  249.   var %ticks $ticks
  250.   if ($2) {
  251.     set $+(%,ysearch.,%ticks,.msgtype) $iif($chan,$iif($left($strip($1),1) == @,msg $chan,notice $nick),msg $nick)
  252.     set $+(%,ysearch.,%ticks,.search) $2-
  253.     set $+(%,ysearch.,%ticks,.query) $urlencode($2-)
  254.     sockopen $+(ysearch.,%ticks) gdata.youtube.com 80
  255.   }
  256.   elseif ($2 == $null) {
  257.     notice $nick 4Incorrect Syntax - Use10 $1 <search term>
  258.   }
  259. }
  260.  
  261. on *:input:*:{
  262.   $iif($istok(%nolinks,$active,44),return,noop)
  263.   $iif($istok(%youtubefetch,$active,44),return,noop)
  264.   var %ticks $ticks
  265.   if (($remove($1,$left($strip($1),1)) == ysearch) || ($remove($1,$left($strip($1),1)) == ytsearch) || ($remove($1,$left($strip($1),1)) == youtube) || ($remove($1,$left($strip($1),1)) == yt) || ($remove($1,$left($strip($1),1)) == youtubesearch)) {
  266.     if ($left($1,1) != /) {
  267.       if ($2 != $null) {
  268.         set $+(%,ysearch.,%ticks,.msgtype) msg $active
  269.         set $+(%,ysearch.,%ticks,.search) $2-
  270.         set $+(%,ysearch.,%ticks,.query) $urlencode($2-)
  271.         sockopen $+(ysearch.,%ticks) gdata.youtube.com 80
  272.       }
  273.       elseif ($2 == $null) {
  274.         .timerYTInputSyntax -m 1 100 echo -at 4Incorrect Syntax - Use10 $1 <search term>
  275.       }
  276.     }
  277.   }
  278.   elseif ((*youtube.com* iswm $1-) || (*youtu.be* iswm $1-)) {
  279.     if ($left($1,1) != /) {
  280.       var %i 1
  281.       while (%i <= $numtok($1-,32)) {
  282.         if ((*youtube.com* iswm $($+($,%i),2)) || (*youtu.be* iswm $($+($,%i),2))) {
  283.           set $+(%,youtube.,%ticks,.url) $strip($($+($,%i),2))
  284.           var %tag $($+(%,youtube.,%ticks,.url),2)
  285.           var %tag $iif($matchtok(%tag,v=,1,38),$v1,%tag)
  286.           var %tag $deltok($deltok(%tag,2,35),2,38)
  287.           set $+(%,youtube.,%ticks,.tag) $remove(%tag,?,m.,v=,/watch?src_vid=,https://,http://,www.,/v/,youtube.com,youtu.be,youtu.be/,/watch?v=,/watch,?v=,$chr(31),#!,/)
  288.         }
  289.         inc %i
  290.       }
  291.       if ($($+(%,youtube.,%ticks,.tag),2) == $null) {
  292.         unset $+(%,youtube.,%ticks,.*)
  293.       }
  294.       else {
  295.         set $+(%,youtube.,%ticks,.msgtype) msg $active
  296.         set $+(%,youtube.,%ticks,.nick) $nick
  297.         set $+(%,youtube.,%ticks,.chan) $chan
  298.         set $+(%,youtube.,%ticks,.network) $network
  299.         sockopen $+(youtube.,%ticks) gdata.youtube.com 80
  300.       }
  301.     }
  302.   }
  303. }
  304.  
  305. on *:sockopen:ysearch*: {  
  306.   sockwrite -nt $sockname GET $+(/feeds/api/videos?q=,$($+(%,ysearch.,$remove($sockname,ysearch.),.query),2),&v=2&prettyprint=true&max-results=1) HTTP/1.1
  307.   sockwrite -nt $sockname Host: gdata.youtube.com
  308.   sockwrite -nt $sockname $crlf
  309. }
  310.  
  311. alias nohtml { return $regsubex($$1-,/^[^<]*>|<[^>]*>|<[^>]*$/g,) }
  312.  
  313. on *:SOCKREAD:ysearch*: {
  314.   if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
  315.   sockread %sockreader
  316.   if (*<title>* iswm %sockreader) {
  317.     set $+(%,ysearch.,$remove($sockname,ysearch.),.title) $replace($nohtml(%sockreader),&amp;quot;,",&amp;#39;,',&quot;,",&amp;,&,&#39;,',&quot;,")
  318.     var %i 0
  319.     while (%i <= $numtok($($+(%,ysearch.,$remove($sockname,ysearch.),.search),2),32)) {
  320.       inc %i
  321.       set $+(%,ysearch.,$remove($sockname,ysearch.),.title) $regsubex($($+(%,ysearch.,$remove($sockname,ysearch.),.title),2), /\b( $gettok($($+(%,ysearch.,$remove($sockname,ysearch.),.search),2),%i,32) )\b/gix, $+($chr(2), \1, $chr(2)))
  322.     }
  323.   }
  324.   elseif (*<id>* iswm %sockreader) {
  325.     set $+(%,ysearch.,$remove($sockname,ysearch.),.tag) $gettok($nohtml(%sockreader),4,58)
  326.   }
  327.   elseif (*<name>* iswm %sockreader) {
  328.     set $+(%,ysearch.,$remove($sockname,ysearch.),.user) $nohtml(%sockreader)
  329.   }
  330.   elseif (*<yt:duration seconds='* iswm %sockreader) {
  331.     var %t $duration($gettok(%sockreader,2,39),3)
  332.     if (($gettok(%t,2,58) == 00) && ($gettok(%t,1,58) == 00)) {
  333.       %t = $puttok(%t,0,2,58)
  334.     }
  335.     if (($left($gettok(%t,2,58),1) == 0) && ($right($gettok(%t,2,58),1) != 0) && ($right($gettok(%t,2,58),1) isnum)) {
  336.       if ($gettok(%t,1,58) == 00) {
  337.         %t = $puttok(%t,$right($gettok(%t,2,58),1),2,58)
  338.       }
  339.     }
  340.     if (($left($gettok(%t,1,58),1) == 0) && ($right($gettok(%t,1,58),1) != 0) && ($right($gettok(%t,1,58),1) isnum)) {
  341.       %t = $puttok(%t,$right($gettok(%t,1,58),1),1,58)
  342.     }
  343.     $iif($gettok(%t,1,58) == 00,%t = $gettok(%t,2-3,58),noop)
  344.     set $+(%,ysearch.,$remove($sockname,ysearch.),.time) %t
  345.   }
  346.   elseif (*<yt:statistics* iswm %sockreader) {
  347.     set $+(%,ysearch.,$remove($sockname,ysearch.),.viewcount) $bytes($gettok(%sockreader,4,39),bd)
  348.     var %msg 1,0You0,4Tube 10Link:4 http://youtu.be/ $+ $($+(%,ysearch.,$remove($sockname,ysearch.),.tag),2) $&
  349.       10Title:4 $($+(%,ysearch.,$remove($sockname,ysearch.),.title),2) $&
  350.       $iif(%_youtube.noviews == true,$null,10Views:4 $($+(%,ysearch.,$remove($sockname,ysearch.),.viewcount),2)) $&
  351.       $iif(%_youtube.nolength == true,$null,10Length:4 $($+(%,ysearch.,$remove($sockname,ysearch.),.time),2)) $&
  352.       $iif(%_youtube.nouser == true,$null,10User:4 $($+(%,ysearch.,$remove($sockname,ysearch.),.user),2))
  353.     $($+(%,ysearch.,$remove($sockname,ysearch.),.msgtype),2) $iif(%_youtube.nocolor == true,$strip(%msg),%msg)
  354.     unset $+(%,ysearch.,$remove($sockname,ysearch.),*)
  355.     sockclose $sockname
  356.   }
  357. }
  358.  
  359. #search end
  360.  
  361. #parse on
  362. on $*:text:/youtu(.be|be.com)/Si:*: {
  363.   $iif($istok(%youtubefetch,$chan,44),halt,noop)
  364.   $iif($istok(%nolinks,$nick,44),halt,noop)
  365.   if ($($+(%,botflood.,$nick),2)) {
  366.     if ($($+(%,botflood.,$nick),2) >= 50) {
  367.       ignore -u60 $address($nick,2)
  368.       msg $chan $+($nick,$chr(44)) You have been put on ignore for 60secs for abusing the bot.
  369.       halt
  370.     }
  371.     elseif ($($+(%,botflood.,$nick),2) >= 40) {
  372.       msg $chan $+($nick,$chr(44)) Please do not flood the bot.  
  373.       inc -z $+(%,botflood.,$nick) 20
  374.       halt
  375.     }
  376.     else {
  377.       inc -z $+(%,botflood.,$nick) 10
  378.     }
  379.   }
  380.   else { inc -z $+(%,botflood.,$nick) 10 }
  381.   var %i 1
  382.   var %ticks $ticks
  383.   while (%i <= $numtok($1-,32)) {
  384.     if ((*youtube.com* iswm $($+($,%i),2)) || (*youtu.be* iswm $($+($,%i),2))) {
  385.       set $+(%,youtube.,%ticks,.url) $strip($($+($,%i),2))
  386.       var %tag $($+(%,youtube.,%ticks,.url),2)
  387.       var %tag $iif($matchtok(%tag,v=,1,38),$v1,%tag)
  388.       var %tag $deltok($deltok(%tag,2,35),2,38)
  389.       set $+(%,youtube.,%ticks,.tag) $remove(%tag,?,m.,v=,/watch?src_vid=,https://,http://,www.,/v/,youtube.com,youtu.be,youtu.be/,/watch?v=,/watch,?v=,$chr(31),#!,/)
  390.     }
  391.     inc %i
  392.   }
  393.   set $+(%,youtube.,%ticks,.msgtype) msg $iif($chan,$v1,$nick)
  394.   if (($($+(%,youtube.,%ticks,.tag),2) != %_youtube.last) && ($($+(%,youtube.,%ticks,.tag),2) != $null)) {
  395.     set $+(%,youtube.,%ticks,.nick) $nick
  396.     set $+(%,youtube.,%ticks,.chan) $chan
  397.     set $+(%,youtube.,%ticks,.network) $network
  398.     sockopen $+(youtube.,%ticks) gdata.youtube.com 80
  399.   }
  400. }
  401.  
  402. on *:sockopen:youtube*: {
  403.   sockwrite -nt $sockname GET $+(/feeds/api/videos/,$($+(%,youtube.,$remove($sockname,youtube.),.tag),2),?v=2&prettyprint=true) HTTP/1.1
  404.   sockwrite -nt $sockname Host: gdata.youtube.com
  405.   sockwrite -nt $sockname $crlf
  406. }
  407.  
  408. on *:SOCKREAD:youtube*: {
  409.   if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
  410.   else {
  411.     var %sockreader
  412.     sockread %sockreader
  413.     if (*<title>* iswm %sockreader) {
  414.       set $+(%,youtube.,$remove($sockname,youtube.),.title) $replace($nohtml(%sockreader),&amp;quot;,",&amp;#39;,',&quot;,",&amp;,&,&#39;,',&quot;,")
  415.     }
  416.     elseif (*<name>* iswm %sockreader) {
  417.       set $+(%,youtube.,$remove($sockname,youtube.),.user) $nohtml(%sockreader)
  418.     }
  419.     elseif (*<yt:duration seconds='* iswm %sockreader) {
  420.       var %t $duration($gettok(%sockreader,2,39),3)
  421.       if (($gettok(%t,2,58) == 00) && ($gettok(%t,1,58) == 00)) {
  422.         %t = $puttok(%t,0,2,58)
  423.       }
  424.       if (($left($gettok(%t,2,58),1) == 0) && ($right($gettok(%t,2,58),1) != 0) && ($right($gettok(%t,2,58),1) isnum)) {
  425.         if ($gettok(%t,1,58) == 00) {
  426.           %t = $puttok(%t,$right($gettok(%t,2,58),1),2,58)
  427.         }
  428.       }
  429.       if (($left($gettok(%t,1,58),1) == 0) && ($right($gettok(%t,1,58),1) != 0) && ($right($gettok(%t,1,58),1) isnum)) {
  430.         %t = $puttok(%t,$right($gettok(%t,1,58),1),1,58)
  431.       }
  432.       $iif($gettok(%t,1,58) == 00,%t = $gettok(%t,2-3,58),noop)
  433.       set $+(%,youtube.,$remove($sockname,youtube.),.time) %t
  434.     }
  435.     elseif (*viewCount='* iswm %sockreader) {
  436.       set $+(%,youtube.,$remove($sockname,youtube.),.viewcount) $bytes($gettok(%sockreader,4,39),bd)
  437.       set %_youtube.last $($+(%,youtube.,$remove($sockname,youtube.),.tag),2)
  438.       var %msg 1,0You0,4Tube 10Title:4 $($+(%,youtube.,$remove($sockname,youtube.),.title),2) $&
  439.         $iif(%_youtube.noviews == true,$null,10Views:4 $($+(%,youtube.,$remove($sockname,youtube.),.viewcount),2)) $&
  440.         $iif(%_youtube.nolength == true,$null,10Length:4 $($+(%,youtube.,$remove($sockname,youtube.),.time),2)) $&
  441.         $iif(%_youtube.nouser == true,$null,10User:4 $($+(%,youtube.,$remove($sockname,youtube.),.user),2))
  442.       $($+(%,youtube.,$remove($sockname,youtube.),.msgtype),2) $iif(%_youtube.nocolor == true,$strip(%msg),%msg)
  443.       unset $+(%,youtube.,$remove($sockname,youtube.),*)
  444.       sockclose $sockname
  445.     }
  446.   }
  447. }
  448. #parse end
  449.  
  450. on *:sockclose:youtube*: {
  451.   unset $+(%,youtube.,$remove($sockname,youtube.),*)
  452.   sockclose $sockname
  453. }
  454.  
  455. on *:sockclose:ysearch*: {
  456.   unset $+(%,ysearch.,$remove($sockname,ysearch.),*)
  457.   sockclose $sockname
  458. }
  459.  
  460. on *:start: .timerYTUpdate 1 60 yupdate
  461.  
  462. alias yupdate {
  463.   echo -atc info 12[04YouTube12] Checking for updates...
  464.   sockopen yupdate www.hawkee.com 80
  465. }
  466.  
  467. on *:sockopen:yupdate: {  
  468.   sockwrite -nt $sockname GET /snippet/8577/ HTTP/1.1
  469.   sockwrite -nt $sockname Host: www.hawkee.com
  470.   sockwrite -nt $sockname $crlf
  471. }
  472.  
  473. on *:SOCKREAD:yupdate: {
  474.   if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
  475.   sockread %sockreader
  476.   if (*<title>* iswm %sockreader) {
  477.     var %x $gettok($nohtml(%sockreader),7,32)
  478.     echo -atc info 12[04YouTube12] Current: $yversion Latest: %x Status: $iif($yversion == %x,Up to date,Please update at www.hawkee.com/snippet/8577/)
  479.     unset %sockreader
  480.     sockclose $sockname
  481.   }
  482. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement