Sidearm

Sidearm

Joined
Dec 25, 2007

Activity Stream

Sidearm commented on a Page, YouTube URL "Detector" (v.8)  -  Jan 06, 2010

This should work. Also, I replace the msg with an echo.

Example:
<@I> http://www.youtube.com/watch?v=0_EFdod4YDo test
[YouTube]: By: eaglerocktv | (uploaded on May 29, 2008) | Title: ZZ Top - Sharp Dressed Man | Views: 3,104,757 | Rating: 5.0 (4,771 ratings)

;// YouTube Detector Identifiers //
alias -l addmark { return $+($sock($1).mark,$chr($3),$2) }

;// 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 %yt | sockread %yt
  if ($regex(%yt,<h1 >(.+)<\/h1>)) sockmark youtube $addmark(youtube,Title: $+(,$regml(1),),62) 
  ;if ($regex(%yt,<title>YouTube\s-\s(.+)<\/title>)) sockmark youtube $addmark(youtube,Title: $+(,$regml(1),),62)
  elseif ($regex(%yt,.+"l":\s(\d+))) sockmark youtube $addmark(youtube,Duration: $+(,$duration($regml(1)),),62)
  elseif ($regex(%yt,/ratingL-(.+)"\stitle|"smallText">(.+)\sratings<\/span>/g)) sockmark youtube $addmark(youtube,$+($regml(1),>,$regml(2)),62)
  elseif ($regex(%yt,count">(.+)<\/span>\sviews)) sockmark youtube $addmark(youtube,$regml(1),62)
  elseif ($regex(%yt,date">(.+)<\/span>)) sockmark youtube $addmark(youtube,$+($chr(40),uploaded on $regml(1),$chr(41)),62)
  elseif ($regex(%yt,<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)
  echo -t # $1 [1,0You0,4Tube]: $iif(%x >= 7,$4 $chr(124) $5 $chr(124) $3 $chr(124) Views: $+(,$iif(%x == 7,$7,$8),) $chr(124) Rating: $iif(%x == 8,$6 $+($chr(40),$7 $iif($7 == 1,rating,ratings),$chr(41),),$+(,Ratings were disabled,)),Either the video doesn't exist or it contained a malformed video ID.)
}
 Respond  
Sidearm commented on a Page, YouTube URL "Detector" (v.8)  -  Aug 15, 2009

Excellent script, I used an ECHO instead of (s)msg for personal use. :)

 Respond  
Sidearm commented on a Page, Kickban script - Kicks - ban on 3  -  Jan 04, 2008

What seems to be the problem?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.