rendered paste bodyon *:text:*youtube.com/watch*:*: {
%url = $*
%youtubepathurl = $urlparse(%url).path
if ($sock(111111)) .sockclose 111111
set %chan $chan
set %nick $nick
sockopen 111111 youtube.com 80
if %tube != on {
window @YouTube
set %tube on
echo @YouTube Info: YouTube window opened $day $+ , $date $+ , $time
echo @YouTube .................................................................................................................................................
}
if ($chan == $null) {
echo @YouTube 4< $asctime(mm:dd:yyyy-HH:nn:ss) $+ 4> 4< $+ $network PM $+ 4> 4< $+ $nick $+ 4> $1- Title: %titles Description: %descs
write youtube.txt < $+ $date $+ > < $+ $time $+ > < $+ $network $chan $+ > < $+ $nick $+ > $1- Title: %titles Description: %descs
}
else {
echo @YouTube 4< $asctime(mm:dd:yyyy-HH:nn:ss) $+ 4> 4< $+ $network $chan $+ 4> 4< $+ $nick $+ 4> $1- Title: %titles Description: %descs
write youtube.txt < $+ $date $+ > < $+ $time $+ > < $+ $network $chan $+ > < $+ $nick $+ > $1- Title: %titles Description: %descs
}
}
on *:close:@YouTube:{
set %tube off
}
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)
%titles = $remove($regml(1),<h1 id="video_title">,</h1>)
}
if (*"vidDescRemain"* iswm %sockreader ) {
noop $regex(%sockreader,/<span id="vidDescRemain">(.*?)</span>/Si)
%descs = $remove($regml(1), ,<span id="vidDescRemain">,<br/>,</span>)
sockclose 111111
}
}
}