Just a small alias for downloading YouTube videos, whipped in about half an hour.
[size=20]Syntax: /youtube [/size]
An example of a "full url" would be something like this:
/youtube http://www.youtube.com/watch?v=Xw6kAAkKFak
Although http://www.mediaconverter.org/ is far more efficient in terms of selecting preferable file extensions, I thought it'd be neat to show that it can be done using basic mIRC coding.
Once the command is activated and the compressed url is retrieved, mIRC will automatically open up the direct link in your default Internet browser.
The downloaded file will always be in Flash Video format, otherwise known as .flv, in the file name of video.flv. Unless you have a resource that enables playing of .flv files, this won't be the best for you. Many programs such as iTunes, WinAmp, and video editing programs are available for viewing the downloaded videos.
As a small addition, I've added a url compressor - TinyUrl! TinyUrl compresses the very long file name for the direct link to the video, mainly in the sense of creating ease for the eyes.
alias youtube {
if (!$1) echo -a * Syntax: /youtube <full url>
elseif (!$regex($1,http:\/\/.*youtube.*\/watch\?v=.{11}&?.*)) echo -a * Url specified was not valid. Please check that you have entered the full YouTube Url.
else {
sockopen yt www.youtube.com 80
sockmark yt $1
}
}
on *:sockopen:yt:{
noop $regex($sock(yt).mark,http:\/\/(.*youtube.*)(\/watch\?v=.{11})&?.*)
sockwrite -n $sockname GET $regml(2) HTTP/1.1
sockwrite -n $sockname Host: $regml(1)
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
on *:sockread:yt: {
sockread %yt
if ($regex(%yt,.+'(/watch_fullscreen)(.+)';)) {
var %x $regsubex($regsubex(%yt,.+'(/watch_fullscreen)(.+)',/get_video\2),/(\s)/g,+)
noop $regex($sock(yt).mark,(http:\/\/)(.*youtube.*)(\/watch\?v=.{11})&?.*)
sockopen tu tinyurl.com 80
sockmark tu $+($regml(1),$regml(2),%x)
}
}
on *:sockopen:tu: {
sockwrite -n $sockname GET $+(/create.php?url=,$sock(tu).mark) HTTP/1.1
sockwrite -n $sockname Host: tinyurl.com
sockwrite -n $sockname $crlf
}
on *:sockread:tu: {
sockread %yt
if ($regex(%yt,<blockquote><b>(http:\/\/(?!preview\.).+)</b>)) {
echo -a [1,0You0,4Tube]: Downloading the video... $+(,$regml(1),)
url -an $regml(1)
unset %yt
}
}
no prob if u want u can try
Here are a valid YouTube link, but your regex detects an error
http://www.youtube.com/watch?gl=FR&hl=fr&v=BZmE3fUKU5U
your regex can be check all that valide links?? no!!
but look Here are 3 invalid YouTube links but your regex does not detect any error
1- http://www.youtube.com/watch?v=RFMT_IzT4&feature=rec-HM-fresh+div
RFMT_IzT4 <==== 9 characters not 11 !!!
2- http://ww.youtube.com/watch?v=Pc3yFlYlhCQ&feature=fvw
ww. <====== not www. !!
3- http://wwwxyoutubexcom/watch?v=Pc3yFlYlhCQ&feature=fvw
no dots!!!
so finally, my own opinion is
$regex($1,http:\/\/www\.youtube\..+\/watch\?(gl=..&..=..&v|v)=[^&]{11})
this regex will check if the link is
http://www.youtube.<something(.com .fr) mabe>/watch?= over 11 characters not include "&"
u can try that regex with all that links and that checking better
No, you [size=28]don't[/size] want to use:
elseif (!$wildtok($1,http://www.youtube.com/watch?v=*,1,32)) echo -a * Url specified was not valid. ...
because with the regex I put in, it does four things: Check to see if it's an actual YouTube URL, varies the different "types" of YouTube (as in countries), checks to see if the video ID matches 11 characters, and strips out any other & tags.
hi
good job Kirby but i think no need for regex here
elseif (!$wildtok($1,http://www.youtube.com/watch?v=*,1,32)) echo -a * Url specified was not valid. ...
on *:sockopen:yt:{
tokenize 47 $sock(yt).mark
sockwrite -n $sockname GET / $+ $3 HTTP/1.1
sockwrite -n $sockname Host: $2
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
like that