Yet Another Shoutcast Script

By JustAUser on Dec 24, 2011

; Shoutcast Radio Script, needs admin/pass for the shoutcast radio server to use.

; I found a tutorial on some website for the socket, so I doubt it's anywhere near
; perfect and I know it can be improved by a lot, hell the entire script can be.
; However, it worked perfectly fine to grab the info, so I was satisfied with it.

; I'm not really an mSL scripter (obviously), so this script isn't really up to par.
; I wrote it up as a request by a friend who hosted a shoutcast server, he's decided
; to take down the radio station and irc and move on with his life, so I really have
; no use in running this script/the bot anymore. So, I've removed everything and I
; thought I'd post the script here on Hawkee for others to use.

; I decided to go with the Admin panel instead of the standard /7.html (I think thats
; the right name) because of all the info I could grab. Hope someone finds this useful.

; Usage:
; 1) Load script.
; 2) Edit/Change details
; 3) Save
; 4) Connect to IRC network
; 5) Type: !all (or whatever character you set for trigger)
; 6) Should display the information.

; Anyway: Enjoy.

on *:LOAD: { sca_vars }     ;Load vars on mIRC startup
on *:CONNECT: { sca_vars }  ;Sometimes, not often, mIRC would fail to load on startup, this made sure it did.

alias sca_vars {
  set %scc.serv 1.2.3.4     ;ip address to shoutcast server
  set %scc.port 1234        ;port to connect to
  set %scc.net CoolNetwork7 ;name of irc network
  set %scc.chan #CoolRadio  ;channel to respond in
  set %scc.me1 RadioBot     ;main nickname to use
  set %scc.me2 RadioB0t     ;alternative nickname to use
  set %scc.auser admin      ;shoutcast server admin username
  set %scc.apass passwd     ;shoutcast server admin password
  set %scc.trig !           ;trigger to use in the channel
}

on @*:TEXT:*:#:{ 
  if ($network == %scc.net) && ($chan == %scc.chan) && ($me === %scc.me1 || $me === %scc.me2) {
    if (%scc.spam >= 1) { .halt }
    else {
      if ($strip($1) == $+(%scc.trig,all)) { 
        .timer 1 0 set %scd.nick $nick
        .timer 1 0 set %scd.text $+(%scc.trig,all)
        .timer 1 1 sca_connect
      } 
    }
  }
}

