Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;YouTube Script (Parse Vids and Search) v3.8
- ;Made by nick1
- ;Last edit December 31 2011
- ;For help type /YouTube in mIRC
- ;2D0 -- Download videos in a few formats [[possible?]], anything else?
- ;EDITS -- Dialog update to remove channels by clicking on channel then click remove
- menu status,channel,query {
- YouTube:youtube
- }
- alias YouTube {
- dialog -m YouTube YouTube
- }
- dialog Youtube {
- title "YouTube Script (Parse Vids and Search) v3.8"
- size -1 -1 187 132
- option dbu
- icon $mircdir $+ Youtube.ico, 0
- link "View Script On Hawkee -- Report Bugs Here", 1, 39 2 105 8
- button "Exit", 7, 54 120 72 12, cancel
- tab "About", 10, 1 9 183 106
- button "On", 15, 20 98 37 12, tab 10
- button "Off", 16, 120 98 37 12, tab 10
- text "This script was created by nick1 (Rizon Network)", 18, 2 24 116 8, tab 10
- text "Last updated on September 28, 2011", 19, 2 32 104 11, tab 10
- text "Please post suggestions, complaints, or bugs on the hawkee link", 20, 2 41 167 8, tab 10
- text "The script automatically will attempt to protect itself from spam", 21, 2 50 174 8, tab 10
- text "!commands will notice the user; @commands will be public to the channel", 13, 2 79 175 8, tab 10
- text "On/Off Buttons will Enable/Disable the entire script", 17, 26 90 135 7, tab 10
- text "By default the script will run on every channel. To disable for a channel use the Channel Settings tab.", 65, 2 59 176 21, tab 10
- link "Chat Here", 66, 120 24 30 8, tab 10
- tab "Parse", 11
- button "On", 111, 20 98 37 12, tab 11
- button "Off", 9, 120 98 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, 3 26 177 14, tab 11
- text "The script will return the following information: Title, Views, and User. ", 23, 3 43 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 56 179 13, tab 11
- text "On/Off Buttons will Enable/Disable the parsing section of the script", 25, 8 90 162 7, tab 11
- tab "Search", 2
- button "On", 5, 20 98 37 12, tab 2
- button "Off", 14, 120 98 37 12, tab 2
- text "This part of the script will automatically find the most relevant YouTube video to the provided search terms.", 57, 4 24 174 13, tab 2
- text "The script will return the following information: Link, Title, Length, Views, and User.", 58, 4 40 176 13, tab 2
- text "Commands may be prefixed with an ! or an @; with !commands private and @commands public to the channel.", 59, 4 54 176 13, tab 2
- box "Search Commands -- Prefix With ! or @ --", 60, 4 68 175 22, tab 2
- text "On/Off Buttons will Enable/Disable the search section of the script", 61, 8 90 159 7, tab 2
- text "ysearch <search terms>; ytsearch <search terms>;youtube <search terms>", 62, 15 75 156 14, tab 2
- tab "Channel Settings", 3
- list 6, 7 56 168 54, tab 3 sort size extsel hsbar vsbar
- edit "", 8, 4 24 140 25, tab 3 multi return autohs autovs
- text "List of channels the script will NOT run on", 12, 27 49 101 7, tab 3
- button "Add", 4, 145 25 37 12, tab 3
- button "Remove", 63, 145 38 37 12, tab 3
- button "Click here to enter #channels ...", 64, 5 25 138 23, tab 3
- tab "Just For Fun", 26
- text "See if you can check all the checkboxes! Warning: there might not be a reward.", 27, 22 50 144 17, tab 26
- check "Check Box", 28, 4 23 50 10, tab 26
- check "Check Box", 29, 5 33 50 10, tab 26
- check "Check Box", 30, 39 23 50 10, tab 26
- check "Check Box", 31, 24 31 50 10, tab 26
- check "Check Box", 32, 3 41 50 10, tab 26
- check "Check Box", 33, 15 78 50 10, tab 26
- check "Check Box", 34, 73 80 50 10, tab 26
- check "Check Box", 35, 84 71 50 10, tab 26
- check "Check Box", 36, 91 29 50 10, tab 26
- check "Check Box", 37, 122 80 50 10, tab 26
- check "Check Box", 38, 129 98 50 10, tab 26
- check "Check Box", 39, 79 90 50 10, tab 26
- check "Check Box", 40, 26 91 50 10, tab 26
- check "Check Box", 41, 109 65 50 10, tab 26
- check "Check Box", 42, 125 56 50 10, tab 26
- check "Check Box", 43, 127 30 50 10, tab 26
- check "Check Box", 44, 120 22 50 10, tab 26
- check "Check Box", 45, 44 35 50 10, tab 26
- check "Check Box", 46, 78 39 50 10, tab 26
- check "Check Box", 47, 128 88 50 10, tab 26
- check "Check Box", 48, 11 66 50 10, tab 26
- check "Check Box", 49, 23 99 50 10, tab 26
- check "Check Box", 50, 36 67 50 10, tab 26
- check "Check Box", 51, 127 71 50 10, tab 26
- check "Check Box", 52, 76 61 50 10, tab 26
- check "Check Box", 53, 132 40 50 10, tab 26
- check "Check Box", 54, 45 97 50 10, tab 26
- check "Check Box", 55, 87 96 50 10, tab 26
- check "Check Box", 56, 30 81 50 10, tab 26
- }
- on *:dialog:youtube:init:0: {
- FillChannelBox
- }
- alias FillChannelBox {
- did -r youtube 6
- var %y 1
- while (%y <= $numtok(%youtubefetch,44)) {
- did -a youtube 6 $gettok(%youtubefetch,%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 == 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 == 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 isnum 28-56) {
- $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))
- #search on
- on $*:text:/^[!@]y(outube|t|tsearch|search|ousearch|outubesearch)/Si:*: {
- $iif($istok(%youtubefetch,$chan,44),halt,noop)
- if ($($+(%,botflood.,$nick),2)) {
- 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
- }
- elseif ($($+(%,botflood.,$nick),2) >= 40) {
- msg $chan $+($nick,$chr(44)) Please Do Not Abuse 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) $replace($2-,$chr(32),+)
- sockopen $+(ysearch.,%ticks) youtube.com 80
- }
- elseif ($2 == $null) {
- msg $nick 4Incorrect Syntax - Use10 $1 <search term>
- }
- }
- on *:input:*:{
- 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) $replace($2-,$chr(32),+)
- sockopen $+(ysearch.,$ticks) 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) $($+($,%i),2)
- set $+(%,youtube.,$ticks,.tag) $remove($strip($($+($,%i),2)),feature=player_embedded&,http://,www.,/v/,youtube.com,youtu.be/,/watch?v=,/watch,?v=,$chr(31),&feature=feedu,#!)
- }
- inc %i
- }
- set $+(%,youtube.,$ticks,.msgtype) msg $active
- set $+(%,youtube.,$ticks,.nick) $nick
- set $+(%,youtube.,$ticks,.chan) $chan
- set $+(%,youtube.,$ticks,.network) $network
- sockopen $+(youtube.,$ticks) youtube.com 80
- }
- }
- elseif (($1 == !youtubelinks) || ($1 == !youtubefetch)) {
- set %youtubefetch $remtok(%youtubefetch,$iif(($2),$2,$chan),44)
- echo -ac info I will message $iif(($2),$2,$chan) with youtube info...
- }
- elseif (($1 == !noyoutubelinks) || ($1 == !noyoutubefetch)) {
- set %youtubefetch $addtok(%youtubefetch,$iif(($2),$2,$chan),44)
- echo -ac info I won't message $iif(($2),$2,$chan) with youtube info...
- }
- }
- on *:sockopen:ysearch*: {
- sockwrite -nt $sockname GET $+(/results?search_query=,$($+(%,ysearch.,$remove($sockname,ysearch.),.search),2)) HTTP/1.1
- sockwrite -nt $sockname Host: www.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 (*<h3>* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.title) $iif($nohtml($replace($remove(%sockreader,|),<b>,,</b>,,",",',',&,&)) != $null,$nohtml($replace($remove(%sockreader,|),<b>,,</b>,,",",',',&,&)),&N0T1TLE&)
- tokenize 34 %sockreader
- set $+(%,ysearch.,$remove($sockname,ysearch.),.tag) $remove($2,/watch?v=)
- tokenize 38 $($+(%,ysearch.,$remove($sockname,ysearch.),.tag),2)
- set $+(%,ysearch.,$remove($sockname,ysearch.),.tag) $1
- }
- elseif ($($+(%,ysearch.,$remove($sockname,ysearch.),.title),2) === &N0T1TLE&) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.title) !*NOTITLE*!
- }
- elseif ($($+(%,ysearch.,$remove($sockname,ysearch.),.title),2) === !*NOTITLE*!) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.title) $nohtml($replace($remove(%sockreader,|),<b>,,</b>,,",",',',&,&))
- }
- elseif (*</div><h3* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.title) $regsubex($nohtml($replace($remove(%sockreader,|),<b>,,</b>,,",",',',&,&)),/&#(\d\d?\d?\d?);/g,$chr(\1))
- tokenize 34 %sockreader
- set $+(%,ysearch.,$remove($sockname,ysearch.),.tag) $remove($4,/watch?v=)
- tokenize 38 $($+(%,ysearch.,$remove($sockname,ysearch.),.tag),2)
- set $+(%,ysearch.,$remove($sockname,ysearch.),.tag) $1
- }
- elseif (*<span class="video-time">* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.time) $nohtml($remove(%sockreader,Add to,Added,to,queue,hozzáadás))
- }
- elseif (*<span class="username-prepend">* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.user) $remove($nohtml(%sockreader),by)
- }
- elseif (*<span class="viewcount">* iswm %sockreader) {
- set $+(%,ysearch.,$remove($sockname,ysearch.),.viewcount) $remove($nohtml(%sockreader),|,views,megtekintés)
- $($+(%,ysearch.,$remove($sockname,ysearch.),.msgtype),2) 1,0You0,4Tube 10Link:4 http://youtu.be/ $+ $($+(%,ysearch.,$remove($sockname,ysearch.),.tag),2) 10Title:4 $iif($($+(%,ysearch.,$remove($sockname,ysearch.),.msgtype),2) == msg #rsbot,$lower($($+(%,ysearch.,$remove($sockname,ysearch.),.title),2)),$($+(%,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)
- 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,0) | 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 Abuse 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) $($+($,%i),2)
- set $+(%,youtube.,%ticks,.tag) $remove($strip($($+($,%i),2)),feature=player_embedded&,http://,/v/,www,$chr(46),youtube,com,youtu,be,/,watch?v=,$chr(31),&feature=feedu,#!)
- }
- inc %i
- }
- if (!$istok(%youtubefetch,$chan,44)) {
- set $+(%,youtube.,%ticks,.msgtype) msg $iif($chan,$v1,$nick)
- }
- elseif ($istok(%youtubefetch,$chan,44)) {
- halt
- }
- 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) youtube.com 80
- }
- }
- on *:sockopen:youtube*: {
- sockwrite -nt $sockname GET $+(/,watch?v=,$($+(%,youtube.,$remove($sockname,youtube.),.tag),2)) HTTP/1.1
- sockwrite -nt $sockname Host: www.youtube.com
- sockwrite -nt $sockname $crlf
- }
- on *:SOCKREAD:youtube*: {
- if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
- else {
- var %sockreader
- sockread %sockreader
- if (*Location: http://www.youtube.com/verify_age?next_url=* iswm %sockreader) {
- if ($($+(%,youtube.,$remove($sockname,youtube.),.msgtype),2) != echo -a) {
- $($+(%,youtube.,$remove($sockname,youtube.),.msgtype),2) 1,0You0,4Tube 10This content may contain material flagged by YouTube's user community that may be inappropriate for some users.
- halt
- }
- set %_youtube.last $($+(%,youtube.,$remove($sockname,youtube.),.tag),2)
- unset $+(%,youtube.,$remove($sockname,youtube.),*)
- sockclose youtube
- halt
- }
- elseif (*<meta name="title"* iswm %sockreader) {
- tokenize 32 %sockreader
- set $+(%,youtube.,$remove($sockname,youtube.),.title) $replace($remove(%sockreader,<meta name="title" content=",">),&quot;,",&#39;,',",",&,&,',')
- }
- elseif ((*<h3><a href="* iswm %sockreader) && ($($+(%,youtube.,$remove($sockname,youtube.),.title),2) == $null)) {
- set $+(%,youtube.,$remove($sockname,youtube.),.title) $nohtml(%sockreader)
- }
- elseif (*<span class="watch-view-count">* iswm %sockreader) {
- set $+(%,youtube.,$remove($sockname,youtube.),.viewcheck) on
- }
- elseif (*<a id="watch-userbanner" class="inline-block" rel="author" href="/user/* iswm %sockreader) {
- tokenize 34 %sockreader
- set $+(%,youtube.,$remove($sockname,youtube.),.user) $10
- }
- elseif ((*<strong>* iswm %sockreader) && ($($+(%,youtube.,$remove($sockname,youtube.),.viewcheck),2) == on)) {
- set $+(%,youtube.,$remove($sockname,youtube.),.viewcount) $nohtml(%sockreader)
- unset $+(%,youtube.,$remove($sockname,youtube.),.viewcheck)
- }
- elseif (*class="yt-user-name author"* iswm %sockreader) {
- tokenize 34 %sockreader
- set $+(%,youtube.,$remove($sockname,youtube.),.user) $remove($2,/user/)
- 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)
- }
- elseif ($($+(%,youtube.,$remove($sockname,youtube.),.msgtype),2) != echo -a) {
- $($+(%,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)
- }
- set %_youtube.last $($+(%,youtube.,$remove($sockname,youtube.),.tag),2)
- unset $+(%,youtube.,$remove($sockname,youtube.),*)
- sockclose $sockname
- }
- }
- }
- #parse end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement