Yet Another Youtube Title grabber

Platform:  mIRC
Published  Feb 24, 2012
Updated  Feb 27, 2012
just a simple channel and pm youtube title grabber. just paste this in your remotes and any youtube url will be parsed for its title.

*** I realize there is a huge replace line in the script. if anyone can suggest an easier or better way to replace html ascii or a better way of going about this i welcome your comments. The script is still functional and nearly instant. Ive been getting same second replies.

Tested and added ProIcons line to it. good call on the shortlink catcher

****This is meant to be put on a bot. when someone posts a youtube link either in the channel or in pm it will grab the title @ EminamaDron


****UPDATE 2/27/2012****

Ok so to start credits to MakiMaki for the no var's version posted. After extensive testing and reworking this is the finalized version. A major thanks goes to my m8 ex0a for an improved regex and alias to eliminate the need for a loop.

This new version will now properly grab any number of youtube url's posted in the channel or pm no matter how fast they are posted and will return the title for each one with a youtube shorturl for each as well. I would highly recommend putting a spam protection on it.
;-------------------------------------------;
; Youtube Title Grabber ;
;-------------------------------------------;
alias -l sockopenmark { sockopen $1-3 | sockmark $1 $4- }
on $*:text:/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si:*: {
sockopenmark $+(yt.,$calc($ticks + $rand(1,99))) www.youtube.com 80 $regml(2) msg $iif($chan,$v1,$nick) $+($chr(02),$chr(03),01,$chr(44),00,You,$chr(3),00,$chr(44),04,Tube,$chr(3)) $+($chr(02),@,$chr(32),$chr(31),http://youtu.be/,$regml(2))
}
on *:sockopen:yt.*:{
tokenize 32 $sock($sockname).mark
sockwrite -n $sockname GET /watch?v= $+ $1 HTTP/1.0
sockwrite -n $sockname HOST: www.youtube.com $+ $str($crlf,2)
}
on *:sockread:yt.*:{
var %v | sockread %v
if ($regex(%v,/"name" content="(.+)"/)) {
tokenize 32 $sock($sockname).mark
$2-4 $replace($regml(1),&,$chr(38),',$chr(39),',$chr(39),",$chr(34),",$chr(34),&,$chr(38)) $5-
sockclose $sockname
}
}

Comments

Sign in to comment.
dreamphreak2   -  Aug 04, 2012
A warning, do not private message yourself with a youtube link, or else you get infinite spam and have to restart irc client.
 Respond  
  -  Feb 27, 2012
I had copied it wrong, it works thank you for sharing it.
 Respond  
Jibberish   -  Feb 27, 2012
all mine grabs is the id of the video after v= no matter where v= is for normal links or anything after / for the short urls. it should work for you as well just fine :) and ty :)
 Respond  
  -  Feb 27, 2012
lol at of all the videos that is the first one to fail LOL saddly for me the fix for you is not what I need, Mine has to be the the id in order to work in my script.. (U) now I have to fix that LOL... great job glad that you got it done looks awesome
 Respond  
Jibberish   -  Feb 27, 2012
major update posted. bugs fixed and completely redone the code :)

@ MakiMaki First let me say thank you for posting the no vars version i love it and it works great. But your regex was a bit flawed as it would catch: OAAAAAAAAAA in: http://www.youtube.com/watch?feature=g-logo&v=BqMIGC1tx3s&context=G2747d50FOAAAAAAAAAA
the new regex corrects this :)

TY to everyones post. still waiting to see someone come up with a better way to do the $replace tho :D
 Respond  
  -  Feb 26, 2012
glad I could help, and yes the pattern will work for all the types of youtube urls I use this in my own script for my webchat to be able to watch the vidoes check out my profile to look at the screenshot
 Respond  
Jibberish   -  Feb 26, 2012
Nice guys thank you all for your suggestions. i will test and implement the changes today.

@ ProIcons i only seperated it out as the pm one isnt really for a bot you can put it into your personal remotes and use it to grab urls pm'd to you. but yes combining them is doable.

@MakiMaki ty for the new regex lines. Im fairly new at using regex , als youtube has been messing with the url formating so all i want to grab is whats after v= no matter where it is in the url. if that regex does it ( at the time of writing this i havent tested) then sweet ill use it.
As for the replace line i couldnt think of a better/simpler way to do it and i tried to do just one and it threw out error's on me and i couldnt get it to work so i just did multiples. ty for showing me how to use just one :)
 Respond  
  -  Feb 25, 2012
Just playing with it some..

Code

 


you dont need the vars, Good idea on the replace tho you only need it once.
 Respond  
  -  Feb 25, 2012
Here is a regex pattern to use for your event triggers

Code

 


Nice job none the less,
- Edit due to my rudeness of not giving props to a good job.

 Respond  
ProIcons   -  Feb 25, 2012

Code

 
 Respond  
ProIcons   -  Feb 25, 2012
Don't need to have 2 Codes,
this Covers and Queries, and Channel Texts.
 Respond  
FelicianoX   -  Feb 24, 2012
Just copy paste a YouTube link in the channel and it will trigger @ Eminama
 Respond  
EminamaDron   -  Feb 24, 2012
lol but how the hell do you access it?
 Respond  
Jibberish   -  Feb 24, 2012
Ty for the update. ill test it out and then edit the post :)
 Respond  
ProIcons   -  Feb 24, 2012
on *:text:*:*: {
if ($regex($1-,/youtube.com.*v=([^&]+)/)) { /set %yt.chan $iif($chan,$v1,$nick) | /set %yt.url /watch?v= $+ $regml(1) | /sockclose yt | /sockopen yt youtube.com 80 }
if ($regex($1-,/youtu.be.([^/]+[^/])/)) { /set %yt.chan $iif($chan,$v1,$nick) | /set %yt.url /watch?v= $+ $regml(1) | /sockclose yt | /sockopen yt youtube.com 80 }
}
 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.