on *:SOCKOPEN:shoutcast:{ 
  inc %scc.spam 
  sockwrite -nt $sockname GET /admin.cgi?mode=viewxml HTTP/1.1
  sockwrite -nt $sockname Accept: */*
  sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.642.2 Safari/534.16
  sockwrite -nt $sockname Authorization: Basic $encode(%scc.auser $+ : $+ %scc.apass, m)
  sockwrite -nt $sockname Host: $+(%scc.serv,:,%scc.port)
  sockwrite -nt $sockname Connection: Keep-Alive
  sockwrite -nt $sockname $crlf
}

on *:SOCKREAD:shoutcast:{ 
  if ($sockerr) { echo -s Socket Error: $sockerr | .halt }
  else {
    var &sc.tmp
    sockread &sc.tmp
    if ($bfind(&sc.tmp,1,<STREAMSTATUS>0)) { .sockclose $sockname | .notice %scd.nick Sorry %scd.nick $+ , the Stream is currently offline. | sca_del | .halt }
    if ($bfind(&sc.tmp,1,<STREAMSTATUS>1)) {
      var %scg.status = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<STREAMSTATUS>)),$calc($bfind(&sc.tmp,1,</STREAMSTATUS>) - $bfind(&sc.tmp,1,<STREAMSTATUS>))).text
      var %scg.title = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<SERVERTITLE>)),$calc($bfind(&sc.tmp,1,</SERVERTITLE>) - $bfind(&sc.tmp,1,<SERVERTITLE>))).text
      var %scg.url = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<SERVERURL>)),$calc($bfind(&sc.tmp,1,</SERVERURL>) - $bfind(&sc.tmp,1,<SERVERURL>))).text
      var %scg.song = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<SONGTITLE>)),$calc($bfind(&sc.tmp,1,</SONGTITLE>) - $bfind(&sc.tmp,1,<SONGTITLE>))).text
      var %scg.bitrate = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<BITRATE>)),$calc($bfind(&sc.tmp,1,</BITRATE>) - $bfind(&sc.tmp,1,<BITRATE>))).text
      var %scg.clist = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<CURRENTLISTENERS>)),$calc($bfind(&sc.tmp,1,</CURRENTLISTENERS>) - $bfind(&sc.tmp,1,<CURRENTLISTENERS>))).text
      var %scg.mlist = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<MAXLISTENERS>)),$calc($bfind(&sc.tmp,1,</MAXLISTENERS>) - $bfind(&sc.tmp,1,<MAXLISTENERS>))).text
      var %scg.plist = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<PEAKLISTENERS>)),$calc($bfind(&sc.tmp,1,</PEAKLISTENERS>) - $bfind(&sc.tmp,1,<PEAKLISTENERS>))).text
      var %scg.genre = $bvar(&sc.tmp,$calc($bfind(&sc.tmp,1,<SERVERGENRE>)),$calc($bfind(&sc.tmp,1,</SERVERGENRE>) - $bfind(&sc.tmp,1,<SERVERGENRE>))).text
      set %scs.status $replace($remove(%scg.status,<STREAMSTATUS>)%scg.status,1,Online,0,Offline)
      set %scs.title $replace($remove(%scg.title,<SERVERTITLE>)%scg.title,&#x22;,",&#x26;,&,&#x27;,',&#x3C;,<,&#x3E;,>,&#x152;,Œ,&#x153;,œ,&#x160;,Š,&#x161;,š,&#x178;,Ÿ,&#x2C6;,ˆ,&#x2DC;,˜,&#x2002;,$chr(32),&#x2003;,$chr(32),&#x2009;,$chr(32),&#x200C;,$chr(32),&#x200D;,$chr(32),&#x200E;,$chr(32),&#x200F;,$chr(32),&#x2013;,–,&#x2014;,—,&#x2018;,‘,&#x2019;,’,&#x201A;,‚,&#x201C;,“,&#x201D;,”,&#x201E;,„,&#x2020;,†,&#x2021;,‡,&#x2030;,‰,&#x2039;,‹,&#x203A;,›,&#x20AC;,€)
      set %scs.url $remove(%scg.url,<SERVERURL>)
      set %scs.song $replace($remove(%scg.song,<SONGTITLE>)%scg.song,&#x22;,",&#x26;,&,&#x27;,',&#x3C;,<,&#x3E;,>,&#x152;,Œ,&#x153;,œ,&#x160;,Š,&#x161;,š,&#x178;,Ÿ,&#x2C6;,ˆ,&#x2DC;,˜,&#x2002;,$chr(32),&#x2003;,$chr(32),&#x2009;,$chr(32),&#x200C;,$chr(32),&#x200D;,$chr(32),&#x200E;,$chr(32),&#x200F;,$chr(32),&#x2013;,–,&#x2014;,—,&#x2018;,‘,&#x2019;,’,&#x201A;,‚,&#x201C;,“,&#x201D;,”,&#x201E;,„,&#x2020;,†,&#x2021;,‡,&#x2030;,‰,&#x2039;,‹,&#x203A;,›,&#x20AC;,€)
      set %scs.bitrate $remove(%scg.bitrate,<BITRATE>)
      set %scs.clist $remove(%scg.clist,<CURRENTLISTENERS>)
      set %scs.mlist $remove(%scg.mlist,<MAXLISTENERS>)
      set %scs.plist $remove(%scg.plist,<PEAKLISTENERS>)
      set %scs.genre $replace($remove(%scg.genre,<SERVERGENRE>)%scg.genre,&#x22;,",&#x26;,&,&#x27;,',&#x3C;,<,&#x3E;,>,&#x152;,Œ,&#x153;,œ,&#x160;,Š,&#x161;,š,&#x178;,Ÿ,&#x2C6;,ˆ,&#x2DC;,˜,&#x2002;,$chr(32),&#x2003;,$chr(32),&#x2009;,$chr(32),&#x200C;,$chr(32),&#x200D;,$chr(32),&#x200E;,$chr(32),&#x200F;,$chr(32),&#x2013;,–,&#x2014;,—,&#x2018;,‘,&#x2019;,’,&#x201A;,‚,&#x201C;,“,&#x201D;,”,&#x201E;,„,&#x2020;,†,&#x2021;,‡,&#x2030;,‰,&#x2039;,‹,&#x203A;,›,&#x20AC;,€)
      if (%scd.text == $+(%scc.trig,all) ) { sca_sendall }
      .sockclose $sockname
    }
  }
}

alias sca_sendall { 
  .timer 1 00 .msg %scc.chan Stream is currently $+(%scs.status,.)
  .timer 1 01 .msg %scc.chan Stream URL: $+(%scs.url,/listen.pls)
  .timer 1 02 .msg %scc.chan Stream Title: %scs.title
  .timer 1 03 .msg %scc.chan Now Playing: %scs.song
  .timer 1 04 .msg %scc.chan Bitrate: $+(%scs.bitrate,kbps)
  .timer 1 05 .msg %scc.chan Listeners: %scs.clist
  .timer 1 06 .msg %scc.chan Max Listeners: %scs.mlist
  .timer 1 07 .msg %scc.chan Peak Listeners: %scs.plist
  .timer 1 08 .msg %scc.chan Stream Genre: %scs.genre
  .timer 1 11 sca_del
}

alias sca_connect { if ($sock(shoutcast)) { .sockclose shoutcast } | sockopen shoutcast %scc.serv %scc.port }
alias sca_del { unset %scs.* | unset %scd.* | unset %scc.spam }

Comments

Sign in to comment.
speedy   -  Mar 28, 2014

i have download more than 5 diverend kind of script and now one works. WTF am i doing wrong. i just want to display automaticly de song in my mirc room. can some one help me please????????

 Respond  
jasonh   -  Jan 07, 2012

doesnt work for me. using mirc 7.19

 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.