dialoged shoutcast
Posted by w.e
Saturday, March 26, 2005
Description: shoutcast connecter

dialog shoutcast {
  title "WNR|REG"
  size -1 -1 159 91
  option dbu
  text "Listeners/Max:", 1, 10 7 35 8
  text "Server IP:", 2, 10 18 25 8
  text "Server Port:", 3, 10 29 30 8
  text "Peak:", 4, 10 40 25 8
  text "Song:", 5, 10 51 25 8
  text "Bitrate:", 6, 10 62 25 8
  edit "", 7, 52 6 97 10, read
  edit "", 8, 52 17 97 10
  edit "", 9, 52 28 97 10
  edit "", 10, 52 39 97 10, read
  edit "", 11, 52 50 97 10, read
  edit "", 12, 52 61 97 10, read
  button "Refresh", 13, 10 75 37 12, default
  button "Done", 14, 112 75 37 12, ok
  button "Echo song", 15, 61 75 37 12
}
on *:dialog:shoutcast:sclick:15: {
  thinggy
}
alias thinggy {
  set %channelmsg $$?1=channel?
  msg %channelmsg Listeners: $did(shoutcast,7) Peak: $did(shoutcast,10) Server IP: $did(shoutcast,8) $+ : $+ $did(shoutcast,9) Song: $did(shoutcast,11) Bitrate: $did(shoutcast,12)
  msg %channelmsg Website: http:// $+ $did(shoutcast,8) $+ : $+ $did(shoutcast,9) $+ / Listen now: http:// $+ $did(shoutcast,8) $+ : $+ $did(shoutcast,9) $+ /listen.pls
}
on *:dialog:shoutcast:init:0: {
  did -ra shoutcast 8 %server
  did -ra shoutcast 9 %port
  sockclose shoutcast.peaklist
  sockopen shoutcast.peaklist $did(shoutcast,8) $did(shoutcast,9)
  sockclose shoutcast.listeners
  sockopen shoutcast.listeners $did(shoutcast,8) $did(shoutcast,9)
  sockclose song
  sockopen song $did(shoutcast,8) $did(shoutcast,9)
  sockclose shoutcast.bitrate
  sockopen shoutcast.bitrate $did(shoutcast,8) $did(shoutcast,9)
}
on *:dialog:shoutcast:sclick:13: {
  set %server $did(shoutcast,8)
  set %port $did(shoutcast,9)
  sockclose shoutcast.peaklist
  sockopen shoutcast.peaklist $did(shoutcast,8) $did(shoutcast,9)
  sockclose shoutcast.listeners
  sockopen shoutcast.listeners $did(shoutcast,8) $did(shoutcast,9)
  sockclose song
  sockopen song $did(shoutcast,8) $did(shoutcast,9)
  sockclose shoutcast.bitrate
  sockopen shoutcast.bitrate $did(shoutcast,8) $did(shoutcast,9)
}
on *:SOCKOPEN:song:{
  if ($sockerr > 0) {
    did -ra shoutcast 11 error
    return
  }
  sockwrite -n $sockname GET /7.html HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla
  sockwrite -n $sockname $crlf
}
on *:sockread:song:{
  if ($sockerr > 0) return
  :nextread
  sockread -f %scasttemp
  if ($sockbr == 0) return
  if (%scasttemp == $null) %scasttemp = empty
  set %scasttemp $remove(%scasttemp,<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>,</body></html> )
  if ((HTTP/1.* !iswm %scasttemp) && (content-type* !iswm %scasttemp) && (%scasttemp != empty)) {
    set %song $gettok(%scasttemp,7-,44)
    set %status $gettok(%scasttemp,2,44)
    set %song $replace(%song,&,$chr(38),',$chr(39))
  }
  goto nextread
}
on *:sockclose:song:{
  if ( %shoutcast.status == 0 ) {
    did -ra shoutcast 11 error
  }
  else {
    did -ra shoutcast 11 %song
  }
}
on *:SOCKOPEN:shoutcast.listeners:{
  if ($sockerr > 0) {
    did -ra shoutcast 7 error
    return
  }
  sockwrite -n $sockname GET /7.html HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla
  sockwrite -n $sockname $crlf
}
on *:sockread:shoutcast.listeners:{
  if ($sockerr > 0) return
  :nextread
  sockread -f %scasttemp
  if ($sockbr == 0) return
  if (%scasttemp == $null) %scasttemp = empty
  set %scasttemp $remove(%scasttemp,<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>,</body></html> )
  if ((HTTP/1.* !iswm %scasttemp) && (content-type* !iswm %scasttemp) && (%scasttemp != empty)) {
    set %shoutcast.status $gettok(%scasttemp,2,44)
    set %shoutcast.listeners $gettok(%scasttemp,1,44)
    set %shoutcast.maxlisteners $gettok(%scasttemp,4,44)
    set %shoutcast.peaklisteners $gettok(%scasttemp,3,44)
  }
  goto nextread
}
on *:sockclose:shoutcast.listeners:{
  if ( %shoutcast.status == 0 ) {
    did -ra shoutcast 7 error
  }
  else {
    did -ra shoutcast 7 %shoutcast.listeners $+ / $+ %shoutcast.maxlisteners
  }
}
on *:SOCKOPEN:shoutcast.peaklist:{
  if ($sockerr > 0) {
    did -ra shoutcast 10
    return
  }
  sockwrite -n $sockname GET /7.html HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla
  sockwrite -n $sockname $crlf
}
on *:sockread:shoutcast.peaklist:{
  if ($sockerr > 0) return
  :nextread
  sockread -f %scasttemp
  if ($sockbr == 0) return
  if (%scasttemp == $null) %scasttemp = empty
  set %scasttemp $remove(%scasttemp,<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>,</body></html> )
  if ((HTTP/1.* !iswm %scasttemp) && (content-type* !iswm %scasttemp) && (%scasttemp != empty)) {
    set %shoutcast.status $gettok(%scasttemp,2,44)
    set %shoutcast.peak $gettok(%scasttemp,3,44)
  }
  goto nextread
}
on *:sockclose:shoutcast.peaklist:{
  if ( %shoutcast.status == 0 ) {
    did -ra shoutcast 10 error could not connect
  }
  else {
    did -ra shoutcast 10 %shoutcast.peak
  }
}
on *:SOCKOPEN:shoutcast.bitrate:{
  if ($sockerr > 0) {
    set %shoutcast.errorformat %shoutcast.commandformat
    set %shoutcast.errorformat $replace(%shoutcast.errorformat,<CommandTopic>,Error)
    set %shoutcast.errorformat $replace(%shoutcast.errorformat,<CommandValue>,No Connection To Server!)
    msg %shoutcast.channel %shoutcast.errorformat
    return
  }
  sockwrite -n $sockname GET /7.html HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla
  sockwrite -n $sockname $crlf
}
on *:sockread:shoutcast.bitrate:{
  if ($sockerr > 0) return
  :nextread
  sockread -f %scasttemp
  if ($sockbr == 0) return
  if (%scasttemp == $null) %scasttemp = empty
  set %scasttemp $remove(%scasttemp,<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>,</body></html> )
  if ((HTTP/1.* !iswm %scasttemp) && (content-type* !iswm %scasttemp) && (%scasttemp != empty)) {
    set %shoutcast.bitrate $gettok(%scasttemp,6,44)
    set %shoutcast.status $gettok(%scasttemp,2,44)
  }
  goto nextread
}
on *:sockclose:shoutcast.bitrate:{
  if ( %shoutcast.status == 0 ) {
    did -ra shoutcast 12 error
  }
  else {
    did -ra shoutcast 12 %shoutcast.bitrate kbps
  }
}
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world