All pastes #15035 Raw Edit

Untitled

public text v1 · immutable
#15035 ·published 2005-06-19 19:12 UTC
rendered paste body
alias streamstat { 

  window @temp2
  sockopen shoutcast $1 $2
}


on *:sockopen:shoutcast:{ 
  if ($sockerr) { disp Can't connect to: $+($hget(shout,ip),:,$hget(shout,port)) | return }
  var %a = sockwrite -n shoutcast
  %a GET / HTTP/1.0
  %a Host: $sock(shoutcast).ip
  %a User-Agent: mSSC/1.1
  %a Accept: */*
  %a Icy-MetaData:0
  %a Connection: close
  %a
}

on *:sockread:shoutcast:{
  var %a
  if (%x != 1) {
    sockread %a
    while ($sockbr) {
      if (%a) {
        tokenize 58 %a
        if (%a == ICY 200 OK) { aline @temp2 Connected successfuly }
        elseif ($1 == icy-name) { aline @temp2 name: $2- }
        elseif ($1 == icy-genre) { aline @temp2 genre: $2- }
        elseif ($1 == icy-url) { aline @temp2 url: $2- }
        set %x 1
      }
    }
  }
}