This was actually
^Neptune's request, so here it is.
YouTube! When you're chatting with your friends on IRC, you'll usually encounter some YouTube links to videos. But ever wonder what the video is? Instead of opening a new tab in your browser to see actually "what" it is, you can have a personal YouTube URL Detector.
Just load it onto a bot, put a YouTube URL, and it'll give you information on the following:
- Title of the video
- Uploader's name
- Date uploaded
- Duration of the video
- Number of views
- Rating + Number of Ratings
:)
Newer news
Updates!: I've removed the TinyURL edition for specific reasons, mentioned below. I might post a snippet on it later, but it will not be in this snippet. (If you liked the older version and enjoyed the benefit of downloading the videos, check out the
older version here.
I've also enhanced the speed of the script, removed the use of key identifiers such as
$between and
$htmlfree, and reduced script space. Triple the pleasure?
Older news
If you do not like the new update:
Quote
Some of you might say that the TinyURL links do not work, or it leads to a blank page and halts.
"It is most likely because it is a .flv file and/or unknown to the web browser."
Edit: That is false. I've later realized that the URL is actually user-based, essentially only one person can access it, or the bot owner; the owner sockopens to the YouTube site, and therefore, given a specific code that expires when accessed.
Despite the update, I doubt many will be intrigued to even download a certain YouTube video (if you can stream it online, why download it?), so I'm not worried much.
Otherwise, the TinyURL's should work if the selected browser detects it.
If your browser happens to detect the video, the video name should be called video.flv.
If you find any bugs, let me know!
Here's a picture:
If you can't see the picture:
Quote
<@noob>
http://www.youtube.com/watch?v=eghL7ORV1lg
<@null> [YouTube]: Title: Seinfeld - Million to One Shot Doc | By: NIGathan (uploaded on August 12, 2008) | Duration: 2mins 8secs | Views: 7,573 | Rating: 4.5 (11 ratings)
Here's the other picture:
If you can't see the picture:
Updates:
Update #1 - Sat Mar 27, 11:32 AM: Fixed the bug with the "duration" with
^Neptune's
$between.
Update #2 - Sat Mar 28, 11:47 AM: Added error checks to see if the video exists or not.
Update #3 - Sun Mar 29, 11:36 AM: Fixed minor bug (if ratings on the video are disabled).
Update #4 - Tue Mar 31, 6:25 PM: Fixed bug where it gets text after the video url. Thanks to
Jonesy44 for the regex help.
Update #5 - Mon Apr 13, 9:33 PM: Added TinyURL link to direct link to the YouTube Video, for downloading. (
.flv file called
video.flv)
Enjoy! :D
;SOF
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
; YouTube Video "Detector" ;
; Made by Kirby (Quakenet) ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;// YouTube Detector Identifiers //
alias -l addmark { return $+($sock($1).mark,$chr($3),$2) }
alias -l smsg { msg $iif(c isincs $chan($1).mode,$1 $strip($2-),$1-) }
;// YouTube Detector Text Event //
on *:text:*youtube.com/watch?v=*:#: {
if (!$sock(youtube)) {
noop $regex($strip($1-),http:\/\/.*youtube.*\/watch\?v=(.{11})&?.*)
sockopen youtube www.youtube.com 80 | sockmark youtube $+(#,>,$regml(1))
}
}
;// YouTube Detector Socket (Video Information) //
on *:sockopen:youtube: {
sockwrite -n $sockname GET $+(/watch?v=,$gettok($sock(youtube).mark,2,62)) HTTP/1.0
sockwrite -n $sockname Host: www.youtube.com
sockwrite -n $sockname $crlf
}
on *:sockread:youtube: {
var %x | sockread %x
if ($regex(%x,<meta\sname="title"\scontent="(.+)">)) sockmark youtube $addmark(youtube,Title: $+(,$regml(1),),62)
elseif ($regex(%x,"length_seconds":\s"(\w+)")) sockmark youtube $addmark(youtube,Duration: $+(,$duration($regml(1)),),62)
elseif ($regex(%x,title="(.+)">.+<span\sclass="smallText">(.+)\sratings<\/span>)) sockmark youtube $addmark(youtube,$+($regml(1),>,$regml(2)),62)
elseif ($regex(%x,view-count">(.+)<\/span>\s)) { sockmark youtube $addmark(youtube,$regml(1),62) }
elseif ($regex(%x,date">(.+)<\/span>)) sockmark youtube $addmark(youtube,$+($chr(40),uploaded on $regml(1),$chr(41)),62)
elseif ($regex(%x,<a\sclass="url"\shref="\/user\/(\w+)")) sockmark youtube $addmark(youtube,By: $+(,$regml(1),),62)
}
on *:sockclose:youtube: {
tokenize 62 $sock(youtube).mark | var %x $numtok($sock(youtube).mark,62)
smsg $1 [1,0You0,4Tube]: $iif(%x >= 7,$3 $chr(124) $5 $6 $chr(124) $4 $chr(124) Views: $+(,$iif(%x == 7,$7,$9),) $chr(124) Rating: $iif(%x == 9,$+(,$7,) $+($chr(40),$8 $iif($8 == 1,rating,ratings),$chr(41),),$+(,Ratings were disabled,)),Either the video doesn't exist or it contained a malformed video ID.)
}
;EOF