_Dean_ commented on a Page, Youtube Link Information --WORKING--  -  Feb 22, 2011

you could do like this

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))
    hmake ytb 10
  }
}

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 %ytx | sockread %ytx
  if $regex(%ytx,/<meta name="title" content="(.+)"/) { hadd ytb 1 1[1,0You0,4Tube] $qt($regml(1)) }
  if $regex(%ytx,/<strong>(\d+)<\/strong>/) { hadd ytb 2 Viewed: $regml(1) }
  if $regex(%ytx,/<a id="watch-username".*><strong>(.+)<\/strong><\/a>/) { hadd ytb 3 - User: $regml(1) }
  if $regex(%ytx,/<span class="likes">(\d+)<\/span>.*<span class="dislikes">(\d+)<\/span>/) { msg $gettok($sock($sockname).mark,1,62) $hget(ytb,1) - $hget(ytb,2) - $hget(ytb,3) - Likes: $regml(1) Dislikes: $regml(2) | sockclose $sockname | hfree ytb }
}

i created a hash to use it to put the data, so no need the sockclose event, by the way, it will return without the html tags, i just added a hmake on text event, and edited the entire sockread event, its just a tip test it

using this one the return will be this

[22:49:29] <~Dean> http://www.youtube.com/watch?v=TRE6smcyDF4&feature=feedrec_grec_index
[22:49:31] <&Botname> [YouTube] "Simunition: US Military Using New Simulation Round" - Viewed: 21196 - - User: MilitaryNewsNetwork - Likes: 18 Dislikes: 2

 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.