egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Domsen update to Shoutcast 2.4.7.256
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
flink
Voice


Joined: 21 Feb 2021
Posts: 33
Location: Canarias

PostPosted: Thu Sep 23, 2021 8:28 am    Post subject: Reply with quote

this is the json code
Code:
 
namespace eval radio {
   
   variable streamurl "https://playradio.nombredelaradio.com/api/nombredelaradio/nowplaying/montaje"
   variable radiochan "#yourchan"
   
   package require http
   package require tls

   
   variable cursong ""                                                                         
   
   bind pub - !direct ::radio::pub:getstream
   bind pub -|n !mute ::radio::mute
   bind pub -|n !unmute ::radio::unmute
   
   proc mute {nick uhost handle chan text} {
      unbind cron - "* * * * *" ::radio::getstream
   }
   
   proc unmute {nick uhost handle chan text} {
      bind cron - "* * * * *" ::radio::getstream
   }
   
   proc pub:getstream {nick uhost handle chan text} {
      if {[::string tolower $chan] ne $::radio::radiochan } {
         return
      }
      ::radio::getstream 0 0 0 0 0
   }
   
   proc getstream {mi ho da mo wd} {
      ::http::register https 443 ::tls::socket
      set tok [::http::geturl $::radio::streamurl]
      set source [::radio::json2dict [::http::data $tok]]
      ::http::cleanup $tok
      ::http::unregister https
      set title [dict get $source title]
      set artist [dict get $source artist]
      if {$::radio::cursong ne $title} {
         set ::radio::cursong $title
         set artist [encoding convertfrom utf-8 [string map {"&" "&"} $artist]]
         set title [encoding convertfrom utf-8 [string map {"&" "&"} $title]]
         putserv "PRIVMSG $::radio::radiochan :Now streaming : \002\00303$title\003\002 by \002\00307$artist\003\002"
      }
   }
   
   proc json2dict {JSONtext} {
      string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
   }
}




this is the code of the shoutcast script that does the function of sending the songs, if the Dj is live or in Dj autoplay the link and etc.
Code:

proc isonline { nick uhost hand chan arg } {
   global radiochans announce tellusers tellsongs tellbitrate urltopic dj
   global offlinetext offlinetopic onlinetext onlinetopic
   global streamip streampass streamport dj
   global doalertadmin alertadmin

   if {$announce == 1 || $tellsongs == 1 || $tellusers == 1 || $tellbitrate == 1} {
      set isonlinefile "isonline.txt"
      set oldisonline "isonline: 0"
      set oldcurlist "curlist: 0"
      set oldcurhigh "curhigh: 0"
      set oldsong "cursong: 0"
      set oldbitrate "bitrate: 0"
      if {[file exists $isonlinefile]} {
         putlog "shoutcast: checking if stream is online"
         set temp [open "isonline.txt" r]
         while {[eof $temp] != 1} {
            set zeile [gets $temp]
            if {[string first "isonline:" $zeile] != -1 } { set oldisonline $zeile }
            if {[string first "curlist:" $zeile] != -1 } { set oldcurlist $zeile }
            if {[string first "curhigh:" $zeile] != -1 } { set oldcurhigh $zeile }
            if {[string first "cursong:" $zeile] != -1 } { set oldsong $zeile }
            if {[string first "bitrate:" $zeile] != -1 } { set oldbitrate $zeile }
         }
         close $temp
      }
      if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
         putlog "error: $sockerror"
         return 0} else {
         puts $sock "GET /admin.cgi?sid=1&pass=$streampass&mode=viewxml&page=0 HTTP/1.1"
         puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
         puts $sock "Host: $streamip"
         puts $sock "Connection: close"
         puts $sock ""
         flush $sock
         while {[eof $sock] != 1} {
            set bl [gets $sock]
            if { [string first "standalone" $bl] != -1 } {
               set streamstatus "isonline: [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]"
               set repl "curlist: [string range $bl [shrink + 19 "<UNIQUELISTENERS>" 0 $bl] [shrink - 1 "</UNIQUELISTENERS>" 0 $bl]]"
               set curhigh "curhigh: [string range $bl [shrink + 15 "<PEAKLISTENERS>" 0 $bl] [shrink - 1 "</PEAKLISTENERS>" 0 $bl]]"
               set currentl [string range $bl [shrink + 18 "<CURRENTLISTENERS>" 0 $bl] [shrink - 1 "</CURRENTLISTENERS>" 0 $bl]]
               set surl "serverurl: [string range $bl [shrink + 11 "<SERVERURL>" 0 $bl] [shrink - 1 "</SERVERURL>" 0 $bl]]"
               set cursong "cursong: [string range $bl [shrink + 11 "<SONGTITLE" 0 $bl] [shrink - 1 "</SONGTITLE>" 0 $bl]]"
               set songurl [string range $bl [shrink + 9 "<SONGURL>" 0 $bl] [shrink - 1 "</SONGURL>" 0 $bl]]
               set bitrate "bitrate: [string range $bl [shrink + 9 "<BITRATE>" 0 $bl] [shrink - 1 "</BITRATE>" 0 $bl]]"
               set stitle "stitle: [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]"
               set sgenre "sgenre: [string range $bl [shrink + 13 "<SERVERGENRE>" 0 $bl] [shrink - 1 "</SERVERGENRE>" 0 $bl]]"
            }
         }
         close $sock
      }
      set temp [open "isonline.txt" w+]
      puts $temp "$streamstatus\n$repl\n$curhigh\n$cursong\n$bitrate\n$stitle\n$sgenre\n$surl"
      close $temp
      if {$announce == 1 } {
         if {![info exists streamstatus]} { poststuff privmsg $offlinetext }
         if {$streamstatus == "isonline: 0" && $oldisonline == "isonline: 1"} {
            poststuff privmsg $offlinetext
            if {$doalertadmin == "1"} { sendnote domsen $alertadmin "radio is now offline" }
            if {$urltopic == 1} { poststuff topic $offlinetopic }
         }
         if {$streamstatus == "isonline: 1" && $oldisonline == "isonline: 0" } {
            if {$sgenre != ""} {
               set sgenre " ([lrange $sgenre 1 [llength $sgenre]] )"
            }
            poststuff privmsg "$onlinetext"
            if {$urltopic == 1} { poststuff topic "$onlinetopic" }
         }
      }
      if {($tellusers == 1) && ($streamstatus == "isonline: 1") && ($oldcurhigh != "curhigh: 0") } {
         if {$oldcurhigh != $curhigh} {
            poststuff privmsg "new listener peak: [lindex $curhigh 1]"
         }
         if {$oldcurlist != $repl} {
            poststuff privmsg "there are currently [lindex $repl 1] ($currentl) people listening"
         }
      }
      if {($tellsongs == 1) && ($oldsong != $cursong) && ($streamstatus == "isonline: 1") } {
         if {$songurl != ""} { set songurl " ($songurl)"}
         regsub -all "&#x3C;" $cursong "<" cursong
         regsub -all "&#x3E;" $cursong ">" cursong
         regsub -all "&#x26;" $cursong "+" cursong
         regsub -all "&#x22;" $cursong "\"" cursong
         regsub -all "&#x27;" $cursong "'" cursong
         regsub -all "&#xFF;" $cursong "" cursong
         regsub -all "&#xB4;" $cursong "" cursong
         regsub -all "&#x96;" $cursong "-" cursong
         regsub -all "&#xF6;" $cursong "" cursong
         regsub -all "&#xE4;" $cursong "" cursong
         regsub -all "&#xFC;" $cursong "" cursong
         regsub -all "&#xD6;" $cursong "" cursong
         regsub -all "&#xC4;" $cursong "" cursong
         regsub -all "&#xDC;" $cursong "" cursong
         regsub -all "&#xDF;" $cursong "" cursong
         regsub -all "&apos;" $cursong "'" cursong
         putlog $cursong
         poststuff privmsg "\007Now Playing\007: [lrange $cursong 1 [llength $cursong]]$songurl"
      }

      if {($tellbitrate == 1) && ($oldbitrate != $bitrate) && ($streamstatus == "isonline: 1") && ($oldbitrate != "bitrate: 0")} {
         poststuff privmsg "bitrate switched to [lindex $bitrate 1]kbps"
      }
   }
}

