mIRC Homepage
Hey all,
i used this script for posting the youtube title from a youtube link, but the script brokes, can anyone fix it? smile

Code:
alias -l sockopenmark { sockopen $1-3 | sockmark $1 $4- }
on $*:text:/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si:*: {
  sockopenmark $+(yt.,$calc($ticks + $rand(1,99)))  www.youtube.com 80 $regml(2) msg $iif($chan,$v1,$nick))
}
on *:sockopen:yt.*:{
  tokenize 32 $sock($sockname).mark
  sockwrite -n $sockname GET /watch?v= $+ $1 HTTP/1.0 
  sockwrite -n $sockname HOST: www.youtube.com $+ $str($crlf,2)
}
on *:sockread:yt.*:{
  var %v  |  sockread %v
  if ($regex(%v,/"name" content="(.+)"/)) { 
    tokenize 32 $sock($sockname).mark
    $2-4 $replace($regml(1),&,$chr(38),',$chr(39),',$chr(39),",$chr(34),",$chr(34),&,$chr(38)) $5-
    sockclose $sockname
  }
}
Looks like they force https, use the -e switch when opening the socket over port 443.

Code:
alias sockopenmark { sockopen -e $1-3 | sockmark $1 $4- }
on $*:text:/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si:*: {
  sockopenmark $+(yt.,$ticks,$rand(1,99)) www.youtube.com 443 $regml(2) msg $iif($chan,$v1,$nick))
}
on *:sockopen:yt.*:{
  tokenize 32 $sock($sockname).mark
  sockwrite -n $sockname GET /watch?v= $+ $1 HTTP/1.0 
  sockwrite -n $sockname HOST: www.youtube.com $+ $str($crlf,2)
}
on *:sockread:yt.*:{
  var %v  |  sockread %v
  if (%v) echo -ag %v
  if ($regex(%v,/"name" content="(.+)"/)) { 
    tokenize 32 $sock($sockname).mark
    $2-4 $replace($regml(1),&,$chr(38),',$chr(39),',$chr(39),",$chr(34),",$chr(34),&,$chr(38)) $5-
    sockclose $sockname
  }
}
This is really cool, but my head 'bout exploded when I tried to make it output like:

$nick just linked to "youtubetitle"

Could you show how to modify the script to do that, please?
Edit:/
Thanks loki - is working fine! smile
© mIRC Discussion Forums