Can anyone suggest a more efficient way to get the video id without it messing up on links like, http://www.youtube.com/watch?v=VecHdfXeXkA#t=1m, http://www.youtube.com/watch?feature=player_embedded&v=8jnfr_j6cdi , youtu.be , or any others you can think of.

I could always use another script, however, I like that this one works with the API. I couldn't find any others that did that.

Code:
; Requires the $download snippet can be found here: http://sephiroth.bounceme.net/forum/viewtopic.php?t=104
; No need to change anything normally
; Simply paste it to remote and you will get an echo after someone pasted a youtube uri
; if you wanna use it for a bot change the marked line
on *:text:*youtube*:#: {
  var %url = $wildtok($1-,*v=*, 1, 32)
  ;  var %url = $wildtok($1-,*http*://*youtube*/watch?v=*, 1, 32)

  if ($youtube(%url)) {
    tokenize 9 $ifmatch
    ; Author -> $1
    ; Duration -> $2
    ; Rating -> $3
    ; Date (last updated OR published) -> $4
    ; Preview Picture -> $5
    ; Title -> $6
    /*
    change the echo line to a msg # line and it will be posted to the channel :)
    */
  msg # 1,0You0,4Tube15,10 Title: $6 (Rating: $3 $+ ) Length: $2 Author: $1   }
}
alias youtube {
  ; http://www.youtube.com/watch?v=B0fFDk2M0zE&feature=fvhl
  ; example: $youtube(...youtube.com/watch?v=vid)
  var %x = $gettok($1-,2-,63)
  %x = $gettok(%x,1,38)
  if ($gettok(%x,1,61) == v) { %x = $gettok(%x,2,61) }
  else { return $false }
  if ($download(tmpfile,GET,http://gdata.youtube.com/feeds/api/videos/ $+ %x ,2)) {
    bread tmpfile 0 $lof(tmpfile) &bin
    var %string = $b(&bin,<author>)
    if ($regex(%string,/\<author\>\<name\>(.*)\<\/name\>/ig)) { var %author = $regml(1) }
    var %string = $b(&bin,<yt:duration)
    if ($regex(%string,/\<yt:duration seconds='([\d]+)'\/\>/ig)) { var %duration = $gmt($regml(1),HH;nn:ss) }
    var %string = $b(&bin,<gd:rating)
    if ($regex(%string,/average='([^']+)' max='([\d]+)'/ig)) { var %rating = $round($regml(1),3) }
    var %string = $b(&bin,<title)
    if ($regex(%string,/type='text'>([^<]+)/ig)) { var %title = $regml(1) }
    var %string = $b(&bin,<updated>)
    if ($regex(%string,/\<updated>([\d]{4})-([\d]{2})-([\d]{2})T([\d]{2}:[\d]{2})\:/ig)) { var %date = $regml(3) $+ . $+ $regml(2) $+ . $+ $regml(1) $regml(4) }
    else {
      var %string = $b(&bin,<published>)
      if ($regex(%string,/\<published>([\d]{4})-([\d]{2})-([\d]{2})T([\d]{2}:[\d]{2})\:/ig)) { var %date = $regml(3) $+ . $+ $regml(2) $+ . $+ $regml(1) $regml(4) }
    }
    var %preview = http://i.ytimg.com/vi/ $+ %x $+ /0.jpg
    if ($isfile(tmpfile)) { !.remove tmpfile }
    %x = $t(%author,%duration,%rating,%date,%preview,%title)
  }
  else { var %x = $false }
  if ($isfile(tmpfile)) { !.remove tmpfile }
  return %x
}
alias -l t { var %x = $0,%o | while (%x) { %o = $ [ $+ [ %x ] ] $+ $chr(9) $+ %o | dec %x } | return %o }
alias -l b { return $bvar($1,$bfind($1,1,$2).text,800).text }


Thanks!