putlog "*** shoutcast.tcl v1.03XXX by Domsen updated by RickTee76 <domsen@domsen.org> succesfully loaded. turn it up baby."




I wonder if there is a way to insert the json into the shoutcast script and have it perform the same function as this part of the original script. thanks a lot.
thanks to the people who help and contribute to see if it is solved.

_________________
Mi ingles: no es el mejor, Manda el traductor... Smile
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 882
Location: France

PostPosted: Thu Sep 23, 2021 8:33 am    Post subject: Reply with quote

The thing we need is what your shoutcast server (not the script, the shoutcat server) send or can send when you go to https://your.shoutcast.server/admin.cgi?sid=1&pass=yourpass&page=0&mode=viewxml

And to know if you can have another output than xml, probably by changing the mode value in the url.
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
flink
Voice


Joined: 21 Feb 2021
Posts: 33
Location: Canarias

PostPosted: Thu Sep 23, 2021 9:25 am    Post subject: Reply with quote

thanks CrazyCat for replying where can I get that info my server is zeno.fm free account would be in the control panel which I have the data of the radio,
Shoutcast Stream Encoder Configuration
ip
port
DJ / User ID
password
Sid
if this is what you need let me know and I will pass it to you via private message, thank you very much.

I leave the web of where I guessed api with which you made me the json
if you get the data that you ask me I do not know how to get them thank you again
https://zeno.fm/angelescaidos/
_________________
Mi ingles: no es el mejor, Manda el traductor... Smile
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 882
Location: France

PostPosted: Thu Sep 23, 2021 10:07 am    Post subject: Reply with quote

Sorry, but you have to ask your radio provider, I can help with the tcl part but I can't do anything else.
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
flink
Voice


Joined: 21 Feb 2021
Posts: 33
Location: Canarias

PostPosted: Thu Sep 23, 2021 12:17 pm    Post subject: Reply with quote

ok CrazyCat thank you, I will talk to the server staff to see if they can reveal this information to me and I will pass it on to you so that you can help me, thank you very much for taking another step to solve the problem, as soon as I know something I will comment here, again thank you very much.
_________________
Mi ingles: no es el mejor, Manda el traductor... Smile
Back to top
View user's profile Send private message
flink
Voice


Joined: 21 Feb 2021
Posts: 33
Location: Canarias

PostPosted: Sat Oct 02, 2021 4:54 am    Post subject: Reply with quote

well at the end I am trying with a centova panel and it goes great with shoutcast v1 and well but I have a problem to see if they help me to solve it in the titles of the songs when they carry accent does not read them and releases in the room a lot of strange signs to see if you have a solution and tell me how to fix it thank you very much as always

this would be the originals : Vctor Manuelle - Si T Me besas
Gloria Trevi & Alejandra Guzmn - Ms Buena
No Doubt - Don't Speak
Lola Indigo, TINI, Belinda - Nia de la Escuela

these the ones that it throws : Víctor Manuelle - Si Tú Me Besas
Gloria Trevi {&amp;} Alejandra Guzmán - Más Buena
No Doubt - {Don&apos;t} Speak
Lola Indigo, TINI, Belinda - Niña de la Escuela

as it is seen when the words have accents or does not read them.
_________________
Mi ingles: no es el mejor, Manda el traductor... Smile
Back to top
View user's profile Send private message
flink
Voice


Joined: 21 Feb 2021
Posts: 33
Location: Canarias

