Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias -l icecast_config {
- if (channel == $1) return #nativamix
- if (timer == $1) return 10
- if (server == $1) return 158.69.226.83
- if (port == $1) return 9319
- }
- alias icecast {
- if (off == $1) {
- if ($timer(icecast)) .timericecast off
- if ($hget(icecast)) hfree icecast
- if ($sock(icecast)) .sockclose icecast
- }
- else {
- if (!$timer(icecast)) .timericecast 0 $icecast_config(timer) icecast
- if ($sock(icecast)) .sockclose icecast
- if (!$hget(icecast)) hmake icecast 4
- sockopen icecast $icecast_config(server) $icecast_config(port)
- sockmark icecast -n
- }
- }
- on *:SOCKOPEN:icecast:{
- if ($sockerr) echo -s Erro ao conectar.
- else sockwrite -t $sockname $+(GET /status.xsl HTTP/1.0,$crlf,Host: $sock($sockname).addr,$crlf,Connection: close,$crlf,$crlf)
- }
- on *:SOCKREAD:icecast:{
- set -l %mark
- :a
- %mark = $sock($sockname).mark
- sockread %mark &read
- if (!$sockbr) return
- if (%mark) {
- if (0 0 == $bvar(&read,1-)) sockmark $sockname
- else {
- tokenize 32 $bvar(&read,1-).text
- if (HTTP/* iswm $1) hadd icecast get_HTTP $2-
- elseif (Content-Length: == $1) hadd icecast get_Content-Length $2
- }
- }
- else {
- noop $hget(icecast,get_content,&content)
- bcopy &content -1 &read 1 -1
- hadd -b icecast get_content &content
- }
- goto a
- }
- on *:SOCKCLOSE:icecast:{
- set -l %amusica $hget(icecast,musica)
- set -l %erro
- if (200 OK != $hget(icecast,get_HTTP)) {
- %erro = HTTP: $v2
- goto erro
- }
- if ($hget(icecast,get_content,&content) != $hget(icecast,get_Content-Length)) {
- %erro = Content != Content: $v1 != $v2
- goto erro
- }
- set -l %ipos $bfind(&content,1,<h3 class="mount">Mount Point /live</h3>).text
- %ipos = $bfind(&content,%ipos,<tr><td>Currently playing:</td><td class="streamstats">).text + 55
- set -l %fpos $bfind(&content,%ipos,</td></tr>).text - %ipos
- if (%fpos) {
- hadd icecast musica $bvar(&content,%ipos,%fpos).text
- if (%amusica != $hget(icecast,musica)) msg $icecast_config(channel) Tocando agora na NativaMix: $v2
- }
- :erro
- if (%erro) {
- echo -s Icecast Erro: %erro
- }
- hdel -w icecast get_*
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement