Snippets Project Page
Author: entropy
Added: 6y
Updated: 44w
mIRC: 7.56+
Hits: 6,727
Downloads: 360
Review: entropy
Size: 10.12KB
4 1
Login to vote.
YouTube
v5.8
This snippet looks up YouTube urls and also searches for matching videos.
Paste a YouTube link in any channel (or channels specified).
Type: !yt <search> or !youtube <search> to search for youtube videos.
You need a valid API key to use the search!
Download
JSON
▲ Review
▲ Log
▼ Source
; YouTube v5.8 - by entropy 2023 ; Get a API Key here: https://developers.google.com/youtube/v3/getting-started ; ============================ YouTube Menus menu menubar,status,channel,query { - YouTube v5.8 $chr(9) $replace($group(#youtube).status,o,O) .Turn it $iif($group(#youtube).status == on,Off,On) { $iif($group(#youtube).status == on,.disable,.enable) #youtube echo 4 -ag * YouTube is now: $qt($replace($group(#youtube).status,o,O)) } .- .Channel(s) $chr(9) $eval($+(%,youtubechans,.,$network),2) { var %net = $eval($+(%,youtubechans,.,$network),2) var %text = $input(Channels list (seperated by comma) or "#" for all?,5,YouTube,%net) %text = $replace(%text,$chr(32),$chr(44)) var %a = 1, %b while ($gettok(%text,%a,44)) { %b = $v1 if ($left(%b,1) != $chr(35)) { %text = $reptok(%text,%b,$+($chr(35),%b),1,44) } inc %a } if (%text) { set $+(%,youtubechans,.,$network) $v1 | echo 4 -ag * YouTube Channels are now: $qt($v1) } else { unset $+(%,youtubechans,.,$network) | echo 4 -ag * YouTube Channels are now reset } } .$iif(!$istok($eval($+(%,youtubechans,.,$network),2),$chan,44) && $eval($+(%,youtubechans,.,$network),2) != $chr(35) && $menu == channel,Add Channel To list) { var %net = $eval($+(%,youtubechans,.,$network),2) %net = $addtok(%net,$chan,44) set $+(%,youtubechans,.,$network) %net echo 4 -ag * YouTube channels are now: $qt(%net) } .$iif($istok($eval($+(%,youtubechans,.,$network),2),$chan,44) && $menu == channel,Delete Channel From list) { var %net = $eval($+(%,youtubechans,.,$network),2) %net = $remtok(%net,$chan,1,44) set $+(%,youtubechans,.,$network) %net echo 4 -ag * YouTube channels are now $+ $iif(!%net,$chr(32) reset,: $qt(%net)) } .$iif($eval($+(%,youtubechans,.,$network),2),Delete all Channels) { unset $+(%,youtubechans,.,$network) echo 4 -ag * YouTube channels are now reset } .- .API Key $chr(9) %yt_key { var %a = $input(Input API Key?,5) if ($! != $null) { %yt_key = $! echo 4 -ag * YouTube key is now: $qt(%yt_key) } } .- .Get an API key { run https://developers.google.com/youtube/v3/getting-started } - } ; ============================ on *:unload:{ echo 4 -ag * YouTube is now unloaded! | unset %youtubechans.* %yt_key } on *:load:{ echo 4 -ag * YouTube is now loaded! } ; ============================ #youtube on on *:text:*:$($eval($+(%,youtubechans,.,$network),2)):{ doyoutube $1- } on *:input:$($eval($+(%,youtubechans,.,$network),2)):{ if (/* !iswm $1 && $server) { doyoutube $1- } } #youtube end alias -l doyoutube { if (!youtube == $1 || !yt == $1) { if ($2 == $null) { return } elseif (%yt_key) { set %_youtubechan # apiYT $+(https://www.googleapis.com/youtube/v3/search?part=snippet&q=,$replace($2-,$chr(32),+),&key=,%yt_key) } } else { var %outputx if (*https://*youtube.com/watch?v=* iswm $1-) { %outputx = $wildtok($1-,https://*youtube.com/watch?v=*,1,32) } elseif (*https://youtu.be/* iswm $1-) { %outputx = $wildtok($1-,https://youtu.be/*,1,32) } elseif (*www.youtube.com/watch?v=* iswm $1-) { %outputx = $wildtok($1-,www.youtube.com/watch?v=*,1,32) } if (%outputx) { set %_youtubechan # grabYT %outputx } } } ;=========================== YouTube Search alias -l apiYT { noop $urlget($1-,gbi,&YouTube,processYTapi) } alias -l processYTapi { var %id = $1 , %BV = $urlget(%id).target, %code = $gettok($urlget(%id).reply,2,32) if (%code == 400) { msg %_youtubechan [YouTube] $c Bad API Key! | unset %_you* | return } elseif (%code != 200) { msg %_youtubechan [YouTube] $c Error code: %code | unset %_you* | return } var %title = $replacehtmlentities($remove($gettok($bvsearch(%BV,"title":,$chr(44)),2-,32),",$chr(44))), %total = [YouTube Search] $c %total = %total Title: %title %total = %total $c Link: $+(https://www.youtube.com/watch?v=,$remove($gettok($bvsearch(%BV,"videoId":,$chr(44)),2,32),")) if (%title) { msg %_youtubechan %total } else { msg %_youtubechan [YouTube Search] $c Nothing found! } unset %_you* } ;=========================== YouTube Link alias -l grabYT { noop $urlget($1-,gbi,&YouTube,processYT) } alias -l processYT { var %id = $1 , %BV = $urlget(%id).target var %a = $bvsearch(%BV,<title>,</title>).inbetween if (%a == - YouTube) { msg %_youtubechan [YouTube] $c Nothing found! | unset %_you* | return } var %total = [YouTube] %total = %total $c Title: $replacehtmlentities($remove($bvsearch(%BV,<title>,</title>).inbetween,- YouTube)) %total = %total $c Video Size: $bvsearch(%BV,<meta property="og:video:width" content=",">).inbetween $+ x $+ $bvsearch(%BV,<meta property="og:video:height" content=",">).inbetween var %a = $bvsearch(%BV,<meta itemprop="uploadDate" content=",">).inbetween, %year = $gettok(%a,1,45), %month = $gettok(%a,2,45), %day = $gettok($gettok(%a,3,45),1,84), %time = $+($chr(40),$gettok($gettok(%a,3,45),2,84),$chr(41)) %total = %total $c Uploaded: $+(%month,/,%day,/,%year) %time %total = %total $c Genre: $bvsearch(%BV,<meta itemprop="genre" content=",">).inbetween %total = %total $c Views: $remove($bvsearch(%BV,"viewCount":{"simpleText":","}).inbetween,views) %total = %total $c Length: $duration($bvsearch(%BV,"lengthSeconds":",34 44).inbetween,3) var %likes = $bvsearch(%BV,"accessibility":{"label":"like this video along with,other people").inbetween if (%likes) { %total = %total $c Likes: %likes } %total = %total $c Uploaded By: $bvsearch(%BV,<link itemprop="name" content=",">).inbetween msg %_youtubechan $replacehtmlentities(%total) unset %_you* } ;=========================== YouTube Aliases alias -l bvsearch { var %S = $bfind($1,1,$2) var %E = $bfind($1,$calc(%S + $len($2)),$3) if (%S <= 0 || %E <= 0) { return } if ($prop == inbetween) { var %S = %S + $len($2) , %E = %E - 1 } else { var %E = %E + $iif($regex($3,/(?:\d+|\s)/g),$numtok($3,32),$len($3)) | dec %e } return $left( $bvar($1,$+(%S,-,%E)).text , $maxlenl) } alias -l replacehtmlentities { return $regsubex($1-,/(\x26[^\x3B]+)\x3B/g,$entitieshtml(\1)) } alias -l entitieshtml { if ($mid($1,2,1) == $chr(35)) { return $chr($mid($1,3)) } elseif ($findtok(&<>ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶¸¹º»¼½¾¿×÷∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖŒœŠšŸƒˆ˜   ‌‍‎‏–—‘’‚“”„†‡•…‰′″‹›‾€™←↑→↓↔↵⌈⌉⌊⌋◊♠♣♥&diams,$1,59)) { return $chr($gettok(38;60;62;192;193;194;195;196;197;198;199;200;201;202;203;204;205;206;207;208;209;210;211;212;213;214;216;217;218;219;220;221;222;223;224;225;226;227;228;229;230;231;232;233;234;235;236;237;238;239;240;241;242;243;244;245;246;248;249;250;251;252;253;254;255;160;161;162;163;164;165;166;167;168;169;170;171;172;173;174;175;176;177;178;179;180;181;182;184;185;186;187;188;189;190;191;215;247;8704;8706;8707;8709;8711;8712;8713;8715;8719;8721;8722;8727;8730;8733;8734;8736;8743;8744;8745;8746;8747;8756;8764;8773;8776;8800;8801;8804;8805;8834;8835;8836;8838;8839;8853;8855;8869;8901;913;914;915;916;917;918;919;920;921;922;923;924;925;926;927;928;929;931;932;933;934;935;936;937;945;946;947;948;949;950;951;952;953;954;955;956;957;958;959;960;961;962;963;964;965;966;967;968;969;977;978;982;338;339;352;353;376;402;710;732;8194;8195;8201;8204;8205;8206;8207;8211;8212;8216;8217;8218;8220;8221;8222;8224;8225;8226;8230;8240;8242;8243;8249;8250;8254;8364;8482;8592;8593;8594;8595;8596;8629;8968;8969;8970;8971;9674;9824;9827;9829;9830,$v1,59)) } } alias -l c { return $chr(9679) }
Changelog:
- v5.8 (6/22/23)
Added www lookup.
- v5.7 (5/27/23)
Added multi network support.
- v5.6 (5/7/23)
Made it work a lot better.
- v5.5 (11/19/21)
added a more accurate lookup.
- v5.4 (11/12/21)
fixed it to work with more URLs.. Also added "Uploaded By".
- v5.3 (9/25/21)
fixed the socket not working.
- v5.2 (12/29/20)
fixed the youtube search key not working.
- v5.1 (12/29/20)
Tweaked it to work on almost all URL's.
Also fixed "length" not showing the proper length.
- v5.0 (12/22/20)
The old version stopped working... Now it works.
- v4.5 (7/16/20)
Fixed misc things and added a inappropriate check (required for all to work).
- v4.4 (7/10/20)
Fixed misc errors and the youtube site changed, so i had to redo it
- v4.3 (2/23/20)
Fixed a typo
- v4.2 (2/23/20)
Changed non working search bug to API lookup
- v5.8 (6/22/23)
Added www lookup.
- v5.7 (5/27/23)
Added multi network support.
- v5.6 (5/7/23)
Made it work a lot better.
- v5.5 (11/19/21)
added a more accurate lookup.
- v5.4 (11/12/21)
fixed it to work with more URLs.. Also added "Uploaded By".
- v5.3 (9/25/21)
fixed the socket not working.
- v5.2 (12/29/20)
fixed the youtube search key not working.
- v5.1 (12/29/20)
Tweaked it to work on almost all URL's.
Also fixed "length" not showing the proper length.
- v5.0 (12/22/20)
The old version stopped working... Now it works.
- v4.5 (7/16/20)
Fixed misc things and added a inappropriate check (required for all to work).
- v4.4 (7/10/20)
Fixed misc errors and the youtube site changed, so i had to redo it
- v4.3 (2/23/20)
Fixed a typo
- v4.2 (2/23/20)
Changed non working search bug to API lookup
Review: entropy
Very handy!
You paste a youtube link, and it defines it on channel.
For searching, use: !yt <search>
Very handy!
You paste a youtube link, and it defines it on channel.
For searching, use: !yt <search>