PostPosted: Fri Nov 19, 2021 12:53 pm    Post subject: Reply with quote

no one has responded, can anyone help?
_________________
Mi ingles: no es el mejor, Manda el traductor... Smile
Back to top
View user's profile Send private message
play4free2
Voice


Joined: 23 Nov 2013
Posts: 33

PostPosted: Fri Nov 19, 2021 7:41 pm    Post subject: Reply with quote

flink wrote:
no one has responded, can anyone help?


Replace this part of the code
Code:

         regsub -all "&#x3C;" $cursong "<" cursong
         regsub -all "&#x3E;" $cursong ">" cursong
         regsub -all "&#x26;" $cursong "+" cursong
         regsub -all "&#x22;" $cursong "\"" cursong
         regsub -all "&#x27;" $cursong "'" cursong
         regsub -all "&#xFF;" $cursong "" cursong
         regsub -all "&#xB4;" $cursong "" cursong
         regsub -all "&#x96;" $cursong "-" cursong
         regsub -all "&#xF6;" $cursong "" cursong
         regsub -all "&#xE4;" $cursong "" cursong
         regsub -all "&#xFC;" $cursong "" cursong
         regsub -all "&#xD6;" $cursong "" cursong
         regsub -all "&#xC4;" $cursong "" cursong
         regsub -all "&#xDC;" $cursong "" cursong
         regsub -all "&#xDF;" $cursong "" cursong
         regsub -all "&apos;" $cursong "'" cursong
         putlog $cursong
         poststuff privmsg "\007Now Playing\007: [lrange $cursong 1 [llength $cursong]]$songurl"
}


With this code
Code:
      regsub -all "&#x3C;" $cursong "<" cursong
      regsub -all "&#x3E;" $cursong ">" cursong
      regsub -all "&#x26;" $cursong "\&" cursong
      regsub -all "&#x22;" $cursong "\"" cursong
      regsub -all "&#x27;" $cursong "'" cursong
      regsub -all "&#xFF;" $cursong "" cursong
      regsub -all "&#xB4;" $cursong "" cursong
      regsub -all "&#x96;" $cursong "-" cursong
      regsub -all "&#xF6;" $cursong "" cursong
      regsub -all "&#xE4;" $cursong "" cursong
      regsub -all "&#xFC;" $cursong "" cursong
      regsub -all "&#xD6;" $cursong "" cursong
      regsub -all "&#xC4;" $cursong "" cursong
      regsub -all "&#xDC;" $cursong "" cursong
      regsub -all "&#xDF;" $cursong "" cursong
      regsub -all "&#xE9;" $cursong "" cursong
      regsub -all "&#xE1;" $cursong "" cursong
      regsub -all "&#xEB;" $cursong "" cursong
      regsub -all "&#xF1;" $cursong "" cursong
      regsub -all "{" $cursong "" cursong
      regsub -all "}" $cursong "" cursong
      putlog $cursong
      poststuff privmsg "\007Now Playing\007: [lrange $cursong 1 [llength $cursong]]$songurl"
}


That should fix a few of your errors, it did mine.
You can also look here: https://www.utf8-chartable.de/unicode-utf8-table.pl?number=1024&unicodeinhtml=hex for more Unicode Hex Characters if you need them.

Like the &#xF1; etc.
_________________

420-HIGHTIMES IRC Network
Back to top
View user's profile Send private message Visit poster's website
ORATEGOD
Voice


Joined: 08 Jun 2020
Posts: 23

PostPosted: Sat Nov 20, 2021 2:11 pm    Post subject: Reply with quote

flink wrote:
thanks CrazyCat for replying where can I get that info my server is zeno.fm free account would be in the control panel which I have the data of the radio,
Shoutcast Stream Encoder Configuration
ip
port
DJ / User ID
password
Sid
if this is what you need let me know and I will pass it to you via private message, thank you very much.

I leave the web of where I guessed api with which you made me the json
if you get the data that you ask me I do not know how to get them thank you again
https://zeno.fm/angelescaidos/

Saludos amigo .... consulta!! ... pudiste correr el tcl en zeno ??
Back to top
View user's profile Send private message AIM Address
flink
Voice


Joined: 21 Feb 2021
Posts: 33
Location: Canarias

PostPosted: Sat Nov 20, 2021 4:16 pm    Post subject: Reply with quote

thanks for the answer, play4free2 but it has not corrected the error. i also looked at the link you left and everything is ok but it keeps giving me the same errors as soon as they come up &,",',',`.

Tainy, Bad Bunny, Julieta Venegas - Lo Siento BB
Tainy · Bad Bunny · Julieta Venegas - Lo Siento BB


Helen Reddy - You're My World
Helen Reddy - {You&apos;re} My World
_________________
Mi ingles: no es el mejor, Manda el traductor... Smile
Back to top
View user's profile Send private message
flink
Voice


Joined: 21 Feb 2021
Posts: 33
Location: Canarias

PostPosted: Sat Nov 20, 2021 4:20 pm    Post subject: Reply with quote

ORATEGOD wrote:
flink wrote:
thanks CrazyCat for replying where can I get that info my server is zeno.fm free account would be in the control panel which I have the data of the radio,
Shoutcast Stream Encoder Configuration
ip
port
DJ / User ID
password
Sid
if this is what you need let me know and I will pass it to you via private message, thank you very much.

I leave the web of where I guessed api with which you made me the json
if you get the data that you ask me I do not know how to get them thank you again
https://zeno.fm/angelescaidos/

Saludos amigo .... consulta!! ... pudiste correr el tcl en zeno ??

Saludos ORATEGOD ... Nada pille un panel centova y ahora si hace lo que necesitaba, gracias
_________________
Mi ingles: no es el mejor, Manda el traductor... Smile
Back to top
View user's profile Send private message
play4free2
Voice


