mIRC Home    About    Download    Register    News    Help

Print Thread
#250527 19/01/15 11:15 AM
Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Code:
on *:TEXT:!yt &:#: {
  echo Started 
  if ($sock(YTube)) .sockclose YTube
  set %link $2
  echo youtube.com/watch?v= $+ %link
  sockopen YTube www.youtube.com 80
}

on *:SOCKOPEN:YTube: {
  echo Opened
  sockwrite -nt $sockname GET /watch?v= $+ %link HTTP/1.1
  sockwrite -nt $sockname Host: www.youtube.com $+ $str($crlf,2)
}

on *:SOCKREAD:YTube: {
  echo read 
  if (!$sockerr) {
    echo not yet
    var %sockreader
    sockread %sockreader
    if (*"title"*  iswm %sockreader) {
      echo Found
      msg # Found 
      unset %link
      sockclose YTube
    }
  }
}


I know that there are a lot of these out there but half of them I don't understand because of how many variables and stuff or because they use links that throw me off. So I decided to goof around with my own socket to try and give it a quick practice. The code goes down to if (!$sockerr) but does not go beyond that. Again I plan to flesh it out more but right now I can't even get this to work.

Newbie #250528 19/01/15 11:45 AM
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
What do you mean exactly? Does it echo 'not yet' at all? if you get a socket error, what's the value of $sockerr?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #250529 19/01/15 04:28 PM
Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
So this script is supposed to just test whether I understand how to use sockets. So it starts of by opening the socket to youtube. If the socket opens it will go to the on *:SOCKOPEN: and so I wanted to test if it got there so I made it echo open if it got that far. If the script reaches SOCKREAD then it should echo read. If there is no error it should get to the line not yet. Lastly from what I understood in the tutorial, if the word "title is within the html page then it should go to the last part where it will respond by saying found. My problem is that it doesn't reach that point, only going as far as the echo not yet.

The echoes are there to see how far the script got, but it stops after if (!sockerr) and doesn't go any farther.

Newbie #250530 19/01/15 04:36 PM
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
You need to use "sockopen -e" with https pages, also change the port to 443

I think it's helpful to just echo the %sockreader before moving forward with anything else


Link Copied to Clipboard