This is a simple tutorial to get basic statistics from a shoutcast server without using a password and using /7.html By: Rayeh Basically all we are doing is going to connect to the shoutcast server and do the following things- 1. Parse the data from the on text and open the socket 2. Sockwrite to the server 3. Parse the data we need from the data it gives 4. Send it back to the channel First lets start with the on text event for this. In the on text event we need to do a few things- 1. Set the channel it was triggered to a variable for later use 2. Close the socket incase there was an error the last time and it didn't close 3. Parse the text given to get the host and port (In the example it will be "-scstat host:port") 4. Open the socket to the server It should look something like this- -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- on *:TEXT:-scstat*:#:{ set %scstat.chan $chan sockclose scstat sockopen scstat $gettok($2,1,58) $gettok($2,2,58) } -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- Next we need to tell mIRC what to do when the socket opens. So here we will use the on sockopen event. In the on sockopen event we will need to do the following- 1. Tell the server we want /7.html 2. Tell the server we are using mozilla 3. Tell the server we are done socket writing It should look something like this- -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- on *:SOCKOPEN:scstat:{ sockwrite -n $sockname GET /7.html HTTP/1.0 sockwrite -n $sockname User-Agent: Mozilla sockwrite -n $sockname $crlf } -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- Now comes the fun part... Parsing the data we get back. Here we will need to do the following- 1. Strip the excess HTML from the 2. Parse the data we want and set it to variables The HTML we are going to parse will look like this, but it will have different data of course- -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- 45,1,91,150,42,192,DJ Tiesto - In Search of Sunrise 3 -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- The '45' is the current listeners The '1' is binary, it is telling us whether there is a live dj or not The '91' is the peak listeners The '150' is the max listeners The '42' is reported listeners, we don't really need that The '192' is the selected bitrate Everything after that is the current song The sockread event should look something like this- -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- on *:sockread:scstat:{ if ($sockerr > 0) return :nextread sockread -f %scasttemp if ($sockbr == 0) return if (%scasttemp == $null) %scasttemp = empty set %scasttemp $remove(%scasttemp,,) if ((HTTP/1.* !iswm %scasttemp) && (content-type* !iswm %scasttemp) && (%scasttemp != empty)) { set %scstat.song $gettok(%scasttemp,7-,44) set %scstat.bitrate $gettok(%scasttemp,6,44) set %scstat.listeners $gettok(%scasttemp,1,44) set %scstat.maxlist $gettok(%scasttemp,4,44) set %scstat.peak $gettok(%scasttemp,3,44) if ($gettok(%scasttemp,2,44) == 1) set %scstat.livedj connected else set %scstat.livedj not connected ; changing some of the html codes back to regular characters set %scast.song $replace(%scast.song,&,$chr(38),',$chr(39)) } goto nextread } -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- After this we probably want to send everything back to the channel right? This is how I did it, I added some extra stuff like calculating the bandwidth used by server- -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- on *:sockclose:scstat:{ msg %scstat.chan DSP  $+ %scstat.livedj $+  and playing  $+ %scstat.song $+  msg %scstatchan  $+ %scstat.listeners $+  out of  $+ %scstat.maxlist $+  listeners at  $+ $+(%scstat.bitrate,Kb) $+  using up $+(,$round($calc(((%scstat.bitrate *1024) * %scstat.listeners)/ 1024 / 1024),2),Mb/s) or $+(,$round($calc(((%scstat.bitrate *1024) * %scstat.listeners)/ 1024 ),2),Kb/s) or $+(,$round($calc(((%scstat.bitrate *1024) * %scstat.listeners)/ 1024 / 8),2),KB/s) msg %scstat.chan You can listen at $+(http://,%scstat.host,:,%scstat.port,/listen.pls) } -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- The full code for this is- -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=- on *:TEXT:-scstat*:#:{ set %scstat.chan $chan sockclose scstat sockopen scstat $gettok($2,1,58) $gettok($2,2,58) } on *:SOCKOPEN:scstat:{ sockwrite -n $sockname GET /7.html HTTP/1.0 sockwrite -n $sockname User-Agent: Mozilla sockwrite -n $sockname $crlf } on *:sockread:scstat:{ if ($sockerr > 0) return :nextread sockread -f %scasttemp if ($sockbr == 0) return if (%scasttemp == $null) %scasttemp = empty set %scasttemp $remove(%scasttemp,,) if ((HTTP/1.* !iswm %scasttemp) && (content-type* !iswm %scasttemp) && (%scasttemp != empty)) { set %scstat.song $gettok(%scasttemp,7-,44) set %scstat.bitrate $gettok(%scasttemp,6,44) set %scstat.listeners $gettok(%scasttemp,1,44) set %scstat.maxlist $gettok(%scasttemp,4,44) set %scstat.peak $gettok(%scasttemp,3,44) if ($gettok(%scasttemp,2,44) == 1) set %scstat.livedj connected else set %scstat.livedj not connected ; changing some of the html codes back to regular characters set %scast.song $replace(%scast.song,&,$chr(38),',$chr(39)) } goto nextread } on *:sockclose:scstat:{ msg %scstat.chan DSP  $+ %scstat.livedj $+  and playing  $+ %scstat.song $+  msg %scstatchan  $+ %scstat.listeners $+  out of  $+ %scstat.maxlist $+  listeners at  $+ $+(%scstat.bitrate,Kb) $+  using up $+(,$round($calc(((%scstat.bitrate *1024) * %scstat.listeners)/ 1024 / 1024),2),Mb/s) or $+(,$round($calc(((%scstat.bitrate *1024) * %scstat.listeners)/ 1024 ),2),Kb/s) or $+(,$round($calc(((%scstat.bitrate *1024) * %scstat.listeners)/ 1024 / 8),2),KB/s) msg %scstat.chan You can listen at $+(http://,%scstat.host,:,%scstat.port,/listen.pls) } -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=-