Youtube url detector for mIRC

Platform:  mIRC
Published  Jul 14, 2011
Updated  May 08, 2013

  • 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:


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))
;;;; 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)
}
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 ¬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
}
}
#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,/alt="Like">\s(.*)/i)) {
hadd $sockname likes $+($hget($sockname,tagcolor),Likes:) $+($hget($sockname,textcolor),$regml(1))
}
elseif ($regex(%LinkDetectorForYoutube,/alt="Dislike">\s(.*)/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))
}
}
}
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});/g,$chr(\1))
return $replacecs(%return,&ndash;,–,&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,&uuml;,ü,&Aacute;,Á,&aacute;,á,&Eacute;,$&
É,&eacute;,é,&Iacute;,Í,&iacute;,í,&Oacute;,Ó,&oacute;,ó,&Ntilde;,Ñ,&ntilde;,ñ,&Uacute;,Ú,&uacute;,ú,&nbsp;,$chr(32),$&
&aelig;,æ,&quot;,"&amp;,&)
}

Comments

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?
toclafane1  -  Apr 11, 2013
This is only for youtube links. If you want to request scripts, it should be done in the forums.
atropine  -  1 day ago
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.
toclafane1  -  Mar 28, 2013
Try this... there is a slight error in lines 29, 30 and 31 with the variables.

Code

 
It worked for me when I changed it.

Quote

[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!
toclafane1  -  Mar 30, 2013
When you view the 'Variables' page... is something like this in it

Quote

%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? :)
toclafane1  -  Mar 30, 2013
Try this:

Code

 

Quote

[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.
toclafane1  -  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.
toclafane1  -  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] <Me> http://www.youtube.com/watch?v=rN7pkFNEg5c
[07:04pm] <Bot> You Views:  292,302 Uploader: aaandre321 Upload Date: Jul 7, 2008
[07:04pm] <Me> http://www.youtube.com/watch?v=rN7pkFNEg5c
[07:04pm] <Bot> 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.

Quote


[19:40:06] <@Ford_Lawnmower> http://www.youtube.com/watch?v=rN7pkFNEg5c
[19:40:07] <GlueSniffer> 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] <GlueSniffer> 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] <GlueSniffer> 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] <GlueSniffer> 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] <GlueSniffer> 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] <GlueSniffer> 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?

Code

 


And this:

Code

 
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  
KilllerX   -  Mar 17, 2012
yes... instead of .msg $chan or anything that is describe/action/message variant. Use

//echo -a
 Respond  
mrmr   -  Mar 17, 2012
is it possible to make the script just "echo" the title (and settings) to yourself?
 Respond  
toclafane1   -  Feb 16, 2012

Quote

[11:53pm] <~toclafane|away> http://www.youtube.com/watch?v=5anLPw0Efmo&ob=av3e
[11:53pm] <@thunderbolt> YouTube Title: Evanescence - My Immortal Views: 26402396 Likes: 135044 Disikes: 879 Uploader: EvanescenceVEVO Upload Date: 02/12/2009
thanks
 Respond  
FordLawnmower   -  Feb 16, 2012
That's not the updated code, because I just noticed that the change I made to fix the uploader broke the date.
Give me a few minutes and I will fix the Date and then post an update.

**Edit**
Okay, I've updated it to fix the Upload Date. Please try the updated code toclafane1
 Respond  
toclafane1   -  Feb 16, 2012
I can't get it to work with any link, I've done quite a few:

Quote

[9:09pm] <~toclafane|away> http://www.youtube.com/watch?v=ke8ZSi80j_0
[9:09pm] <@thunderbolt> YouTube Title: Get Over It - Avril Lavigne Views: 16279542 Likes: 26907 Disikes: 746 Upload Date: 18/06/2006
[9:09pm] <~toclafane|away> http://www.youtube.com/watch?v=9qhkf1hDh4M&feature=related
[9:10pm] <@thunderbolt> YouTube Title: Avril Lavigne - Slipped Away - Views: 87387 Likes: 197 Disikes: 8 Upload Date: 23/02/2008
[9:10pm] <~toclafane|away> http://www.youtube.com/watch?v=BX518lEPis8&feature=related
[9:10pm] <@thunderbolt> YouTube Title: Avril Lavigne Who Knows Views: 3233705 Likes: 4520 Disikes: 113 Upload Date: 02/08/2007
[9:11pm] <~toclafane|away> http://www.youtube.com/watch?v=x75Ka_wwOYg
[9:11pm] <@thunderbolt> YouTube Title: Eminem - That's All She Wrote (Solo Version) Views: 863960 Likes: 4096 Disikes: 37 Upload Date: 21/11/2010
[9:11pm] <~toclafane|away> http://www.youtube.com/watch?v=pjTUIu95jYs&feature=related
[9:12pm] <@thunderbolt> YouTube Title: Eminem - Where I'm At (Ft. Lloyd Banks) (2010) (HQ) Views: 785451 Likes: 2760 Disikes: 22 Upload Date: 22/11/2010
[9:12pm] <~toclafane|away> http://www.youtube.com/watch?v=5anLPw0Efmo&ob=av3e
[9:12pm] <@thunderbolt> YouTube Title: Evanescence - My Immortal Views: 26394632 Likes: 134975 Disikes: 878 Upload Date: 02/12/2009
[9:13pm] <~toclafane|away> http://www.youtube.com/watch?v=fhGF33qPkp4
[9:13pm] <@thunderbolt> YouTube Title: Skipi &amp; Tyzee - Momentot (LYRICS) ²º¹¹ Views: 164110 Likes: 431 Disikes: 11 Upload Date: 21/05/2011
All the link's I tryed
 Respond  
FordLawnmower   -  Feb 16, 2012
With this update I also fixed the missing uploader column.
Are you not seeing the uploader column with the code at the top of this page toclafane1 ?
If so, please post a link for me that's not showing the uploader and I'll sort it out.
 Respond  
Bladerunner   -  Feb 16, 2012
I couldn't either so I had removed that (it's not really a big deal anyway), but it seems that since FordLawnmower's youtu.be update it's working perfectly for me now.
 Respond  
toclafane1   -  Feb 16, 2012
Just wondering if this is only a problem I'm having, but any way. I can't get the song author (uploader) to show, any idea how to fix this problem?
 Respond  
toclafane1   -  Feb 15, 2012
Thank's for that update. :D I was wondering how to do that.
 Respond  
Bladerunner   -  Feb 14, 2012
Works like a charm!

Thanks very much FordLawnmower. Much appreciated. :)
 Respond  
FordLawnmower   -  Feb 14, 2012
Okay, thanks Bladerunner :)
It's updated for youtu.be . Please let me know if you have any problems with this edit.
 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.