mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2014
Posts: 42
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
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
  }
}

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
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
  }
}

Joined: Nov 2014
Posts: 32
P
Ameglian cow
Offline
Ameglian cow
P
Joined: Nov 2014
Posts: 32
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?

Joined: Aug 2014
Posts: 42
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Edit:/
Thanks loki - is working fine! smile

Last edited by Krawalli; 08/01/15 06:19 PM.

Link Copied to Clipboard