Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;YouTube Script (Parse Vids and Search) v4.4
- ;Made by nick1
- ;Last edit March 18 2012
- ;For help type /YouTube in mIRC
- ;2D0 -- Download videos in a few formats [[possible?]], anything else?
- ;EDITS -- Improved the searching speed and reliability by 340%, added a nick settings tab to dialog, added option to send without formatting, removed channel settings management via bot (only dialog now)
- menu status,channel,query {
- YouTube:youtube
- }
- alias YouTube {
- dialog -m YouTube YouTube
- }
- dialog Youtube {
- title "YouTube Script (Parse Vids and Search) v4.5"
- size -1 -1 226 138
- option dbu
- icon $mircdir $+ Youtube.ico, 0
- link "View Script On Hawkee -- Report Bugs Here", 1, 58 3 105 8
- button "Exit", 7, 77 125 72 12, cancel
- tab "About", 10, 0 11 225 110
- button "On", 15, 38 97 37 12, tab 10
- button "Off", 16, 148 97 37 12, tab 10
- text "This script was created by nick1 (Rizon Network)", 18, 2 26 116 8, tab 10
- text "Last updated on March 18, 2012", 19, 3 34 104 11, tab 10
- text "Please post suggestions, complaints, or bugs on the hawkee link (or in chat)", 20, 3 43 195 8, tab 10
- text "The script automatically will attempt to protect itself from spam", 21, 3 52 174 8, tab 10
- text "!commands will notice the user; @commands will be public to the channel", 13, 3 78 175 8, tab 10
- text "On/Off Buttons will Enable/Disable the entire script", 17, 48 111 125 7, tab 10
- text "By default the script will run on every channel. To disable for a channel use the Channel Settings tab. Nick Settings tab to disable for a certain nick. (useful for other bots)", 65, 3 61 217 15, tab 10
- link "Click here to chat (leave a message for nick1)", 66, 108 34 110 8, tab 10
- check "Do *NOT* Format (colorize//bold) the output (red and blue) (if checked is plain)", 67, 2 88 218 9, tab 10
- tab "Parse", 11
- button "On", 111, 38 97 37 12, tab 11
- button "Off", 9, 148 97 37 12, tab 11
- text "This part of the script will automatically find youtube links that other people post and message the channel with info about the video.", 22, 4 29 205 14, tab 11
- text "The script will return the following information: Title, Views, and User. ", 23, 22 54 174 10, tab 11
- text "There is automatic flood protection enabled so the script will not process the same link twice in a row", 24, 3 74 201 13, tab 11
- text "On/Off Buttons will Enable/Disable the parsing section of the script", 25, 32 110 162 7, tab 11
- tab "Search", 2
- button "On", 5, 38 97 37 12, tab 2
- button "Off", 14, 148 97 37 12, tab 2
- text "This part of the script will automatically find the most relevant YouTube video to the provided search terms.", 57, 3 26 207 13, tab 2
- text "The script will return the following information: Link, Title, Views, and User.", 58, 19 42 182 13, tab 2
- text "Commands may be prefixed with an ! or an @; with !commands private and @commands public to the channel.", 59, 3 56 201 13, tab 2
- box "Search Commands -- Prefix With ! or @ --", 60, 21 72 175 22, tab 2
- text "On/Off Buttons will Enable/Disable the search section of the script", 61, 32 109 159 7, tab 2
- text "ysearch <search terms>; ytsearch <search terms>;youtube <search terms>", 62, 31 79 156 13, tab 2
- tab "Channel Settings", 3
- list 6, 6 58 202 54, tab 3 sort size extsel vsbar
- edit "", 8, 7 28 155 25, tab 3 multi autohs autovs
- text "List of channels the script will NOT run on", 12, 46 52 101 6, tab 3
- button "Add", 4, 170 29 37 12, tab 3
- button "Remove", 63, 170 44 37 12, tab 3
- button "Click here to enter #channels ...", 64, 8 29 153 23, tab 3
- tab "Nick Settings", 26
- text "List of nicks the script will NOT run for", 70, 46 52 101 6, tab 26
- list 71, 6 58 202 54, tab 26 sort size extsel vsbar
- button "Remove", 72, 170 44 37 12, tab 26
- button "Add", 73, 170 29 37 12, tab 26
- edit "", 69, 7 28 155 25, tab 26 multi autohs autovs
- button "Click here to enter Nicks ...", 74, 8 29 153 23, tab 26
- tab "Just For Fun", 68
- text "See if you can check all the checkboxes! Warning: there might not be a reward.", 27, 23 54 144 17, tab 68
- check "Check Box", 44, 121 26 50 10, tab 68
- check "Check Box", 43, 128 34 50 10, tab 68
- check "Check Box", 53, 133 44 50 10, tab 68
- check "Check Box", 42, 126 60 50 10, tab 68
- check "Check Box", 51, 128 75 50 10, tab 68
- check "Check Box", 41, 110 69 50 10, tab 68
- check "Check Box", 35, 85 75 50 10, tab 68
- check "Check Box", 34, 74 84 50 10, tab 68
- check "Check Box", 39, 80 94 50 10, tab 68
- check "Check Box", 55, 88 100 50 10, tab 68
- check "Check Box", 38, 130 102 50 10, tab 68
- check "Check Box", 47, 129 92 50 10, tab 68
- check "Check Box", 37, 123 84 50 10, tab 68
- check "Check Box", 54, 46 101 50 10, tab 68
- check "Check Box", 49, 24 103 50 10, tab 68
- check "Check Box", 40, 27 95 50 10, tab 68
- check "Check Box", 56, 31 85 50 10, tab 68
- check "Check Box", 33, 16 82 50 10, tab 68
- check "Check Box", 48, 12 70 50 10, tab 68
- check "Check Box", 50, 37 71 50 10, tab 68
- check "Check Box", 52, 77 65 50 10, tab 68
- check "Check Box", 46, 79 43 50 10, tab 68
- check "Check Box", 36, 92 33 50 10, tab 68
- check "Check Box", 45, 45 39 50 10, tab 68
- check "Check Box", 31, 25 35 50 10, tab 68
- check "Check Box", 30, 40 27 50 10, tab 68
- check "Check Box", 28, 5 27 50 10, tab 68
- check "Check Box", 29, 6 37 50 10, tab 68
- check "Check Box", 32, 4 45 50 10, tab 68
- check "Check Box", 75, 150 78 50 10, tab 68
- check "Check Box", 76, 160 39 50 10, tab 68
- check "Check Box", 77, 168 26 50 10, tab 68
- check "Check Box", 78, 162 58 50 10, tab 68
- check "Check Box", 79, 163 88 50 10, tab 68
- check "Check Box", 80, 175 99 50 10, tab 68
- check "Check Box", 81, 145 107 50 10, tab 68
- check "Check Box", 82, 164 66 50 10, tab 68
- check "Check Box", 83, 171 75 50 10, tab 68
- check "Check Box", 84, 172 47 50 10, tab 68
- check "Check Box", 85, 166 34 50 10, tab 68
- check "Check Box", 86, 74 108 50 10, tab 68
- check "Check Box", 87, 4 91 50 10, tab 68
- }
- on *:dialog:youtube:init:0: {
- FillChannelBox
- FillNickBox
- if (%youtubenocolor == true) {
- did -c youtube 67
- }
- }
- alias FillChannelBox {
- did -r youtube 6
- var %y 1
- while (%y <= $numtok(%youtubefetch,44)) {
- did -a youtube 6 $gettok(%youtubefetch,%y,44)
- inc %y
- }
- }
- alias FillNickBox {
- did -r youtube 71
- var %y 1
- while (%y <= $numtok(%nolinks,44)) {
- did -a youtube 71 $gettok(%nolinks,%y,44)
- inc %y
- }
- }
- on *:dialog:youtube:sclick:*: {
- if ($did == 1) {
- run http://www.hawkee.com/snippet/8577/
- }
- elseif ($did == 66) {
- run https://qchat.rizon.net/?&channels=#rsbot_help&nick=YouTube..
- }
- elseif ($did == 67) {
- set %youtubenocolor $iif($did(67).state,true,false)
- }
- elseif ($did == 15) {
- enable #search
- enable #parse
- }
- elseif ($did == 16) {
- disable #search
- disable #parse
- }
- elseif ($did == 111) {
- enable #parse
- }
- elseif ($did == 9) {
- disable #parse
- }
- elseif ($did == 5) {
- enable #search
- }
- elseif ($did == 14) {
- disable #search
- }
- elseif ($did == 4) {
- set %youtubefetch $addtok(%youtubefetch,$iif(($left($did(8),1) == $chr(35)),$did(8),$+($chr(35),$did(8))),44)
- did -r youtube 8
- FillChannelBox
- }
- elseif ($did == 73) {
- set %nolinks $addtok(%nolinks,$did(69),44)
- did -r youtube 69
- FillNickBox
- }
- elseif ($did == 63) {
- if ($did(8) != $null) {
- set %youtubefetch $remtok(%youtubefetch,$iif(($left($did(8),1) == $chr(35)),$did(8),$+($chr(35),$did(8))),44)
- did -r youtube 8
- }
- if ($did(6).seltext != $null) {
- set %youtubefetch $remtok(%youtubefetch,$did(6).seltext,44)
- }
- FillChannelBox
- }
- elseif ($did == 3) {
- did -t youtube 4
- }
- elseif ($did == 26) {
- did -t youtube 73
- }
- elseif ($did == 72) {
- if ($did(69) != $null) {
- set %nolinks $remtok(%nolinks,$did(69),44)
- did -r youtube 69
- }
- if ($did(71).seltext != $null) {
- set %nolinks $remtok(%nolinks,$did(71).seltext,44)
- }
- FillNickBox
- }
- elseif ($did isnum 28-56) {
- var %r $r(1,2)
- if (%r == 1) {
- $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))
- }
- else {
- $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))
- }
- }
- elseif ($did isnum 75-87) {
- var %r $r(1,2)
- if (%r == 1) {
- $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))
- }
- else {
- $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))
- }
- }
- }
- raw 408:*: msg $2 $remove($strip($13-),$chr(9))
- alias urlencode {
- return $replacex($regsubex($$1-,/([^\w\s])/Sg,$+(%,$base($asc(\t),10,16,2))),$chr(32),+,$chr(43),%2B)
- }
- #search on
- on $*:text:/^[!@]y(outube|t|tsearch|search|ousearch|outubesearch)/Si:*: {
- $iif($istok(%youtubefetch,$chan,44),halt,noop)
- $iif($istok(%nolinks,$nick,44),halt,noop)
- if ($($+(%,botflood.,$nick),2)) {
- if ($($+(%,botflood.,$nick),2) >= 50) {
- ignore -u60 $address($nick,2)
- msg $chan $+($nick,$chr(44)) You have been put on ignore for 60secs for abusing the bot.
- halt
- }
- elseif ($($+(%,botflood.,$nick),2) >= 40) {
- msg $chan $+($nick,$chr(44)) Please do not flood the bot.
- inc -z $+(%,botflood.,$nick) 20
- halt
- }
- else {
- inc -z $+(%,botflood.,$nick) 25
- }
- }
- else {
- inc -z $+(%,botflood.,$nick) 25
- }
- var %ticks $ticks
- if ($2) {
- set $+(%,ysearch.,%ticks,.msgtype) $iif($chan,$iif($left($strip($1),1) == @,msg $chan,notice $nick),msg $nick)
- set $+(%,ysearch.,%ticks,.search) $2-
- set $+(%,ysearch.,%ticks,.search) $urlencode($2-)
- sockopen $+(ysearch.,%ticks) gdata.youtube.com 80
- }
- elseif ($2 == $null) {
- notice $nick 4Incorrect Syntax - Use10 $1 <search term>
- }
- }
- on *:input:*:{
- $iif($istok(%nolinks,$active,44),return,noop)
- $iif($istok(%youtubefetch,$active,44),return,noop)
- var %ticks $ticks
- 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)) {
- if ($left($1,1) != /) {
- if ($2 != $null) {
- set $+(%,ysearch.,%ticks,.msgtype) msg $active
- set $+(%,ysearch.,%ticks,.search) $2-
- set $+(%,ysearch.,%ticks,.query) $urlencode($2-)
- sockopen $+(ysearch.,%ticks) gdata.youtube.com 80
- }
- elseif ($2 == $null) {
- .timerYTInputSyntax -m 1 100 echo -at 4Incorrect Syntax - Use10 $1 <search term>
- }
- }
- }
- elseif ((*youtube.com* iswm $1-) || (*youtu.be* iswm $1-)) {
- if ($left($1,1) != /) {
- var %i 1
- while (%i <= $numtok($1-,32)) {
- if ((*youtube.com* iswm $($+($,%i),2)) || (*youtu.be* iswm $($+($,%i),2))) {
- set $+(%,youtube.,%ticks,.url) $strip($($+($,%i),2))
- var %tag $($+(%,youtube.,%ticks,.url),2)
- var %tag $iif($matchtok(%tag,v=,1,38),$v1,%tag)
- var %tag $deltok($deltok(%tag,2,35),2,38)
- 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),#!,/)
- }
- inc %i
- }
- if ($($+(%,youtube.,%ticks,.tag),2) == $null) {
- unset $+(%,youtube.,%ticks,.*)
- }
- else {
- set $+(%,youtube.,%ticks,.msgtype) msg $active
- set $+(%,youtube.,%ticks,.nick) $nick
- set $+(%,youtube.,%ticks,.chan) $chan
- set $+(%,youtube.,%ticks,.network) $network
- sockopen $+(youtube.,%ticks) gdata.youtube.com 80
- }
- }
- }
- }
- on *:sockopen:ysearch*: {
- sockwrite -nt $sockname GET $+(/feeds/api/videos?q=,$($+(%,ysearch.,$remove($sockname,ysearch.),.query),2),&v=2&prettyprint=true&max-results=1) HTTP/1.1
- sockwrite -nt $sockname Host: gdata.youtube.com
- sockwrite -nt $sockname $crlf
- }
- alias nohtml { return $regsubex($$1-,/^[^<]*>|<[^>]*>|<[^>]*$/g,) }
- on *:SOCKREAD:ysearch*: {
- if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
- sockread %sockreader
- if (*<title>* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.title) $replace($nohtml(%sockreader),&quot;,",&#39;,',",",&,&,',',",")
- var %i 0
- while (%i <= $numtok($($+(%,ysearch.,$remove($sockname,ysearch.),.search),2),32)) {
- inc %i
- 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)))
- }
- }
- elseif (*<id>* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.tag) $gettok($nohtml(%sockreader),4,58)
- }
- elseif (*<name>* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.user) $nohtml(%sockreader)
- }
- elseif (*<yt:statistics* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.viewcount) $bytes($gettok(%sockreader,4,39),bd)
- var %msg 1,0You0,4Tube 10Link:4 http://youtu.be/ $+ $($+(%,ysearch.,$remove($sockname,ysearch.),.tag),2) 10Title:4 $($+(%,ysearch.,$remove($sockname,ysearch.),.title),2) 10Views:4 $($+(%,ysearch.,$remove($sockname,ysearch.),.viewcount),2) 10User:4 $($+(%,ysearch.,$remove($sockname,ysearch.),.user),2)
- $($+(%,ysearch.,$remove($sockname,ysearch.),.msgtype),2) $iif(%youtubenocolor == true,$strip(%msg),%msg)
- unset $+(%,ysearch.,$remove($sockname,ysearch.),*)
- sockclose $sockname
- }
- }
- #search end
- #parse on
- on $*:text:/youtu(.be|be.com)/Si:*: {
- $iif($istok(%youtubefetch,$chan,44),halt,noop)
- $iif($istok(%nolinks,$nick,44),halt,noop)
- if ($($+(%,botflood.,$nick),2)) {
- if ($($+(%,botflood.,$nick),2) >= 50) {
- ignore -u60 $address($nick,2)
- msg $chan $+($nick,$chr(44)) You have been put on ignore for 60secs for abusing the bot.
- halt
- }
- elseif ($($+(%,botflood.,$nick),2) >= 40) {
- msg $chan $+($nick,$chr(44)) Please do not flood the bot.
- inc -z $+(%,botflood.,$nick) 20
- halt
- }
- else {
- inc -z $+(%,botflood.,$nick) 10
- }
- }
- else { inc -z $+(%,botflood.,$nick) 10 }
- var %i 1
- var %ticks $ticks
- while (%i <= $numtok($1-,32)) {
- if ((*youtube.com* iswm $($+($,%i),2)) || (*youtu.be* iswm $($+($,%i),2))) {
- set $+(%,youtube.,%ticks,.url) $strip($($+($,%i),2))
- var %tag $($+(%,youtube.,%ticks,.url),2)
- var %tag $iif($matchtok(%tag,v=,1,38),$v1,%tag)
- var %tag $deltok($deltok(%tag,2,35),2,38)
- 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),#!,/)
- }
- inc %i
- }
- set $+(%,youtube.,%ticks,.msgtype) msg $iif($chan,$v1,$nick)
- if (($($+(%,youtube.,%ticks,.tag),2) != %_youtube.last) && ($($+(%,youtube.,%ticks,.tag),2) != $null)) {
- set $+(%,youtube.,%ticks,.nick) $nick
- set $+(%,youtube.,%ticks,.chan) $chan
- set $+(%,youtube.,%ticks,.network) $network
- sockopen $+(youtube.,%ticks) gdata.youtube.com 80
- }
- }
- on *:sockopen:youtube*: {
- sockwrite -nt $sockname GET $+(/feeds/api/videos/,$($+(%,youtube.,$remove($sockname,youtube.),.tag),2),?v=2&prettyprint=true) HTTP/1.1
- sockwrite -nt $sockname Host: gdata.youtube.com
- sockwrite -nt $sockname $crlf
- }
- on *:SOCKREAD:youtube*: {
- if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
- else {
- var %sockreader
- sockread %sockreader
- if (*<title>* iswm %sockreader) {
- set $+(%,youtube.,$remove($sockname,youtube.),.title) $replace($nohtml(%sockreader),&quot;,",&#39;,',",",&,&,',',",")
- }
- elseif (*<name>* iswm %sockreader) {
- set $+(%,youtube.,$remove($sockname,youtube.),.user) $nohtml(%sockreader)
- }
- elseif (*viewCount='* iswm %sockreader) {
- set $+(%,youtube.,$remove($sockname,youtube.),.viewcount) $bytes($gettok(%sockreader,4,39),bd)
- set %_youtube.last $($+(%,youtube.,$remove($sockname,youtube.),.tag),2)
- var %msg 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)
- $($+(%,youtube.,$remove($sockname,youtube.),.msgtype),2) $iif(%youtubenocolor == true,$strip(%msg),%msg)
- unset $+(%,youtube.,$remove($sockname,youtube.),*)
- sockclose $sockname
- }
- }
- }
- #parse end
- on *:sockclose:youtube*: {
- unset $+(%,youtube.,$remove($sockname,youtube.),*)
- sockclose $sockname
- }
- on *:sockclose:ysearch*: {
- unset $+(%,ysearch.,$remove($sockname,ysearch.),*)
- sockclose $sockname
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement