; youtube URL logger
; finds info about a youtube video and logs it to @YouTube and writes to youtube.txt
; info it finds about a single video: title, description, ratngs, view count, # of comments, times favorited
on *:text:*youtube.com/watch?v=*:*:{
%rating = 0
%entry = $1-
if (%tube != on) {
window @YouTube
set %tube on
echo @YouTube Info: YouTube window opened $day $+ , $date $+ , $time
}
if (http:// isin $1-) %ytpath = / $+ $gettok($gettok($gettok($1-,3,47),1,38),1,32)
else %ytpath = / $+ $gettok($gettok($gettok($1-,2,47),1,38),1,32)
%ytnick = $nick
%ytchan = $chan
sockclose yt
sockopen yt youtube.com 80
}
on *:close:@YouTube:{
set %tube off
}
on *:sockopen:yt:{
if ($sockerr) {
; echo -a $chr(91) $+ $time $+ $chr(93) YouTube: socket error
if (%ytchan) {
echo @YouTube ...................................................................................................................................................................................................................................................................................................
echo @YouTube ERROR: $+($chr(3),04,<,$chr(15),$date,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),$time,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),$network %ytchan,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),%ytnick,$chr(3),04>,$chr(15)) %entry
write yterror.txt < $+ $date $+ > < $+ $time $+ > < $+ $network %ytchan $+ > < $+ %ytnick $+ > %entry
}
if (%ytchan == $null && %ytnick != $null) {
echo @YouTube ...................................................................................................................................................................................................................................................................................................
echo @YouTube ERROR: $+($chr(3),04,<,$chr(15),$date,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),$time,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),$network PM,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),%ytnick,$chr(3),04>,$chr(15)) %entry
write yterror.txt < $+ $date $+ > < $+ $time $+ > < $+ $network PM $+ > < $+ %ytnick $+ > %entry
}
halt
}
sockwrite -n $sockname GET %ytpath HTTP/1.1
sockwrite -n $sockname Host: youtube.com
sockwrite -n $sockname $crlf
}
on *:sockread:yt: {
:read
sockread -f %ytread
if (Ratings have been disabled for this video isin %ytread) { set %ratingsdisabled yes }
if (Adding comments have been disabled for this video isin %ytread) { set %commentsdisabled yes }
if (
isin %ytread) { %numratings = $remove(%ytread, ,
, ratings,
) }
if (Views: isin %ytread) { %views = $remove(%ytread, ,,,,|
, ,Views:) }
if (Comments: isin %ytread) { %comments = $remove(%ytread, ,,,,|
, ,Comments:) }
if (Favorited: isin %ytread) { %favorited = $remove(%ytread, ,,,,|
, ,Favorited:) }
if ( isin %ytread) %title = $remove(%ytread, ,YouTube - ,)
if (%found) { unset %found | %desc_be = $remove(%ytread, ) }
if ( isin %ytread) %found = k
if ( isin %ytread) %desc_re = $replace($remove(%ytread, ,,),
,$chr(32))
if (Category isin %ytread) %done = k
if (%done) {
sockclose yt
unset %done
if ($read(youtube.txt,w,* $+ %ytpath $+ *) != $null) { %record = noop }
else { %record = write }
:title
if (%ytchan) {
echo @YouTube ...................................................................................................................................................................................................................................................................................................
echo @YouTube 4 $+($chr(3),04,<,$chr(15),$date,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),$time,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),$network %ytchan,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),%ytnick,$chr(3),04>,$chr(15)) %entry
echo @YouTube Title: %title
%record youtube.txt .....................................................................................................................................................................................................................................................................
%record youtube.txt < $+ $date $+ > < $+ $time $+ > < $+ $network %ytchan $+ > < $+ %ytnick $+ > %entry
%record youtube.txt Title: %title
if (%ratingsdisabled == yes && %commentsdisabled == yes) {
echo @YouTube Rating: %rating stars 4(Disabled). Views: %views $+ . Comments: %comments 4(Disabled). Favorited: %favorited times.
%record youtube.txt Rating: %rating stars (Disabled). Views: %views $+ . Comments: %comments (Disabled). Favorited: %favorited times.
goto desc
}
if (%commentsdisabled == yes && %ratingsdisabled = $null) {
echo @YouTube Rating: %rating stars. Rated: %numratings times. Views: %views $+ . Comments: %comments 4(Disabled). Favorited: %favorited times.
%record youtube.txt Rating: %rating stars. Rated: %numratings times. Views: %views $+ . Comments: %comments (Disabled). Favorited: %favorited times.
goto desc
}
else {
echo @YouTube Rating: %rating stars. Rated: %numratings times. Views: %views $+ . Comments: %comments $+ . Favorited: %favorited times.
%record youtube.txt Rating: %rating stars. Rated: %numratings times. Views: %views $+ . Comments: %comments $+ . Favorited: %favorited times.
goto desc
}
}
if (%ytchan == $null && %ytnick != $null) {
echo @YouTube ...................................................................................................................................................................................................................................................................................................
echo @YouTube 4 $+($chr(3),04,<,$chr(15),$date,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),$time,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),$network PM,$chr(3),04>,$chr(15)) $+($chr(3),04,<,$chr(15),%ytnick,$chr(3),04>,$chr(15)) %entry
echo @YouTube Title: %title
%record youtube.txt .....................................................................................................................................................................................................................................................................
%record youtube.txt < $+ $date $+ > < $+ $time $+ > < $+ $network PM $+ > < $+ %ytnick $+ > %entry
%record youtube.txt Title: %title
if (%ratingsdisabled == yes && %commentsdisabled == yes) {
echo @YouTube Rating: %rating stars 4(Disabled). Views: %views $+ . Comments: %comments 4(Disabled). Favorited: %favorited times.
%record youtube.txt Rating: %rating stars (Disabled). Views: %views $+ . Comments: %comments (Disabled). Favorited: %favorited times.
goto desc
}
if (%commentsdisabled == yes && %ratingsdisabled = $null) {
echo @YouTube Rating: %rating stars. Rated: %numratings times. Views: %views $+ . Comments: %comments 4(Disabled). Favorited: %favorited times.
%record youtube.txt Rating: %rating stars. Rated: %numratings times. Views: %views $+ . Comments: %comments (Disabled). Favorited: %favorited times.
goto desc
}
else {
echo @YouTube Rating: %rating stars. Rated: %numratings times. Views: %views $+ . Comments: %comments $+ . Favorited: %favorited times.
%record youtube.txt Rating: %rating stars. Rated: %numratings times. Views: %views $+ . Comments: %comments $+ . Favorited: %favorited times.
goto desc
}
}
:desc
if (%desc_re) {
echo @YouTube Description: %desc_re
%record youtube.txt Description: %desc_re
}
else {
echo @YouTube Description: %desc_be
%record youtube.txt Description: %desc_be
}
unset %entry
unset %ytpath
unset %ytnick
unset %ytchan
unset %title
unset %ytread
unset %desc_be
unset %desc_re
unset %rating
unset %views
unset %comments
unset %favorited
unset %numratings
unset %ratingsdisabled
unset %commentsdisabled
}
if ($sockbr) goto read
}