Joined: 23 Nov 2013
Posts: 33

PostPosted: Tue Nov 23, 2021 12:34 am    Post subject: Reply with quote

flink wrote:
thanks for the answer, play4free2 but it has not corrected the error. i also looked at the link you left and everything is ok but it keeps giving me the same errors as soon as they come up &,",',',`.

Tainy, Bad Bunny, Julieta Venegas - Lo Siento BB
Tainy · Bad Bunny · Julieta Venegas - Lo Siento BB


Helen Reddy - You're My World
Helen Reddy - {You&apos;re} My World


This is the complete code I am currently using for my Shoutcast Server v2.6.0.753 Eggdrop v1.8.4 and Anope 1.8.9

It will work with Anope 2.0.x if you change this line:

Code:
if {$advertiseglobal == "1" && $advertiseonlyifonline == "0"} { putserv "PRIVMSG OperServ :GLOBAL $globaltext" }


To this:
Code:
if {$advertiseglobal == "1" && $advertiseonlyifonline == "0"} { putserv "PRIVMSG GLOBAL :GLOBAL $globaltext" }



Code:
###############################################################################################################
#
# shoutcast.tcl v2.00
# copyleft (c) 2o21 - play4free2 & cards
#
# Based on the original shoutcast.tcl v1.03 by domsen <domsen@domsen.org> (c)2oo5
# Also some parts are based on shoutcast.tcl by Sm0ke0ut
#
# This displays the current song, bitrate, and stream title plus
# listen link(s), page link(s) and website link into the public channel(s)
# It also sends all request to the radio's staff channel.
#
# Also this script will have the bot kick the source from the shoutcast radio server,
# from the Radio's staff channel and requires Ops in the channel for it to work.
# It also displays listerners, peak listeners, the shoutcast server status and
# the admin login link to the radio's staff channel.
#
# Last but not least it auto announces the current song and link(s) into public channel(s)
#
# To enable in your channel(s) Type: .chanset <channel> +radio +shoutgreet +shoutauto +shoutadmin
#
# Public Commands: !radio !song !link !dj !request !website and !page
# Staff Channel Commands: !kickdj !listeners !peak !server !admin
#
# Channel Setup Fill in: Radio Station URL or IP and Port, DJ Staff Channel,
# Listen link(s), Radio Station Page(s), Radio Station Website and Admin login link.
# Also fill in: streamip streamport streampass
# You will need these even if you don't use the auto announce for !kickdj to work.
#
# Auto Announce Setup:
# streamip - the ip of your radio
# streamport - the port of your radio
# streampass - the admin pass of your radio
#
# alertadmin - the userhandle of the user who will get a msg if the server goes down
# doalertadmin - 1 if you want to get a msg if the server goes offline, 0 if you
#                dont. this is done through the bots notes system because its
#                more comfortable and persistent this way.
#
# announce - shall the bot announce any stuff? 1 for yes, 0 for no
# urltopic - shall the bot change the topic everytime the radio goes on or off?
# NOTE: If enable urltopic and have +radio set to multipal channels it will change the topic in all of them.
#
# tellsongs - shall the bot post the songtitle to the channels everytime a new song starts?
# tellusers - shall the bot post the number of current users to the channel
#             everytime it changes or a new user maximum is reached?
# tellbitrate - shall the bot announce bitrate changes?
#
# offlinetext - the reason the bot says when the radio goes offline
# offlinetopic - the topic which is set when the radio goes offline
#
# onlinetext - the reason the bot says when the radio goes online
# onlinetopic - the topic which is set when the radio goes online
#
# advertise1 - shall the bot advertise the advertisetext1?
# advertise2 - shall the bot advertise the advertisetext2?
#
# advertiseglobal - shall the bot advertise the globaltext?
# NOTE: The bot must have access to OperServ Global command.
#
# advertiseonlyifonline - 1 if the bot only should advertise the radio and to globals if the stream
#                         is up and running, 0 for all-the-time advertisement
#
# globaltext - the global message the bot sends to all channels every hour on the full.
#
# advertisetext1 - the first line of text the bot will post 3 times an hour on the full 20th. and 40th. min.
# advertisetext2 - the second line of text the bot will post 3 times an hour on the 10th. 30th. and 50th. min.
#
# how do I put veriables in the different texts and topics?
###############################################################################################################
#
# the script knows the following variables which can be used in the offlinetext,
# offlinetopic, onlinetext, onlinetopic, streamtext and advertisetext:
#
# /dj/ - the djnickname
# /sgenre/ - the servers music genre
# /stitle/ - the streamtitle
# /surl/ - the servers url
# /bitrate/ - the current streaming bitrate
# /curlist/ - current listeners
# /curhigh/ - current listener peak
# /cursong/ - the current song
# $streamip - the streams ip
# $streamport - the streams port
#
###############################################################################################################
#Begin Setup
set streamip "your.radio.station.com"
set streamport "8000"
set streampass "Admin Password"
set streamid "1"

set alertadmin "0"
set doalertadmin "0"

set announce "1"

#See NOTE
set urltopic "0"

set tellsongs "1"
set tellusers "0"
set tellbitrate "0"

set advertise1 "1"
set advertise2 "1"

#See NOTE
set advertiseglobal "1"

set advertiseonlyifonline "1"

set offlinetext "\00304Your Radio Station is offline now \00303:'(\003"
set offlinetopic "Set your offline topic here"

set onlinetext "\00304Your Radio Station is now online at \00303(/surl/)\003"
set onlinetopic "/dj/@/stitle/ @ /surl/ streaming at /bitrate/kbps"

set advertisetext1 "\00304Winamp \00303(http://your.radio.station/listen.pls) \00304Request Link \00303(https://www.your.radio.station.com/#Playlist)\003"
set advertisetext2 "\00304Windows Media Player \00303(https//:your.radio.station.m3u) \00304RealPlayer \00303(https://your.radio.station.com/listen.ram)\003"

