Youtube url detector for mIRC

By FordLawnmower on Jul 14, 2011

  • Requested by H0LLYWOOD
    Remote script for a bot that will resolve valid Youtube links and return the title and some other information about the video to channels the script is turned on for.
    SCREEN:
    Image

Usage:

  • Copy this code, paste it to a new remote and save with a unique filename.
  • Type +ytdetect in each channel you want the script to run in.(Requires Ops or higher)
  • -ytdetect to turn the script off for a channel.
;YouTube Link detector by Ford_Lawnmower irc.Geekshed.net #Script-Help
alias -l GetLinkDetectorForYoutube {
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;; Change %tagcolor to the color you want for tags:
  var %tagcolor $+($chr(15),$chr(2))
  ;;;; Change %textcolor to the color you want for normal text
  var %textcolor $+($chr(15),$chr(3),04)
  ;;;; Change %logo to change the YouTube logo
  var %logo $+($chr(2),$chr(3),01,$chr(44),00You,$chr(3),00,$chr(44),04Tube,$chr(2),$chr(15))
  ;;;; Change %tagSelection to choose the tags you want displayed.
  ;;;; Valid tags are: title views likes dislikes uploader and date 
  var %tagSelection title views likes dislikes uploader date
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  var %sockname $+(LinkDetectorForYoutube,$network,$2,$ticks,$r(1,1000))
  hadd -m %sockname tags %tagSelection
  hadd %sockname tagcolor %tagcolor
  hadd %sockname textcolor %textcolor
  hadd %sockname logo %logo
  sockopen %sockname www.youtube.com 80
  sockmark %sockname $1-2 $+(/watch?v=,$3,&hl=en)
}
menu Channel,Status {
  .$iif($group(#LinkDetectorForYoutube) == On,$style(1)) LinkDetectorForYoutube
  ..$iif($group(#LinkDetectorForYoutube) == On,$style(2)) On: .enable #LinkDetectorForYoutube
  ..$iif($group(#LinkDetectorForYoutube) == Off,$style(2)) Off: .disable #LinkDetectorForYoutube
}
#LinkDetectorForYoutube on
On $*:Text:/(^[\+-])ytdetect$|(https?\x3a\/\/|www\.)(([\S]*youtube\.com[\S]+v\=)|(youtu\.be\/))([\S]{11})/Si:#: {
  var %action $strip($regml(1)), %id $strip($regml(4))
  if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
    if (%action == +) {
      if ($istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the LinkDetectorForYoutube script }
      else { 
        .enable #LinkDetectorForYoutube
        set %LinkDetectorForYoutubeChanList $addtok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)
        .msg $chan $nick has activated the LinkDetectorForYoutube script for $chan .
      }
    }
    else {
      if (!$istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the LinkDetectorForYoutube script }
      else { 
        Set %LinkDetectorForYoutubeChanList $remtok(%LinkDetectorForYoutubeChanList,$+($network,$chan),1,32)
        .msg $chan $nick has deactivated the LinkDetectorForYoutube script for $chan . 
      }
    }
  }
  elseif (!$timer($+(LinkDetectorForYoutube,$network,$nick))) && ($istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) {
    .timer $+ $+(LinkDetectorForYoutube,$network,$nick) 1 4 noop
    GetLinkDetectorForYoutube .msg $chan %id
  }
}
#LinkDetectorForYoutube end
On *:sockopen:LinkDetectorForYoutube*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: $sock($sockname).addr
    sockwrite -n $sockname $crlf
  }
  else { sockclose $sockname | return }
}
On *:sockread:LinkDetectorForYoutube*: {
  if ($sockerr) { sockclose $sockname | return }
  else {
    var %LinkDetectorForYoutube | sockread %LinkDetectorForYoutube
    if ($regex(%LinkDetectorForYoutube,/watch-like\s[^<>]+><[^<>]+><[^<>]+>([^<>\s]+)\s?</i)) { 
      hadd $sockname likes $+($hget($sockname,tagcolor),Likes:) $+($hget($sockname,textcolor),$regml(1)) 
    }
    elseif ($regex(%LinkDetectorForYoutube,/watch-dislike\s[^<>]+><[^<>]+><[^<>]+>([^<>\s]+)\s?</i)) { 
      hadd $sockname dislikes $+($hget($sockname,tagcolor),Dislikes:) $+($hget($sockname,textcolor),$regml(1))
    }
    elseif ($regex(%LinkDetectorForYoutube,/\/user\/(.*?)">/i)) {
      hadd $sockname uploader $+($hget($sockname,tagcolor),Uploader:) $+($hget($sockname,textcolor),$regml(1))
    }
    elseif ($regex(%LinkDetectorForYoutube,/<span class="yt-user-name[^>]*>([^<]*)</i)) {
      hadd $sockname uploader $+($hget($sockname,tagcolor),Uploader:) $+($hget($sockname,textcolor),$regml(1))
    }
    elseif ($regex(%LinkDetectorForYoutube,/watch-view-count"\s?>([^\x20]*)</i)) { 
      hadd $sockname views $+($hget($sockname,tagcolor),Views:) $+($hget($sockname,textcolor),$regml(1)) 
    }
    elseif (id="watch-uploader-info"> isin %LinkDetectorForYoutube) {
      hadd $sockname datefound 1
    }
    elseif ($hget($sockname,datefound) && $regex(%LinkDetectorForYoutube,/(?:published|uploaded)\son\s(.*?)<\/strong>/i)) {
      hadd $sockname date $+($hget($sockname,tagcolor),Upload Date:) $+($hget($sockname,textcolor),$regml(1))
      if ($hget($sockname,tags)) $gettok($sock($sockname).mark,1-2,32) $hget($sockname,logo) $Xchr($regsubex($v1,/([\S]+)/g,$hget($sockname,\t)))
      if ($hget($sockname)) hfree $sockname
      sockclose $sockname          
    } 
    ;long-title ?
    elseif ($regex(%LinkDetectorForYoutube,/class="watch-title".*title="(.*?)">/)) {
      hadd $sockname title $+($hget($sockname,tagcolor),Title:) $+($hget($sockname,textcolor),$regml(1))
    }
    elseif ($regex(%LinkDetectorForYoutube,/<meta\sname="title"\scontent="(.*?)">/)) {
      hadd $sockname title $+($hget($sockname,tagcolor),Title:) $+($hget($sockname,textcolor),$regml(1))
    }
  }
}
on *:sockclose:LinkDetectorForYoutube*: if ($hget($sockname)) hfree $sockname
alias  -l Xchr { 
  var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2,4});/g,$utf8(\1)) 
  return $xXchr($replacecs(%return,&ndash;,$utf8(8211),&mdash;,$utf8(8212),&iexcl;,$utf8(161),&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,$&
    &uuml;,ü,&Aacute;,Á,&aacute;,á,&Eacute;,É,&iquest;,$utf8(191),&ldquo;,$utf8(8220),&rdquo;,$utf8(8221),&apos;,',$&
    &lsquo;,$utf8(8216),&rsquo;,$utf8(8217),&cent;,$utf8(162),&copy;,$utf8(169),&divide;,$utf8(247),&micro;,$utf8(181),$&
    &para;,$utf8(182),&plusmn;,±,&euro;,$utf8(8364),&pound;,£,&reg;,$utf8(174),&sect;,$utf8(167),&trade;,$utf8(153),$&
    &yen;,$utf8(165),&curren;,$utf8(164),&brvbar;,$utf8(166),&sect;,$utf8(167),&uml;,$utf8(168),&ordf;,$utf8(170),$&
    &not;,$utf8(172),&shy;,$utf8(173),&macr;,$utf8(175),&deg;,$utf8(176),&sup2;,$utf8(178),&sup3;,$utf8(179),$&
    &acute;,´,&ccedil;,$utf8(184),&sup1;,$utf8(185),&ordm;,$utf8(186),&frac14;,$utf8(188),&frac12;,$utf8(189),$&
    &frac34;,$utf8(190),&Agrave;,$utf8(192),&Acirc;,$utf8(194),&Atilde;,$utf8(195),&Auml;,$utf8(196),&Aring;,$utf8(197),$&
    &AElig;,$utf8(198),&Ccedil;,$utf8(199),&Egrave;,$utf8(200),&Ecirc;,$utf8(202),&Euml;,$utf8(203),&Igrave;,$utf8(204),&Icirc;,$utf8(206),$&
    &Iuml;,$utf8(207),&ETH;,$utf8(208),&Ograve;,$utf8(210),&Ocirc;,$utf8(212),&Otilde;,$utf8(213),&Ouml;,$utf8(214),&times;,$utf8(215),$&
    &Oslash;,$utf8(216),&Ugrave;,$utf8(217),&Ucirc;,$utf8(219),&Yacute;,$utf8(221),&THORN;,$utf8(222),&szlig;,$utf8(223),&agrave;,$utf8(224),$&
    &acirc;,$utf8(226),&atilde;,$utf8(227),&auml;,$utf8(228),&aring;,$utf8(229),&ccedil;,$utf8(231),&egrave;,$utf8(232),&ecirc;,$utf8(234),&euml;,$utf8(235),$&
    &igrave;,$utf8(236),&icirc;,$utf8(238),&iuml;,$utf8(239),&eth;,$utf8(240),&ograve;,$utf8(242),&ocirc;,$utf8(244),&otilde;,$utf8(245),&ouml;,$utf8(246),$&
    &divide;,$utf8(247),&oslash;,$utf8(248),&ugrave;,$utf8(249),&ucirc;,$utf8(251),&yacute;,$utf8(253),&thorn;,$utf8(254),&yuml;,$utf8(255),&ang;,$utf8(8736),$&
    &and;,$utf8(8743),&fnof;,$utf8(402),&Alpha;,$utf8(913),&Beta;,$utf8(914),&Gamma;,$utf8(915),&Delta;,$utf8(916),&Epsilon;,$utf8(917),&Zeta;,$utf8(918),$&
    &Eta;,$utf8(919),&Theta;,$utf8(920),&Iota;,$utf8(921),&Kappa;,$utf8(922),&Lambda;,$utf8(923),&Mu;,$utf8(924),&Nu;,$utf8(925),&Xi;,$utf8(926),$&
    &Omicron;,$utf8(927),&Pi;,$utf8(928),&Rho;,$utf8(929),&Sigma;,$utf8(931),&Tau;,$utf8(932),&Upsilon;,$utf8(933),&Phi;,$utf8(934),&Chi;,$utf8(935),$&
    &Psi;,$utf8(936),&Omega;,$utf8(937),&alpha;,$utf8(945),&beta;,$utf8(946),&gamma;,$utf8(947),&delta;,$utf8(948),&epsilon;,$utf8(949),&zeta;,$utf8(950)))
}
alias -l xXchr {
  return $replacecs($1-,&eta;,$utf8(951),&theta;,$utf8(952),&iota;,$utf8(953),&kappa;,$utf8(954),&lambda;,$utf8(955),&mu;,$utf8(956),$&
    &nu;,$utf8(957),&xi;,$utf8(958),&omicron;,$utf8(959),&pi;,$utf8(960),&rho;,$utf8(961),&sigmaf;,$utf8(962),$&
    &sigma;,$utf8(963),&tau;,$utf8(964),&upsilon;,$utf8(965),&phi;,$utf8(966),&chi;,$utf8(967),&psi;,$utf8(968),$&
    &omega;,$utf8(969),&thetasym;,$utf8(977),&upsih;,$utf8(978),&piv;,$utf8(982),&bull;,$utf8(8226),&hellip;,$utf8(8230),$&
    &prime;,$utf8(8242),&Prime;,$utf8(8243),&oline;,$utf8(8254),&frasl;,$utf8(8260),&weierp;,$utf8(8472),$&
    &image;,$utf8(8465),&real;,$utf8(8476),&trade;,$utf8(8482),&alefsym;,$utf8(8501),&larr;,$utf8(8592),$&
    &uarr;,$utf8(8593),&rarr;,$utf8(8594),&darr;,$utf8(8595),&harr;,$utf8(8596),&crarr;,$utf8(8629),&lArr;,$utf8(8656),$&
    &uArr;,$utf8(8657),&rArr;,$utf8(8658),&dArr;,$utf8(8659),&hArr;,$utf8(8660),&forall;,$utf8(8704),&part;,$utf8(8706),$&
    &exist;,$utf8(8707),&empty;,$utf8(8709),&nabla;,$utf8(8711),&isin;,$utf8(8712),&notin;,$utf8(8713),&ni;,$utf8(8715),$&
    &prod;,$utf8(8719),&sum;,$utf8(8721),&minus;,$utf8(8722),&lowast;,$utf8(8727),&radic;,$utf8(8730),&prop;,$utf8(8733),$&
    &infin;,$utf8(8734),&or;,$utf8(8744),&cap;,$utf8(8745),&cup;,$utf8(8746),&int;,$utf8(8747),&there4;,$utf8(8756),$&
    &sim;,$utf8(8764),&cong;,$utf8(8773),&asymp;,$utf8(8776),&ne;,$utf8(8800),&equiv;,$utf8(8801),&le;,$utf8(8804),$&
    &ge;,$utf8(8805),&sub;,$utf8(8834),&sup;,$utf8(8835),&nsub;,$utf8(8836),&sube;,$utf8(8838),&supe;,$utf8(8839),$&
    &oplus;,$utf8(8853),&otimes;,$utf8(8855),&perp;,$utf8(8869),&sdot;,$utf8(8901),&lceil;,$utf8(8968),&rceil;,$utf8(8969),$&
    &lfloor;,$utf8(8970),&rfloor;,$utf8(8971),&lang;,$utf8(9001),&rang;,$utf8(9002),&loz;,$utf8(9674),&spades;,$utf8(9824),$&
    &clubs;,$utf8(9827),&hearts;,$utf8(9829),&diams;,$utf8(9830),&eacute;,é,&Iacute;,Í,&iacute;,í,&Oacute;,Ó,&oacute;,ó,$&
    &Ntilde;,Ñ,&ntilde;,ñ,&Uacute;,Ú,&uacute;,ú,&nbsp;,$chr(32),&aelig;,æ,&quot;,",&lt;,<,&gt;,>, &amp;,&,&quot;,")
}
alias -l UTF8 {
  if ($version >= 7) return $chr($1)
  elseif ($1 < 255) { return $chr($1) }
  elseif ($1 >= 256) && ($1 < 2048) { return $+($chr($calc(192 + $div($1,64))),$chr($calc(128 + $mod($1,64)))) }
  elseif ($1 >= 2048) && ($1 < 65536) { return $+($chr($calc(224 + $div($1,4096))),$chr($calc(128 + $mod($div($1,64),64))),$chr($calc(128 + $mod($1,64)))) }
  elseif ($1 >= 65536) && ($1 < 2097152) {
    return $+($chr($calc(240 + $div($1,262144))),$chr($calc(128 + $mod($div($1,4096),64))),$chr($calc(128 + $mod($div($1,64),64))),$&
      $chr($calc(128 + $mod($1,64))))
  }
}
alias -l div { return $int($calc($1 / $2)) }
alias -l mod {
  var %int $int($calc($1 / $2))
  return $calc($1 - (%int * $2))
}
alias -l H2U { return $utf8($base($1,16,10)) }

Comments

Sign in to comment.
ovelayer   -  Jul 21, 2016

Use the one illhawkthat made its the best one. This one has been broke for sometime and i believe fordlawnmower has quit updating his scripts

 Respond  
Alejandro   -  Jun 29, 2016

Can someone help me? I post a youtube link and it doesnt show anything

cptpan  -  Jul 09, 2016

Pretty sure this is broken

Alejandro  -  Jul 21, 2016

Yeah, i'm going to look in somewhere else

Sign in to comment

Aurora801   -  Oct 02, 2015

I'm catching a 301 Perm Moved page when I post a link.
I added some echo's to the script to see where it was going wrong, and they all check out.

This is what I get from the sock read echo:

HTTP/1.1 301 Moved Permanently
Date: Sat, 03 Oct 2015 00:39:59 GMT
Server: gwiseguy/2.0
Content-Length: 0
X-XSS-Protection: 1; mode=block; report=https://www.google.com/appserve/security-bugs/log/youtube
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
X-Content-Type-Options: nosniff
P3P: CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en for more info."
Location: https://www.youtube.com/watch?v=kdUnpV7n1xs
Expires: Tue, 27 Apr 1971 19:44:06 EST
X-Frame-Options: SAMEORIGIN
Set-Cookie: VISITOR_INFO1_LIVE=S9KY8ccag8c; path=/; domain=.youtube.com; expires=Thu, 02-Jun-2016 12:32:59 GMT; httponly
Set-Cookie: YSC=uhmg8nBjaOs; path=/; domain=.youtube.com; httponly

 Respond  
cptpan   -  Feb 24, 2015

This doesn't work any more for me?

Is there something wrong or what?

 Respond  
BitHelper   -  Jan 15, 2015

You should update it. To make work with https

 Respond  
FordLawnmower   -  Sep 27, 2014

Updated to fix likes , dislikes and views.

cptpan  -  Dec 28, 2014

I can't get this script to respond or work at all.

I added script in remote and the message showed:

[10:20] User has activated the LinkDetectorForYoutube script for #channel

But YouTube links don't do anything when pasted in from other users.

Xabache  -  Dec 21, 2015

FordLawnmower please update this to work again. Youtube has changed and your wonderful script does not work anymore.

Sign in to comment

Spinti89   -  Jul 13, 2014

How can i make this work with echo ? But i don't want to echo to the active channel , insted i want it to echo in the channel or query that the link was given...
Can someone help me ?

 Respond  
  -  Jul 08, 2014

Could you add playlist support?
Something like this: https://www.youtube.com/playlist?list=PLat_oTO7cmowvoTNEOQWZgCdaXDLLGnv0

You've Been Doing it Wrong by CrazyRussianHacker 23 videos 467,182 views 310 likes 1 hour, 30 minutes

thanks!

 Respond  
FordLawnmower   -  May 17, 2014

Updated

incognitus  -  May 18, 2014

Thanks FordLawnmower, but doesn't work for me. No info whatsoever after posting links.

Mrmot  -  May 18, 2014

Not working, doesnt show any info when link is posted..

incognitus  -  May 18, 2014

It's working now, thanks. You're the best, FordLawnmower !! \m/

Mrmot  -  May 21, 2014
  • Line too long: $& (line 109, youtubetitle) i have this error :/
incognitus  -  Jun 11, 2014

It's working, but doenst display "views". Any idea? Thanks again, FordLawnmower!

Stewie1k94  -  Jul 06, 2014

@incognitus - If you change Line-77 from

elseif ($regex(%LinkDetectorForYoutube,/watch-view-count">(.*)\sviews/i)) { 

to

elseif ($regex(%LinkDetectorForYoutube,/>([^<]*)<div class="watch-view/i)) {

it should be a temporary fix until Ford updates his code. :)

incognitus  -  Jul 11, 2014

toclafane1 thanks for the tip but still doesnt work ;)

Stewie1k94  -  Jul 25, 2014

@incognitus - Try this instead:

elseif ($regex(%LinkDetectorForYoutube,/watch-view-count">(.*)</i)) {

Line-77. Sorry, the other worked when I posted it.

Sign in to comment

H0LLYWOOD   -  Nov 22, 2013

wow. i cant believe that i requested this over two years ago. and its still getting great use for many many people.
Thanks to @FordLawnmower for continuing to keep updating this snippet and many more like it.
Your The Best.

 Respond  
ovelayer   -  Jun 29, 2013

doesn't seem to work anymore any chance of a fix?

FordLawnmower  -  Jun 29, 2013

I still have this working @overlayer . What problem are you having?

ovelayer  -  Jun 29, 2013

i paste link in channel like
http://www.youtube.com/watch?v=vYeajoizdm0
and it doesn't display anything

FordLawnmower  -  Jun 29, 2013

Did you change anything or add a script that might conflict with this one @overlayer ?
It's still working fine here so, I'm just grasping at straws. Any info might help.

ovelayer  -  Jun 29, 2013

running mirc 7.32 and window's 8
when i do +ydetect it doesn't respond..or when i paste a link
i even reinstalled mirc and still can't seem to get it to work

incognitus  -  Jul 09, 2013

Same here, +ydetect doesnt even respond.

Can you take a look at that, FordLawnmower? Thanks a lot.

FordLawnmower  -  Jul 09, 2013

Now that I look at this , something has happened to the code. Not sure if I'm at fault or @Hawkee .
Can you see anything wrong with this:
Image
I'll post the correct code in a few moments.

FordLawnmower  -  Jul 09, 2013
ovelayer  -  Jul 09, 2013

now it responds when activated but i still can't get it to respond when link is posted..
and yes i see the error in the A
sence the A was not correct is it possible
alias -l Xchr {
var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2});/g,$chr(\1))
return $replacecs(%return,–,,·,·,»,»,«,«,Ü,Ü,ü,ü,Á,Á,á,á,É,$&
É,é,é,Í,Í,í,í,Ó,Ó,ó,ó,Ñ,Ñ,ñ,ñ,Ú,Ú,ú,ú, ,$chr(32),$&
æ,æ,",",&,&)
is incorect as well?
just a thought

incognitus  -  Jul 10, 2013

FordLawnmower thanks for the update. Script works fine again but it doesnt show views and likes. Only title, uploader and date.

Can you add that too please. Thanks again : )

Vegito  -  Nov 13, 2013

Replace line 65 with:

if ($regex(%LinkDetectorForYoutube,/<span class="likes-count">(.*?)</span>/i)) {

That should fix the likes.

Replace line 68 with:

elseif ($regex(%LinkDetectorForYoutube,/<span class="dislikes-count">(.*?)</span>/i)) {

To fix the dislikes.

Replace line 71 with:

elseif (<span class="watch-view-count $"> isin %LinkDetectorForYoutube) {

That should fix the views.

incognitus  -  Nov 13, 2013

Thanks, Vegito. Works great!

FordLawnmower  -  Nov 16, 2013

I didn't know this was broken again. Updated.

Vegito  -  Nov 17, 2013

Could also add that we can see the length of the video.

Sign in to comment

ovelayer   -  Apr 11, 2013

ever thought of doing one of theese that would return the info for all http,www.tinyurl,youtube,ect?

Stewie1k94  -  Apr 11, 2013

This is only for youtube links. If you want to request scripts, it should be done in the forums.

atropine  -  Jun 18, 2013

Could you or someone else please fix this script it doesn't work at all, and contains odd things like

var ¬tion $strip($regml(1)), %id $strip($regml(4))
if (¬tion isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
if (¬tion == +) {

Is that supposed to be %action and if so is that why it's broken?
On the other hand does this work fine for people, and it's just me?

this is the only error i see . it shows on status screen

  • Invalid parameters: $replacecs (line 107, yt detect new)
  • Invalid parameters: $replacecs (line 107, yt detect new)

Is it possible for someone to post a full working script that shows name, views, upload date, likes and dislikes.
I use a very old version works fine but as youtube has changed it will now only show name and upload date.

Sign in to comment

harl   -  Mar 21, 2013

Hi, just dropping this here to let you know.
The latest version of March 17 doesn't work for me. For some reason, neither +ytdetect nor YouTube links seem to correctly activate the script (or its "on TEXT" part respectively), but there are no error messages whatsoever.
The older one I've been using still works just fine (though it only does so correctly with %LinkDetectorForYoutubeChanList set to # but not with single $network#$chan entries. I've tried either way as well with the newer version to no avail). The date on the working script's file says December 14 2012.

Stewie1k94  -  Mar 28, 2013

Try this... there is a slight error in lines 29, 30 and 31 with the variables.

On $*:Text:/(^[\+-])ytdetect$|(https?\x3a\/\/|www\.)(([\S]*youtube\.com[\S]+v\=)|(youtu\.be\/))([\S]{11})/Si:#: {
  var %tion $strip($regml(1)), %id $strip($regml(4))
  if (%tion isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
    if (%tion == +) {
      if ($istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the LinkDetectorForYoutube script }
      else { 
        .enable #LinkDetectorForYoutube
        set %LinkDetectorForYoutubeChanList $addtok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)
        .msg $chan $nick has activated the LinkDetectorForYoutube script for $chan .
      }
    }
    else {
      if (!$istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the LinkDetectorForYoutube script }
      else { 
        Set %LinkDetectorForYoutubeChanList $remtok(%LinkDetectorForYoutubeChanList,$+($network,$chan),1,32)
        .msg $chan $nick has deactivated the LinkDetectorForYoutube script for $chan . 
      }
    }
  }
  elseif (!$timer($+(LinkDetectorForYoutube,$network,$nick))) && ($istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) {
    .timer $+ $+(LinkDetectorForYoutube,$network,$nick) 1 4 noop
    GetLinkDetectorForYoutube .msg $chan %id
  }
}

It worked for me when I changed it. > [7:18pm] <~Stewie> +ytdetect
[7:18pm] <&thunderbolt> Stewie #i is already running the LinkDetectorForYoutube script

harl  -  Mar 28, 2013

Yea, I had tried that before, realizing that the variable wasn't supposed to look the way it does. The original variable's name is %action and somehow it became ¬tion in the script above - but correcting it doesn't change anything. This newer version of the script still doesn't work for me, when all I do is copy&paste it (and change the variable in those 3 lines).
Thanks for trying to help though!

Stewie1k94  -  Mar 30, 2013

When you view the 'Variables' page... is something like this in it > %LinkDetectorForYoutubeChanList Torn#i if not, maybe you could try adding the channels manually, just until you can get the +/-ytdetect to work. Also, you do have OP status or above in the channel, right? It won't work for the +/-ytdetect if you don't.

ircnoob74  -  Mar 30, 2013

Thanks, that fix worked. Do you by chance know how to make likes/dislikes work again? :)

Stewie1k94  -  Mar 30, 2013

Try this:

On *:sockread:LinkDetectorForYoutube*: {
  if ($sockerr) { sockclose $sockname | return }
  else {
    var %LinkDetectorForYoutube | sockread %LinkDetectorForYoutube
    if ($regex(%LinkDetectorForYoutube,/<span class="likes-count">(.*?)</span>/i)) { 
      hadd $sockname likes $+($hget($sockname,tagcolor),Likes:) $+($hget($sockname,textcolor),$regml(1)) 
    }
    elseif ($regex(%LinkDetectorForYoutube,/<span class="dislikes-count">(.*?)</span>/i)) { 
      hadd $sockname dislikes $+($hget($sockname,tagcolor),Disikes:) $+($hget($sockname,textcolor),$regml(1))
    }
    elseif (<span class="watch-view-count"> isin %LinkDetectorForYoutube) {
      hadd $sockname viewsFound 1
      if ($regex(%linkdetectorforyoutube,/\/user\/([^\/]+)\/videos/i)) {
        hadd $sockname uploader $+($hget($sockname,tagcolor),Uploader:) $+($hget($sockname,textcolor),$regml(1))
      }
    }
    elseif ($hget($sockname,viewsFound)) {
      hadd $sockname viewsFound 0
      hadd $sockname views $+($hget($sockname,tagcolor),Views:) $+($hget($sockname,textcolor),$remove(%LinkDetectorForYoutube,<strong>,</strong>)) 
    }
    elseif (($regex(%LinkDetectorForYoutube,/dir="ltr">(.*?)<\/a><span class="yt-user-separator">/i))) {
      hadd $sockname uploader $+($hget($sockname,tagcolor),Uploader:) $+($hget($sockname,textcolor),$regml(1))
      hadd $sockname date $+($hget($sockname,tagcolor),Upload Date:) $+($hget($sockname,textcolor),$regml(2))
    }
    elseif (($regex(%LinkDetectorForYoutube,/watch-video-date"\s>(.*?)<\/span>/i))) {
      hadd $sockname date $+($hget($sockname,tagcolor),Upload Date:) $+($hget($sockname,textcolor),$regml(1))
      if ($hget($sockname,tags)) $gettok($sock($sockname).mark,1-2,32) $hget($sockname,logo) $Xchr($regsubex($v1,/([\S]+)/g,$hget($sockname,\t)))
      if ($hget($sockname)) hfree $sockname
      sockclose $sockname          
    }    
    elseif ($regex(%LinkDetectorForYoutube,/class="watch-video-date"\s>(.*?)<\/span>/)) {
      hadd $sockname date $+($hget($sockname,tagcolor),Upload Date:) $+($hget($sockname,textcolor),$regml(1))
    }
    elseif ($regex(%LinkDetectorForYoutube,/class="long-title".*title="(.*?)">/)) {
      hadd $sockname title $+($hget($sockname,tagcolor),Title:) $+($hget($sockname,textcolor),$regml(1))
    }
    elseif ($regex(%LinkDetectorForYoutube,/<meta\sname="title"\scontent="(.*?)">/)) {
      hadd $sockname title $+($hget($sockname,tagcolor),Title:) $+($hget($sockname,textcolor),$regml(1))
    }
  }
}

[6:45pm] <~Stewie> http://www.youtube.com/watch?v=kHeMck0Ap3I
[6:46pm] <&thunderbolt> YouTube Title: Amaranthe -Razorblade Views: 1,583 Likes: 19 Disikes: 1 Uploader: Luis Manuel Oviedo Vizcaya Upload Date: 23 Mar 2013

ircnoob74  -  Mar 31, 2013

awesome. I tried to figure it out myself and had something similar, but it didn't work. You're the man, thanks.

Stewie1k94  -  Mar 31, 2013

You're welcome mate. :)

harl  -  Apr 06, 2013

Yes, I know about %LinkDetectorForYoutubeChanList.

TL/DR: I'm out of ideas - but I'll just use the working version of the script that I have.

Stewie1k94  -  Apr 07, 2013

So... this version of the script is not working at all for you? :(

Sign in to comment

ircnoob74   -  Jan 17, 2013

Reproducable bug. Sometimes it lists the video description, sometimes it doesn't. No rhyme or reason. Didn't happen in older versions prior to youtube changing stuff up.

[07:04pm] http://www.youtube.com/watch?v=rN7pkFNEg5c
[07:04pm] You Views: 292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008
[07:04pm] http://www.youtube.com/watch?v=rN7pkFNEg5c
[07:04pm] You: The Wire - Bunk's interrogation techniques Views: 292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008

FordLawnmower  -  Jan 17, 2013

I've never seen this and I've been unable to reproduce it in several tries.

[19:40:06] <@Ford_Lawnmower> http://www.youtube.com/watch?v=rN7pkFNEg5c
[19:40:07] YouTube Title: The Wire - Bunk's interrogation techniques Views: 292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008
[19:40:57] <@Ford_Lawnmower> http://www.youtube.com/watch?v=rN7pkFNEg5c
[19:40:58] YouTube Title: The Wire - Bunk's interrogation techniques Views: 292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008
[19:41:02] <@Ford_Lawnmower> http://www.youtube.com/watch?v=rN7pkFNEg5c
[19:41:03] YouTube Title: The Wire - Bunk's interrogation techniques Views: 292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008
[19:41:07] <@Ford_Lawnmower> http://www.youtube.com/watch?v=rN7pkFNEg5c
[19:41:08] YouTube Title: The Wire - Bunk's interrogation techniques Views: 292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008
[19:41:16] <@Ford_Lawnmower> http://www.youtube.com/watch?v=rN7pkFNEg5c
[19:41:17] YouTube Title: The Wire - Bunk's interrogation techniques Views: 292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008
[19:41:26] <@Ford_Lawnmower> http://www.youtube.com/watch?v=rN7pkFNEg5c
[19:41:27] YouTube Title: The Wire - Bunk's interrogation techniques Views: 292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008

If I can't reproduce it , I won't be able to fix it. If you have anymore information that you think will help, please post it.

ircnoob74  -  Jan 18, 2013

I've slightly modified the script, but I don't see why it would cause this. Posted below. Do you see any issues here?

;YouTube Link detector by Ford_Lawnmower irc.Geekshed.net #Script-Help
alias -l GetLinkDetectorForYoutube {
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;; Change %tagcolor to the color you want for tags:
  var %tagcolor $+($chr(15),$chr(2))
  ;;;; Change %textcolor to the color you want for normal text
  var %textcolor $chr(15)
  ;;;; Change %logo to change the YouTube logo
  var %logo $+($chr(2),$nick))
  ;;;; Change %tagSelection to choose the tags you want displayed.
  ;;;; Valid tags are: title views likes dislikes uploader and date 
  var %tagSelection title views likes dislikes uploader date
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  var %sockname $+(LinkDetectorForYoutube,$network,$2,$ticks,$r(1,1000))
  hadd -m %sockname tags %tagSelection
  hadd %sockname tagcolor %tagcolor
  hadd %sockname textcolor %textcolor
  hadd %sockname logo %logo
  sockopen %sockname www.youtube.com 80
  sockmark %sockname $1-2 $+(/watch?v=,$3)
}

And this:

elseif ($regex(%LinkDetectorForYoutube,/class="long-title".*title="(.*?)">/)) {
      hadd $sockname title $+($hget($sockname,tagcolor),:) $+($hget($sockname,textcolor),$regml(1))
    }
    elseif ($regex(%LinkDetectorForYoutube,/<meta\sname="title"\scontent="(.*?)">/)) {
      hadd $sockname title $+($hget($sockname,tagcolor),:) $+($hget($sockname,textcolor),$regml(1))
ircnoob74  -  Jan 18, 2013

I just copied and pasted the original script and it does the same thing. I'm still using mirc 6.2, if that matters.

FordLawnmower  -  Jan 19, 2013

This script probably won't work with 6.2 . I don't have the time to sort it out and see what issues it would have with 6.2 but I'm sure there are some. Most likely the issue is that the variable length being to short to read the youtube page. 6.2 is 7 years old and you will have trouble with lots of newer scripts if you keep using it. To upgrade, all you have to do is replace the mIRC.exe with a newer one. I would suggest 6.35 if you have a lot of older scripts.

ircnoob74  -  Jan 23, 2013

I see, thanks. Any idea why likes and dislikes no longer work?

Sign in to comment

harl   -  Dec 17, 2012

@FordLawnmower - It'd be cool if you could add two things:
1) "on ACTION" and "on NOTICE" (both utilizing the same formatting as "on TEXT")
2) a variable in the top section, to have a single spot to toggle between msg and echo

Thanks for maintaining this script ;)

 Respond  
chachin   -  Dec 08, 2012

amclay.. I cant find the lines that will let me do what you ask me so Im the only one who can +youtube/-youtube :(

 Respond  
chachin   -  Dec 08, 2012

no matter what I try.... I cant select > copy from this site anymore... and firefox doesnt have a "copy feature"

 Respond  
FordLawnmower   -  Dec 08, 2012

Updated. Thanks for noticing Bladerunner :)

 Respond  
Bladerunner   -  Dec 07, 2012

Hi, as of today YouTube launched a new design, and the script is no longer working. Is this a simple fix?

 Respond  
amclay   -  Aug 25, 2012

add a (if $ != Owner) to the +/- command, that way only your text will trigger that.

 Respond  
chachin   -  Aug 21, 2012

how about making it soonly the owner of the bot can do +ytube -ytube

 Respond  
^WeSt   -  May 30, 2012

@FordLawnmower ,

I wanna suggest to add and the Video Length (duration) of an video and the maximum video quality (1080).

  • Thanks!
 Respond  
ircnoob74   -  May 27, 2012

Would it be possible to add a short description to the parsed link from the yt desc?? Anyone give me an idea how to? I've tried, and failed. ;)

 Respond  
ircnoob74   -  May 27, 2012

Disregard previous comment, wasn't running the latest version of mirc. Upgrading to that fixed it.

 Respond  
ircnoob74   -  May 27, 2012

nevermind

 Respond  
amclay   -  May 24, 2012

If I wanted to not post if the youtube title contained certain bad words, how would I go about doing this?

v1de0man, what's not working for you? make sure you enable the script in the channel by typing +ytdetect OR add the variable %LinkDetectorForYoutubeChanList #channel1 #channel2 in variables

 Respond  
v1de0man   -  May 20, 2012

i tried this, but alas i get nothing posted here

 Respond  
amclay   -  May 19, 2012

Oh, WOW. yeah. I am used to justin.tv, which a lot of the commands are .COMMAND anyways. Thanks a ton, you're the best!

 Respond  
FordLawnmower   -  May 18, 2012

Yes @amclay . Just do a find and replace.
Find: .msg
Replace with: msg
The dot -->> .
in front of msg suppresses the output on the client running the script.

 Respond  
amclay   -  May 18, 2012

Whenever a link is posted, I don't see what the script is writing to the channel. Is there a way to fix it?
IE

ON THE BOT
[03:17] <@tester> http://www.youtube.com/watch?v=IPEnEkBY-9U

ON PERSON POSTING
[03:16] <@tester> http://www.youtube.com/watch?v=IPEnEkBY-9U
[03:16] <@bot> YouTube Title: Wolf's Retarded Mission Episode 1 Views: 416,103 Likes: 3,163 Disikes: 160 Upload Date: Jun 4, 2008

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.