Shoutcast Stream Bot
Platform: mIRC
Published Sep 17, 2008
Updated 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
}