#Global message the bot will post:
#See NOTE
set globaltext "\00304Tune in to Your Radio Station! It's the \00303'Official' \00304Radio station on irc.your.radio.station.com - Winamp \00303http://your.radio.station.com/listen.pls \00304Windows Media Player \00303https://your.radio.station.com/listen.m3u \00304RealPlayer \00303https://your.radio.station.com/listen.ram \00304Join #YourRadioStationChannel for music - Thx for listening!\003"

#Radio Station URL or IP and Port:
set url "http://your.radio.station.com:8000"

#DJ Staff Channel:
set radiostaff "#RadioStaffChannel"

#Listen links:
set linktext1 "\00304Winamp \00303(http://your.radio.station.com/listen.pls) \00304Request Link \00303(https://your.radio.station.com/#Playlist)\003"
set linktext2 "\00304Windows Media Player \00303(https://your.radio.station.com/listen.m3u) \00304RealPlayer \00303(https://your.radio.station.com/listen.ram)\003"

#Radio Station Pages:
set pagetext "\00304Facebook \00303(https://www.facebook.com/your.station.com) \00304Twitter \00303(https://twitter.com/your.station.com)\003"

#Radio Station Website:
set webtext "\00304Station's Website \00303(https://www.your.radio.station.com)\003"

#Admin login link:
set admintext "\00304\002Admin login\002: \00303(http://your.radio.station.com/admin.cgi)\003"
#End Setup
#########################################################
#DO NOT EDIT BELOW HERE UNLESS YOU KNOW HOW TO WRITE .tcl
#########################################################
bind cron - {* * * * *} isonline

bind cron - {0 */1 * * *} advertise1
bind cron - {20 */1 * * *} advertise1
bind cron - {40 */1 * * *} advertise1

bind cron - {10 */1 * * *} advertise2
bind cron - {30 */1 * * *} advertise2
bind cron - {50 */1 * * *} advertise2

bind cron - {0 */1 * * *} advertiseglobal

set dj ""
set surl ""
set bitrate ""
set stitle ""

proc shrink { calc number string start bl } {
  return [expr [string first "$string" $bl $start] $calc $number]
}

proc status { } {
  global streamip streamport streampass streamid
  if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
    putlog "error: $sockerror"
    return 0
  } else {
    puts $sock "GET /stats?sid=&$streamid&pass=$streampass HTTP/1.0"
    puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
    puts $sock "Host: $streamip"
    puts $sock "Connection: close"
    puts $sock ""
    flush $sock
    while {[eof $sock] != 1} {
      set bl [gets $sock]
      if { [string first "standalone" $bl] != -1 } {
        set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
      }
    }
    close $sock
  }
  if { $streamstatus == "1" } { return 1 } else { return 0 }
}

proc poststuffb { chand mode text } {
  global radiochans dj
  set curlist "0"
  set curhigh "0"
  set surl ""
  set cursong ""
  set sgenre ""
  set bitrate "0"
  set stitle ""
  set temp [open "isonline" r]
  while {[eof $temp] != 1} {
    set zeile [gets $temp]
    if {[string first "curlist:" $zeile] != -1 } { set curlist $zeile }
    if {[string first "curhigh:" $zeile] != -1 } { set curhigh $zeile }
    if {[string first "cursong:" $zeile] != -1 } { set cursong [lrange $zeile 1 [llength $zeile]] }
    if {[string first "sgenre:" $zeile] != -1 } { set sgenre [lrange $zeile 1 [llength $zeile]]}
    if {[string first "serverurl:" $zeile] != -1 } { set surl [lindex $zeile 1] }
    if {[string first "bitrate:" $zeile] != -1 } { set bitrate [lindex $zeile 1] }
    if {[string first "stitle:" $zeile] != -1 } { set stitle [lrange $zeile 1 [llength $zeile]] }
    if {[string first "dj:" $zeile] != -1 } { set dj [lrange $zeile 1 [llength $zeile]] }
  }
  close $temp
  set stitle [string map {& \\&} $stitle]
  set cursong [string map {& \\&} $cursong]
  regsub -all "/stitle/" $text "$stitle" text
  regsub -all "/curlist/" $text "$curlist" text
  regsub -all "/curhigh/" $text "$curhigh" text
  regsub -all "/cursong/" $text "$cursong" text
  regsub -all "/sgenre/" $text "$sgenre" text
  regsub -all "/surl/" $text "$surl" text
  regsub -all "/bitrate/" $text "$bitrate" text
  regsub -all "/dj/" $text "$dj" text
  regsub -all "{" $text "" text
  regsub -all "}" $text "" text
  regsub -all {\\} $text "" text
  putserv "$mode $chand :$text"
  putlog $text
}

proc poststuff { mode text } {
  global radiochans dj streamid
  set curlist "0"
  set curhigh "0"
  set surl ""
  set cursong ""
  set sgenre ""
  set bitrate "0"
  set stitle ""
  set temp [open "isonline" r]
  while {[eof $temp] != 1} {
    set zeile [gets $temp]
    if {[string first "curlist:" $zeile] != -1 } { set curlist $zeile }
    if {[string first "curhigh:" $zeile] != -1 } { set curhigh $zeile }
    if {[string first "cursong:" $zeile] != -1 } { set cursong [lrange $zeile 1 [llength $zeile]] }
    if {[string first "sgenre:" $zeile] != -1 } { set sgenre [lrange $zeile 1 [llength $zeile]] }
    if {[string first "serverurl:" $zeile] != -1 } { set surl [lindex $zeile 1] }
    if {[string first "bitrate:" $zeile] != -1 } { set bitrate [lindex $zeile 1] }
    if {[string first "stitle:" $zeile] != -1 } { set stitle [lrange $zeile 1 [llength $zeile]] }
    if {[string first "dj:" $zeile] != -1 } { set dj [lrange $zeile 1 [llength $zeile]] }
  }
  close $temp
  set stitle [string map {& \\&} $stitle]
  set cursong [string map {& \\&} $cursong]
  regsub -all "/stitle/" $text "$stitle" text
  regsub -all "/curlist/" $text "$curlist" text
  regsub -all "/curhigh/" $text "$curhigh" text
  regsub -all "/cursong/" $text "$cursong" text
  regsub -all "/sgenre/" $text "$sgenre" text
  regsub -all "/surl/" $text "$surl" text
  regsub -all "/bitrate/" $text "$bitrate" text
  regsub -all "/dj/" $text "$dj" text
  regsub -all "{" $text "" text
  regsub -all "}" $text "" text
  regsub -all {\\} $text "" text
  foreach chan [channels] {
    if {[lsearch -exact [channel info $chan] +shoutauto] != -1} {putserv "$mode $chan :$text"}
  }
  putlog $text
}

