rendered paste body;alias yt {
; if (youtube.com/watch?v= isin $1-) {
; if (http:// isin $1-) %ytpath = / $+ $gettok($gettok($1-,3,47),1,38)
; else %ytpath = / $+ $gettok($gettok($1-,2,47),1,38)
; sockclose yt
; sockopen yt youtube.com 80
; }
; else {
; echo -a $chr(91) $+ $time $+ $chr(93) YouTube: syntax error
; }
;}
on *:text:*youtube.com/watch?v=*:*:{
if (http:// isin $1-) %ytpath = / $+ $gettok($gettok($1-,3,47),1,38)
else %ytpath = / $+ $gettok($gettok($1-,2,47),1,38)
%ytnick = $nick
%ytchan = $chan
sockclose yt
sockopen yt youtube.com 80
}
on *:sockopen:yt:{
if ($sockerr) { echo -a $chr(91) $+ $time $+ $chr(93) YouTube: socket error | halt }
sockwrite -n $sockname GET %ytpath HTTP/1.1
sockwrite -n $sockname Host: youtube.com
sockwrite -n $sockname $crlf
}
on *:sockread:yt: {
:read
;sockread &temp
;bwrite yt.txt -1 -1 &temp
sockread -f %ytread
; if (<title> isin %ytread) {
; if (%ytchan != $null) { msg %ytchan YouTube: %ytpath $remove(%ytread,<title>,</title>) | goto gettitle }
; if (%ytchan == $null && %ytnick != $null) { msg %ytnick YouTube: %ytpath $remove(%ytread,<title>,</title>) }
; }
:gettitle
if (*"video_title"* iswm %ytread ) {
noop $regex(%ytread,/<h1 id="video_title">(.*?)</h1>/Si)
set %titles $remove($regml(1),<h1 id="video_title">,</h1>)
if (%ytchan != $null) { msg %ytchan %ytpath Title: %titles | goto getdesc }
if (%ytchan == $null && %ytnick != $null) { msg %ytnick %ytpath Title: %titles }
}
:getdesc
if (*"vidDescRemain"* iswm %ytread ) {
noop $regex(%ytread,/<span id="vidDescRemain">(.*?)</span>/Si)
set %descs $remove($regml(1), ,<span id="vidDescRemain">,<br/>,</span>)
if (%ytchan != $null) { msg %ytchan %ytpath Description: %descs | goto end }
if (%ytchan == $null && %ytnick != $null) { msg %ytnick %ytpath Description: %descs }
}
:end
if ($sockbr) goto read
}