Shoutcast Stream Bot

By Soulkeeper on Sep 17, 2008

This isn't my snippet, but due to an extreme lack of seeing this type of snippet out there, I'm posting my friend Talon's snippet.

It's just a snippet for a bot, say if you have a shoutcast server, that'll query the server, and announce the song.

;#########################################
; Modify User/Pass/Host/Port then use
; "/cshout" to connect and fill hash table
; YOU WILL GET * Line too long: $+ ERRORS!
; what can i say, im lazy and mIRC SUX!
;#########################################
alias ShoutData { 
  if ($isid) {
    if ($1 = user) { return ***** }
    if ($1 = pass) { return ***** }
    if ($1 = host) { return ***** }
    if ($1 = port) { return ***** }
    if ($1 = Accept) { return CURRENTLISTENERS;PEAKLISTENERS;MAXLISTENERS;REPORTEDLISTENERS;AVERAGETIME;SERVERGENRE;SERVERURL;SERVERTITLE;SONGTITLE;SONGURL;IRC;ICQ;AIM;WEBHITS;STREAMHITS;STREAMSTATUS;BITRATE;CONTENT;VERSION;INDEX;LISTEN;PALM7;LOGIN;LOGINFAIL;PLAYED;ADMIN;UPDINFO }
  }
}
;#########################################
; $ShoutInfo(<data>) Improper use of this
; alias will return all possible choices
; Just look at the Accept in ShoutData
;#########################################
alias ShoutInfo {
  if ($istok($shoutdata(accept),$1,59)) { return $hget(ShoutInfo,$1) }
  else { return *** Improper Usage: use one of the following: $shoutdata(accept) }
}
alias SShout { sockwrite -n $1- }
alias CShout { hfree -w ShoutInfo | sockopen ShoutCast $ShoutData(host) $ShoutData(port) }
on *:sockclose:ShoutCast: { 
  echo -a Closed Scoket?
}
on *:sockopen:ShoutCast: {
  if ($sockerr > 0) { sockclose $sockname | return }
  else {
    SShout $sockname GET /admin.cgi?mode=viewxml HTTP/1.1
    SShout $sockname Authorization: Basic $encode($+($ShoutData(user),:,$ShoutData(pass)),m)
    SShout $sockname Referer: $+(http://,$ShoutData(host),:,$ShoutData(port))
    SShout $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)
    SShout $sockname Host: $+($ShoutData(host),:,$ShoutData(port))
    SShout $sockname Connection: Keep-Alive $+ $str($crlf,2)
  }
}
on *:sockread:ShoutCast: {
  if ($sockerr > 0) return
  :nextread | sockread -f %temp
  if ($sockbr == 0) return

  var %match = $regsub(%temp,/^HTTP\/1\.0 200 OK/g,$null,%temp)
  var %match = $regsub(%temp,/^Content\-Type\:text\/xml/g,$null,%temp)

  var %MaxLen = 900 | dec %MaxLen $len(%BackBuffer)
  var %Srch = $+(%BackBuffer,$mid(%temp,1,%MaxLen))
  inc %MaxLen | var %BackBuffer = $mid(%temp,%MaxLen)

  var %match = $regex(ShoutData,%Srch,/<(\w+?)>(.*?)<\/\1?>/msg)
  var %x = 0 , %y = 1 | while (%x < %match) { inc %x
    if ($istok($shoutdata(accept),$regml(ShoutData,%y),59)) { hadd -m ShoutInfo $regml(ShoutData,%y) $regml(ShoutData,$calc(%y + 1)) }
    inc %y 2
  }
  %match = $regsub(%temp,/<(\w+?)>.*?<\/\1?>/g,$null,%temp)
  if (%temp) { 
    var %match = $regsub(%temp,/<\?[^>]>/g,$null,%temp)
    var %match = $regsub(%temp,/<\![^>]>/g,$null,%temp)
    %BackBuffer = $+(%BackBuffer,%temp)
  }
  goto nextread
}

Comments

Sign in to comment.
akierry9   -  Mar 15, 2011

im cant use it!! why?! noting over thar

 Respond  
LucSatise   -  Mar 26, 2010

i got it workin but it doesnt update all the time for servertitle which is the main thing im trying to get

 Respond  
RicJames   -  Jun 15, 2009

i keep getting this error Closed Scoket?

 Respond  
Dangus   -  Mar 06, 2009

i need this script or similar script. Can anyone tell me how to install it to mirc? step by step? please :) im just started use mirc and i have no clue how it works and what i can to do to make scripts work on it. Please, if anyone spare a few minutes explain to me how do that, please please please :) :)

 Respond  
^Neptune   -  Nov 06, 2008

Doesn't work for me, and I have changed the port, host and password. I also edited user to Neptune, as I have no clue what that is supposed to be.

Everything returns: "* /echo: insufficient parameters".

Are you supposed to use this on a computer that hosts the radio itself? Because that's exactly what I'm doing here, and is suggested by the password bit.

 Respond  
AdrianF   -  Nov 06, 2008

cool

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.