proc advertise1 { nick uhost hand chan arg } {
  global advertisetext1 advertise1 advertiseonlyifonline streamid
  if {$advertise1 == "1" && $advertiseonlyifonline == "0"} { poststuff privmsg "$advertisetext1" }
  if {$advertise1 == "1" && $advertiseonlyifonline == "1" && [status] == 1} { poststuff privmsg "$advertisetext1" }
}

proc advertise2 { nick uhost hand chan arg } {
  global advertisetext2 advertise2 advertiseonlyifonline streamid
  if {$advertise2 == "1" && $advertiseonlyifonline == "0"} { poststuff privmsg "$advertisetext2" }
  if {$advertise2 == "1" && $advertiseonlyifonline == "1" && [status] == 1} { poststuff privmsg "$advertisetext2" }
}

proc advertiseglobal { minute hour day month year } {
  global globaltext advertiseglobal advertiseonlyifonline streamid
  if {$advertiseglobal == "1" && $advertiseonlyifonline == "0"} { putserv "PRIVMSG OperServ :GLOBAL $globaltext" }
  if {$advertiseglobal == "1" && $advertiseonlyifonline == "1" && [status] == 1} { putserv "PRIVMSG OperServ :GLOBAL $globaltext" }
}

proc isonline { nick uhost hand chan arg } {
  global radiochans announce tellusers tellsongs tellbitrate urltopic dj
  global offlinetext offlinetopic onlinetext onlinetopic
  global streamip streampass streamport dj streamid
  global doalertadmin alertadmin
  # if we cannot determine status this will assume it is offline
  # keeps tcl errors from lacking required streamstatus variable.
  set streamstatus "isonline: 0"

  if {$announce == 1 || $tellsongs == 1 || $tellusers == 1 || $tellbitrate == 1} {
    set isonlinefile "isonline"
    set oldisonline "isonline: 0"
    set oldcurlist "curlist: 0"
    set oldcurhigh "curhigh: 0"
    set oldsong "cursong: 0"
    set oldbitrate "bitrate: 0"
    if {[file exists $isonlinefile]} {
      set temp [open "isonline" r]
      while {[eof $temp] != 1} {
        set zeile [gets $temp]
        if {[string first "isonline:" $zeile] != -1 } { set oldisonline $zeile }
        if {[string first "curlist:" $zeile] != -1 } { set oldcurlist $zeile }
        if {[string first "curhigh:" $zeile] != -1 } { set oldcurhigh $zeile }
        if {[string first "cursong:" $zeile] != -1 } { set oldsong $zeile }
        if {[string first "bitrate:" $zeile] != -1 } { set oldbitrate $zeile }
    }
      close $temp
    }
    if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
      putlog "error: $sockerror"
      return 0
    } else {
      puts $sock "GET /stats?sid=$streamid&pass=$streampass HTTP/1.0"
      puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
      puts $sock "Host: $streamip"
      puts $sock "Connection: close"
      puts $sock ""
      flush $sock
      while {[eof $sock] != 1} {
        set bl [gets $sock]
        if { [string first "standalone" $bl] != -1 } {
          set streamstatus "isonline: [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]"
          set repl "curlist: [string range $bl [shrink + 17 "<UNIQUELISTENERS>" 0 $bl] [shrink - 1 "</UNIQUELISTENERS>" 0 $bl]]"
          set curhigh "curhigh: [string range $bl [shrink + 15 "<PEAKLISTENERS>" 0 $bl] [shrink - 1 "</PEAKLISTENERS>" 0 $bl]]"
          set currentl [string range $bl [shrink + 18 "<CURRENTLISTENERS>" 0 $bl] [shrink - 1 "</CURRENTLISTENERS>" 0 $bl]]
          set surl "serverurl: [string range $bl [shrink + 11 "<SERVERURL>" 0 $bl] [shrink - 1 "</SERVERURL>" 0 $bl]]"
          set cursong "cursong: [string range $bl [shrink + 11 "<SONGTITLE" 0 $bl] [shrink - 1 "</SONGTITLE>" 0 $bl]]"
          set songurl "surl: [string range $bl [shrink + 9 "<SONGURL>" 0 $bl] [shrink - 1 "</SONGURL>" 0 $bl]]"
          set bitrate "bitrate: [string range $bl [shrink + 9 "<BITRATE>" 0 $bl] [shrink - 1 "</BITRATE>" 0 $bl]]"
          set stitle "stitle: [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]"
          set sgenre "sgenre: [string range $bl [shrink + 13 "<SERVERGENRE>" 0 $bl] [shrink - 1 "</SERVERGENRE>" 0 $bl]]"
     set dj "dj: [string range $bl [shrink + 4 "<DJ>" 0 $bl] [shrink - 1 "</DJ>" 0 $bl]]"
        }
      }
      close $sock
#      putlog $cursong
      set cursong [string map {[ \\[} $cursong]
      set cursong [string map {&#x26; \\&} $cursong]
      set cursong [string map {$ \\$} $cursong]
      #regsub -all "&#x26;" $cursong "\&" cursong
      #set cursong [string map {& \\&} $cursong]
      regsub -all -nocase "&amp;" $cursong "\\&" cursong
      regsub -all "&#x3C;" $cursong "<" cursong
      regsub -all "&#x3E;" $cursong ">" cursong
      regsub -all "&#x26;" $cursong "\&" cursong
      regsub -all "&#x22;" $cursong "\"" cursong
      regsub -all "&#x27;" $cursong "'" cursong
      regsub -all "&#xFF;" $cursong "" cursong
      regsub -all "&#xB4;" $cursong "" cursong
      regsub -all "&#x96;" $cursong "-" cursong
      regsub -all "&#xF6;" $cursong "" cursong
      regsub -all "&#xE4;" $cursong "" cursong
      regsub -all "&#xFC;" $cursong "" cursong
      regsub -all "&#xD6;" $cursong "" cursong
      regsub -all "&#xC4;" $cursong "" cursong
      regsub -all "&#xDC;" $cursong "" cursong
      regsub -all "&#xDF;" $cursong "" cursong
      regsub -all "&#xE9;" $cursong "" cursong
      regsub -all "&#xE1;" $cursong "" cursong
      regsub -all "&#xEB;" $cursong "" cursong
      regsub -all "&#xF1;" $cursong "" cursong
      regsub -all "&apos;" $cursong "'" cursong
      regsub -all "{" $cursong "" cursong
      regsub -all "}" $cursong "" cursong
 #     putlog $cursong

      set temp [open "isonline" w+]
      puts $temp "$streamstatus\n$repl\n$curhigh\n$cursong\n$bitrate\n$stitle\n$sgenre\n$surl\n$dj"
      close $temp
      if {$announce == 1 } {
        if {$streamstatus == "isonline: 0" && $oldisonline == "isonline: 1"} {
          poststuff privmsg $offlinetext
          if {$doalertadmin == 1} { $alertadmin "radio is now offline" }
          if {$urltopic == 1} { poststuff topic $offlinetopic }
        }
        if {$streamstatus == "isonline: 1" && $oldisonline == "isonline: 0" } {
          if {$sgenre != ""} {
            set sgenre " ([lrange $sgenre 1 [llength $sgenre]] )"
          }
          poststuff privmsg "$onlinetext"
          if {$urltopic == 1} { poststuff topic "$onlinetopic" }
        }
      }
    }
    if {$tellusers == 1 && $streamstatus == "isonline: 1" && $oldcurhigh != "curhigh: 0" } {
      if {$oldcurhigh != $curhigh} {
        poststuff privmsg "\00304New listener peak:\00303 [lindex $curhigh 1]\003"
      }
      if {$oldcurlist != $repl} {
        poststuff privmsg "\00304There are currently\00303 [lindex $repl 1] \($currentl\ unique) people listening\003"
      }
    }
    if {$tellsongs == 1 && $oldsong != $cursong && $streamstatus == "isonline: 1" } {
      if {$songurl != ""} { set songurl " ($songurl)"}
      putlog $cursong
      poststuff privmsg "\00304Now Playing @ [lindex $bitrate 1] kbps \00303[lrange $cursong 1 [llength $cursong]] ([lrange $stitle 1 [llength $stitle]])\003"
    }
    if {$tellbitrate == 1 && $oldbitrate != $bitrate && $streamstatus == "isonline: 1" && $oldbitrate != "bitrate: 0"} {
      poststuff privmsg "\00304Bitrate switched to\00303 [lindex $bitrate 1]kbps\003"
    }
  }
}
#--------------- Begin Public Commands ---------------
bind pub -|- !song shoutcast_song
proc shoutcast_song {nick uhost hand chan text} {
  poststuffb $chan privmsg "\00304Now Playing @ /bitrate/ kbps \00303/cursong/ (/stitle/)\003"
}
bind pub -|- !dj shoutcast_dj
proc shoutcast_dj {nick uhost hand chan text} {
  if {[channel get $chan radio]} {
  poststuffb $chan privmsg "\00304DJ \00303/dj/\00304 is currently on \00303/stitle/\003"
  }

bind pub -|- !request shoutcast_request
proc shoutcast_request {nick uhost hand chan arg} {
  global radiostaff
  if {[channel get $chan radio]} {
    set cmd [string tolower [lindex $arg 0]]
    if {$cmd == ""} {
      putserv "NOTICE $nick Please use: !request Artist - Song Title"
      return 0
      } else {
      putserv "PRIVMSG $radiostaff :\00304\002Request from\002: \00303$nick \00304\002for\002: \00303$arg\003"
      putserv "NOTICE $nick :Your request for \002'$arg'\002 has been succesfully sent to the station's staff."
    }
  }
}
bind pub -|- !link shoutcast_link
proc shoutcast_link {nick uhost hand chan text} {
  global linktext1 linktext2
  if {[channel get $chan radio]} {
    putserv "PRIVMSG $chan :$linktext1"
    putserv "PRIVMSG $chan :$linktext2"
  }
}
bind pub -|- !page shoutcast_page
proc shoutcast_page {nick uhost hand chan text} {
  global pagetext
  if {[channel get $chan radio]} {
    putserv "PRIVMSG $chan :$pagetext"
  }
}
bind pub -|- !website shoutcast_website
proc shoutcast_website {nick uhost hand chan text} {
  global webtext
  if {[channel get $chan radio]} {
    putserv "PRIVMSG $chan :$webtext"
  }
}
bind pub -|- !radio shoutcast_help
proc shoutcast_help {nick uhost hand chan text} {
  if {[channel get $chan radio]} {
    putserv "NOTICE $nick :The following commands are available:"
    putserv "NOTICE $nick :!song !link !dj !page !website and !request"
  }
}
#----------------- End Public Commands ----------------
#--------------- Begin Main Channel Greet -------------
catch {bind join - * rchangreet:wjoin}
proc rchangreet:wjoin {nick uhost hand chan} {
  if {[channel get $chan shoutgreet]} {
    if {![isbotnick $nick]} {
      putserv "NOTICE $nick :\00303Welcome to \00304$chan \00303$nick, where we bring you music 24/7\003"
      putserv "NOTICE $nick :\00303Type: \00304!radio \00303to see a list of bot commands :)\003"
    }
  }
}
#---------------- End Main Channel Greet --------------
#------------- Begin Staff Channel Commands -----------
package require http
bind pub - !kickdj radio_kickdj
proc radio_kickdj {nick uhost hand chan arg} {
  global streamip streamport streampass streamid
  if {[channel get $chan shoutadmin]} {
    if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
    putlog "error: $sockerror"
    return 0
    } else {
    if {[isop $nick $chan] == 1} {
      puts $sock "GET /admin.cgi?sid=$streamid&pass=$streampass&mode=kicksrc HTTP/1.1"
      puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
      puts $sock "Host: $streamip"
      puts $sock "Connection: close"
      puts $sock ""
      flush $sock
      close $sock
        putserv "PRIVMSG $chan :\00304\002Current DJ\002: \00303Was successfully kicked.\003"
        } else {
        putserv "NOTICE $nick :You lack sufficient access to use the command: !kickdj"
      }
    }
  }
}
bind pub -|- !status shoutcast_status
proc shoutcast_status {nick uhost hand chan arg} {
  global url streamid
  if {[channel get $chan shoutadmin]} {
    ::http::config -useragent "Mozilla/5.0; Shoutinfo"
    set http_req [::http::geturl $url/index.html?sid=$streamid -timeout 2000]
    if {[::http::status $http_req] != "ok"} {
      putserv "PRIVMSG $chan :\00304Stream is unavailable.\003";
    }
    set data [::http::data $http_req]
    ::http::cleanup $http_req
    if {[regexp {Listing Status: </td><td><b>([^<]+)</b>} $data x server]} {
      putserv "PRIVMSG $chan :\00304\002Server Status\002: \00303$server\003"
      } else {
      putserv "PRIVMSG $chan :\00304Couldn't contact the server, please check the configuration and/or streaming server.\003"
    }
  }
}
bind pub -|- !peak shoutcast_peak
proc shoutcast_peak {nick uhost hand chan arg} {
  global url streamid
  if {[channel get $chan shoutadmin]} {
    ::http::config -useragent "Mozilla/5.0; Shoutinfo"
    set http_req [::http::geturl $url/index.html?sid=$streamid -timeout 2000]
    if {[::http::status $http_req] != "ok"} {
      putserv "PRIVMSG $chan :\00304Stream is unavailable.\003";
    }
    set data [::http::data $http_req]
    ::http::cleanup $http_req
    if {[regexp {Listener Peak: </td><td><b>([^<]+)</b>} $data x peak]} {
      putserv "PRIVMSG $chan :\00304\002Listener Peak\002: \00303$peak\003"
      } else {
      putserv "PRIVMSG $chan :\00304Couldn't receive any information, checking server status...\003"
      shoutcast_status $nick $uhost $hand $chan $arg
    }
  }
}
bind pub -|- !listeners shoutcast_listeners
proc shoutcast_listeners {nick uhost hand chan arg} {
  global url streamid
  if {[channel get $chan shoutadmin]} {
    ::http::config -useragent "Mozilla/5.0; Shoutinfo"
    set http_req [::http::geturl $url/index.html?sid=$streamid -timeout 2000]
    if {[::http::status $http_req] != "ok"} {
      putserv "PRIVMSG $chan :\00304Stream is unavailable.\003";
    }
    set data [::http::data $http_req]
    ::http::cleanup $http_req
    if {[regexp {([0-9]+) of} $data x listeners]} {
      regexp { of ([^<]+) listeners} $data x maxlisteners
      regexp {listeners ([^<]+)} $data x unique
      regexp {@ ([^<]+),} $data x bitrate
      putserv "PRIVMSG $chan :\00304\002Stream Status\002: \00303Stream is up at $bitrate with $listeners of $maxlisteners listeners $unique\003"
      } else {
      putserv "PRIVMSG $chan :\00304Couldn't receive any information, checking server status...\003"
      shoutcast_status $nick $uhost $hand $chan $arg
    }
  }
}
bind pub -|- !admin shoutcast_admin
proc shoutcast_admin {nick uhost hand chan text} {
  global admintext
  if {[channel get $chan shoutadmin]} {
    putserv "PRIVMSG $chan :$admintext"
  }
}
bind pub -|- !cmds shoutcast_adminhelp
proc shoutcast_adminhelp {nick uhost hand chan text} {
  if {[channel get $chan shoutadmin]} {
    putserv "NOTICE $nick :The following commands are available:"
    putserv "NOTICE $nick :!kickdj !listeners !peak !status !admin"
    putserv "NOTICE $nick :!song !link !dj !page and !website"
  }
}
#-------------- End Staff Channel Commands ------------
setudef flag radio
setudef flag shoutauto
setudef flag shoutadmin
setudef flag shoutgreet
putlog "Shoutcast shoutcast.tcl v2.20 by: play4free2 & cards irc.420-hightimes.com #HighTimes-Lounge & #snoopdogg loaded! Type .chanset <channel> +radio +shoutgreet +shoutauto +shoutadmin to enable in your channel(s)"


Sorry about the custom colours but I was to lazy to take them out Razz
I have removed and added a few things from the original... This was just writen a month ago for my shoutcast.v2, it suits my needs fine, and I didn't feel like changing it all.
_________________

420-HIGHTIMES IRC Network
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber