mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2003
Posts: 16
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Sep 2003
Posts: 16
Indeed is not a problem in my script, but I was thinking, why this socket take a long time to retrieve the data...
somebody can check my code, and check if the problem is on my script...

Code:
####################################
### TWITCAM IRC VIEWER by Unfor  ###
####################################
alias twtc { 
  if (http isin $1) { set %twt $remove($1,http://twitcam.livestream.com,http://twitcam.com,http://www.twitcam.com)
    sockclose twtc 
    sockopen twtc twitcam.livestream.com 80
  }
  else { set %twt $remove($1,www.twitcam.livestream.com,http://twitcam.com) 
    sockclose twtc 
    sockopen twtc twitcam.livestream.com 80
  }
}
on *:sockopen:twtc:{
  sockwrite -nt $sockname GET %twt HTTP/1.1
  sockwrite -nt $sockname Host: twitcam.livestream.com
  sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; pt-BR; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
  sockwrite -nt $sockname $crlf
}
on *:sockread:twtc:{
  if ($sockerr) { echo 4 -a ERRRROOOOOO! }
  else {
    sockread %twtc
    if (<p>Recorded Live by isin %twtc) || (<h1> Live Stream by isin %twtc) { echo 4 -a $nohtml(%twtc) | set %twtuser $remove($nohtml(%twtc),Live Stream by) }
    if ("video_src" isin %twtc) && (id="video-share-embed" !isin %twtc) { 
      set %twtc.url $remove(%twtc,<link rel="video_src" href=","/>)
      set %twtc.url $right(%twtc.url,$calc($len(%twtc.url)-3))       
    }
  }
}
on *:sockclose:twtc:{ twtcw | echo -s $time }
alias twtcw {
  var %tcn = 1
  :loop 
  if ($window(@Twtcam $+ %tnc)) { 
    inc %tnc
    goto loop 
  }
  else {
    addurl 
    ;    window -dok0w3z @Twtcam $+ %tnc 343 102 344 311 
    window -dok0w3z @Twtcam $+ %tnc 343 102 379 326
    titlebar @Twtcam $+ %tnc - %twt - %twtuser
    /dll nHTMLn_2.95.dll attach $window(@Twtcam $+ %tnc).hwnd
    ;    /dll nHTMLn_2.95.dll navigate %twtc.url 
    /dll nHTMLn_2.95.dll navigate $scriptdirtwitcam.html
  }
  unset %tnc
}
alias addurl {
  .remove twitcam.html
  write twitcam.html <html>
  write twitcam.html <body bgcolor="black">
  ;write twitcam.html <object id="twitcamPlayer" width="320" height="265" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="movie" value="http://static.livestream.com/chromelessPlayer/wrappers/TwitcamPlayer.swf?hash= $+ $remove(%twt,/) $+ "/><param name="allowScriptAccess" value="always"/><param name="allowFullScreen" value="true"/><param name="wmode" value="window"/> <embed name="twitcamPlayer" src="http://static.livestream.com/chromelessPlayer/wrappers/TwitcamPlayer.swf?hash= $+ $remove(%twt,/) $+ " allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" bgcolor="#ffffff" width="320" height="265" wmode="window" ></embed></object>
  write twitcam.html <object id="twitcamPlayer" width="320" height="265" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="movie" value="http://static.livestream.com/grid/LSPlayer.swf?hash=2r6e9"/><param name="allowScriptAccess" value="always"/><param name="allowFullScreen" value="true"/><param name="wmode" value="window"/> <embed name="twitcamPlayer" src="http://static.livestream.com/grid/LSPlayer.swf?hash= $+ $+ $remove(%twt,/) $+ " allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" bgcolor="#ffffff" width="320" height="265" wmode="window" ></embed></object>
  write twitcam.html </body>
  write twitcam.html </html>
}


It takes almost 10 minutes to open the window, if I close prematurely the socket, I've got the wrong data, get the previous info of the script.
I'm using Windows 7 32Bit - mirc 7.15
this happens with mirc 7.14 too.
Thats I remembering on version 7.1, works fine!

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
a quick comment: if you send 'Connection: close' in your HTTP request then the web server will end the connection as soon as it finishes sending the data. for example:

Code:
on *:sockopen:twtc:{
  sockwrite -nt $sockname GET %twt HTTP/1.1
  sockwrite -nt $sockname Host: twitcam.livestream.com
  sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; pt-BR; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
  sockwrite -n $sockname Connection: close 
  sockwrite -nt $sockname $crlf
}


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Sep 2003
Posts: 16
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Sep 2003
Posts: 16
nice suggestion, but now, all twitcams appears offline, my webcam which I created to test appears offline too... any other suggestion?

Edit: Problem already solved... thx 4 all dudes.

Last edited by UnFoRgIvInG; 22/11/10 04:37 PM.

Link Copied to Clipboard