Youtube video lookup script - 11/02/07 03:04 AM
Hi, I managed to make this after a week's worth of insanity (I am a scripting noob)... It matches on *youtube.com/watch* and it looks up the video's title and description, and says it in the channel asked.
The part I'm having trouble with is that, sometimes the title and description is flat out wrong. It either a) returns a previous matches' title/desc b) returns "http" as title and desc (I don't know why) c) returns null for both title and desc
If someone can take a look at this, I would be much obliged ^_^
The part I'm having trouble with is that, sometimes the title and description is flat out wrong. It either a) returns a previous matches' title/desc b) returns "http" as title and desc (I don't know why) c) returns null for both title and desc
If someone can take a look at this, I would be much obliged ^_^
Code:
; you need this module: http://www.xise.nl/mirc/url.mrc ; you need this module: http://www.xise.nl/mirc/url.mrc ; you need this module: http://www.xise.nl/mirc/url.mrc on *:text:*youtube.com/watch*:*: { set %titles $remove($regml(1),<h1 id="video_title">,</h1>) set %descs $remove($regml(1), ,<span id="vidDescRemain">,<br/>,</span>) %url = $* %youtubepathurl = $urlparse(%url).path if ($sock(111111)) .sockclose 111111 sockopen 111111 youtube.com 80 msg $chan %youtubepathurl Title: %titles Description: %descs ; unset %titles ; unset %descs ; unset %url ; unset %youtubepathurl } on *:SOCKOPEN:111111: { sockwrite -nt $sockname GET %youtubepathurl HTTP/1.1 sockwrite -nt $sockname Host: youtube.com sockwrite -nt $sockname $crlf } on *:SOCKREAD:111111: { if ($sockerr) { msg %chan Socket Error: $sockname $+ . Error code: $sockerr Please inform $me of this error message. halt } else { var %sockreader sockread %sockreader if (*"video_title"* iswm %sockreader ) { noop $regex(%sockreader,/<h1 id="video_title">(.*?)</h1>/Si) } if (*"vidDescRemain"* iswm %sockreader ) { noop $regex(%sockreader,/<span id="vidDescRemain">(.*?)</span>/Si) sockclose 111111 } } }