mIRC Shoutcast-Client
Posted by Lumpi
Thursday, June 11, 2009
Description: play, stores or plays & stores shoutcast-streams (non final! few bugs but works)
##########################################################
##
## Popmenu
##
##########################################################
menu status,channel,nicklist,query,menubar {
Pain
.Shoutcast
..$iif($dialog(shoutcast) != $null,$style(2)) Open Shoutcast:/dialog -m shoutcast shoutcast
..$iif($dialog(shoutcast) == $null,$style(2)) Close Shoutcast:/dialog -x shoutcast
..-
..Spamm: {
describe $active >> Listening to: $gettok($did(shoutcast,2).seltext,1,32) >> $gettok($did(shoutcast,2).seltext,2,32) $&
>> for $duration($calc($calc($ticks - %stream.start) / 1000))
}
..Advertise Shoutcast:/describe $active is using @pain`s mIRC-Shoutcast-Client
}
##########################################################
##
## Dialog
##
##########################################################
dialog shoutcast {
title "mIRC Shoutcast-Client"
size -1 -1 221 107
option dbu
tab "Streams", 28, 2 0 216 104
edit "", 4, 8 20 205 10, tab 28
list 2, 8 31 205 54, tab 28 size hsbar vsbar
button "Add", 6, 8 87 32 12, tab 28
button "Edit", 7, 42 87 32 12, tab 28
button "Delete", 8, 76 87 32 12, tab 28
button "Play", 14, 140 87 35 12, tab 28
button "Stop", 15, 177 87 35 12, tab 28
tab "Infos", 29
list 5, 8 20 205 56, tab 29 size hsbar vsbar
text "Buffer:", 16, 9 79 54 8, tab 29
text "", 13, 64 79 45 8, tab 29
radio "256kb", 9, 118 78 22 10, tab 29 push
radio "512kb", 10, 142 78 22 10, tab 29 push
radio "768kb", 11, 166 78 22 10, tab 29 push
radio "1024kb", 12, 190 78 22 10, tab 29 push
text "Temporary Streams Size:", 26, 108 92 61 8, tab 29
text "", 27, 170 92 42 8, tab 29
text "", 25, 59 92 28 8, tab 29
text "Temporary Streams:", 24, 9 92 49 8, tab 29
tab "Playback / Saving", 30
radio "Only Play Streams", 18, 9 21 65 10, tab 30 push
radio "Only Save Streams", 22, 77 21 65 10, tab 30 push
radio "Play and Save Streamm", 19, 146 21 65 10, tab 30 push
button "Select Save Location", 21, 8 87 60 12, tab 30
button "View Saved Streams", 23, 8 73 60 12, tab 30
edit "", 20, 70 89 142 10, tab 30
tab "Temporary Files", 32
list 34, 8 20 203 64, tab 32 size hsbar vsbar
button "Megre temporary saved to one file", 3, 8 87 203 12, tab 32
tab "Saved Streams", 38
list 33, 8 20 203 79, tab 38 size hsbar vsbar
box "", 1, 5 14 210 88
menu "Maximize / Minimize", 31
item "Maximize", 17, 31
item "Minimize", 35, 31
}
dialog shoutcast_mini {
title "mIRC Shoutcast-Client"
size -1 -1 154 24
option dbu
box "", 1, 2 -1 150 23
text "Station:", 5, 4 4 19 8
text "Buffer:", 6, 4 12 71 8
text "Text Label", 7, 24 4 125 8
text "Text Label", 8, 78 12 71 8
menu "Maximize / Minimize", 2
item "Maximize", 3, 2
item "Minimize", 4, 2
}
alias shoutcast {
$iif($dialog(shoutcast), dialog -x shoutcast, dialog -m shoutcast shoutcast)
}
alias -l shoutkb { return $round($calc($1 /1024),2) }
##########################################################
##
## Dialog init
##
##########################################################
on *:dialog:shoutcast:init:0: {
load.streams
if (!%stream.kb) {
did -c shoutcast 9
set %stream.kb 262144
}
if (%stream.kb == 262144) { did -c shoutcast 9 }
if (%stream.kb == 524288) { did -c shoutcast 10 }
if (%stream.kb == 786432) { did -c shoutcast 11 }
if (%stream.kb == 1048576) { did -c shoutcast 12 }
if (%stream.kb == 2097152) { did -c shoutcast 13 }
if (!%stream.act) { set %stream.act p }
if (%stream.act == p) { did -c shoutcast 18 }
if (%stream.act == s) { did -c shoutcast 22 }
if (%stream.act == ps) { did -c shoutcast 19 }
if (!%stream.store) { set %stream.store $nofile($mircexe) }
did -ra shoutcast 20 %stream.store
unset %stream.mini
did -b shoutcast 17
if (%stream.info) {
.timer 1 1 did -f shoutcast 29
.timer 1 1 loadbuf -o shoutcast 5 stream.info
}
}
##########################################################
##
## Dialog close
##
##########################################################
on *:dialog:shoutcast:close:0: {
if (!%stream.mini) {
stop.stream
stream_del_temp
unset %stream.info
}
else {
unset %stream.mini
}
}
##########################################################
##
## Dialog sclick / dslick
##
##########################################################
on *:dialog:shoutcast_mini:init:0: {
if (%stream.mini) {
did -e shoutcast_mini 3
did -b shoutcast_mini 4
}
set %stream.info 1
}
on *:dialog:shoutcast_mini:menu:3: {
set %stream.mini 1
dialog -m shoutcast shoutcast
dialog -x shoutcast_mini
}
on *:dualog:shoutcast_mini:sclick:0: {
if (%stream.mini) {
did -e shoutcast.mini 17
did -b shoutcast.mini 35
}
}
on *:dialog:shoutcast:dclick:2: {
echo -a $did
stop.stream
play.stream
stream_del_temp
}
on *:dialog:shoutcast:menu:*: {
if ($did == 17) {
unset %stream.mini
did -b shoutcast 17
did -e shoutcast 35
}
if ($did == 35) {
set %stream.mini 1
dialog -x shoutcast
dialog -m shoutcast_mini shoutcast_mini
}
}
on *:dialog:shoutcast:sclick:9,10,11,12,13,18,22,19,21,23: {
if ($did == 9) { set %stream.kb 262144 }
if ($did == 10) { set %stream.kb 524288 }
if ($did == 11) { set %stream.kb 786432 }
if ($did == 12) { set %stream.kb 1048576 }
if ($did == 13) { set %stream.kb 2097152 }
if ($did == 18) { set %stream.act p }
if ($did == 22) {
set %stream.act s
splay stop
}
if ($did == 19) { set %stream.act ps }
if ($did == 21) {
set %stream.store $sdir(%stream.store,Select a folder to save Shoutcast-Streams)
did -ra shoutcast 20 %stream.store
}
if ($did == 23) { run explorer.exe %stream.store }
}
on *:dialog:shoutcast:sclick:*: {
if ($did == 2) { did -ra shoutcast 4 $readini(shoutcast.ini, $gettok($gettok($did(shoutcast,2).seltext,2,47),1,58), pls) }
if ($did == 6) { ;ADD
writeini shoutcast.ini $gettok($gettok($did(shoutcast,4),2,47),1,58) pls $did($dname, 4)
load.streams
}
if ($did == 8) { ;DEL
remini shoutcast.ini $gettok($gettok($did(shoutcast,4),2,47),1,58)
load.streams
}
if ($did == 7) { ;EDIT
remini shoutcast.ini $gettok($gettok($did(shoutcast,2).seltext,2,47),1,58)
writeini shoutcast.ini $gettok($gettok($did(shoutcast,4),2,47),1,58) pls $did($dname, 4)
load.streams
}
if ($did == 14) {
stop.stream
play.stream
stream_del_temp
}
if ($did == 15) {
stream.mergetemp
stop.stream
}
if ($did == 32) {
stream.loadtemp
}
if ($did == 38) {
stream.loadstreams
}
if ($did == 3) {
stream.mergetemp
}
}
##########################################################
##
## Aliases
##
##########################################################
alias stream.loadtemp {
if ($dialog(shoutcast)) {
did -r shoutcast 34
var %x 1
while (%x <= $findfile(%stream.store,TEMPSTREAM_*.*,0,1)) {
did -a shoutcast 34 $findfile(%stream.store,TEMPSTREAM_*.*, %x ,1)
inc %x
}
}
}
alias stream.loadstreams {
if ($dialog(shoutcast)) {
did -r shoutcast 33
var %x 1
while (%x <= $findfile(%stream.store,*Shoutcast-Stream*.*,0,1)) {
did -a shoutcast 33 $findfile(%stream.store,*Shoutcast-Stream*.*, %x ,1)
inc %x
}
}
}
alias stream.mergetemp {
var %x 1
var %filetype $did(shoutcast,34,1)
%filetype = $gettok($right(%filetype,5),2,46)
write -c $+(%stream.store,%stream.station,Shoutcast-Stream__,%stream.startdate,.,%filetype)
while (%x <= $did(shoutcast,34).lines) {
.copy -a $did(shoutcast,34,%x) $+(%stream.store,%stream.station,Shoutcast-Stream__,%stream.startdate,.,%filetype)
.remove $did(shoutcast,34,%x)
inc %x
}
did -r shoutcast 34
var %x 1
while (%x <= $findfile(%stream.store,TEMPSTREAM_*.*,0,1)) {
did -a shoutcast 34 $findfile(%stream.store,TEMPSTREAM_*.*, %x ,1)
inc %x
}
stream_del_temp
}
alias stream_del_temp {
var %x 1
var %y $findfile(%stream.store,TEMPSTREAM_*.*,0,1)
while (%x <= $findfile(%stream.store,TEMPSTREAM_*.*,0)) {
.remove $findfile(%stream.store,TEMPSTREAM_*.*, %x ,1)
}
}
alias load.streams {
did -r shoutcast 2
var %x 1
while (%x <= $ini(shoutcast.ini,0)) {
did -a shoutcast 2 $readini(shoutcast.ini, $ini(shoutcast.ini, %x), pls)
inc %x
}
did -c shoutcast 2 1
}
alias play.stream {
set %stream.startdate $replace($date,$chr(47),-) $+ __ $+ $replace($time,:,-)
set %stream.start $ticks
sockclose stream
unset %streaming
sockopen stream $gettok($gettok($did(shoutcast,2).seltext,2,47),1,58) $gettok($gettok($did(shoutcast,2).seltext,2,47),2,58)
did -f shoutcast 29
.timer 1 1 loadbuf -o shoutcast 5 stream.info
}
alias stop.stream {
sockclose stream
unset %streaming
splay stop
did -r shoutcast 5
.remove stream-temp1.mp3
.remove stream-temp2.mp3
.remove stream-temp3.mp3
.remove stream-temp4.mp3
.remove stream-temp5.mp3
.remove stream-temp6.mp3
.remove stream-temp7.mp3
.remove stream-temp8.mp3
.remove stream-temp9.mp3
.remove stream-temp10.mp3
.remove stream-temp11.mp3
.remove stream-temp12.mp3
.remove stream-temp13.mp3
.remove stream-temp14.mp3
.remove stream-temp15.mp3
.remove stream-temp16.mp3
.remove stream-temp17.mp3
.remove stream-temp18.mp3
.remove stream-temp19.mp3
.remove stream-temp20.mp3
}
alias tempstream.size {
var %size 0
var %x 1
var %y $findfile(%stream.store,TEMPSTREAM_*.*,0)
while (%x <= %y) {
inc %size $file($findfile(%stream.store,TEMPSTREAM_*.*,%x)).size
inc %x
}
return $bytes(%size).suf
}
##########################################################
##
## Socket-Connection
##
##########################################################
on *:sockopen:stream: {
if ($sockerr) {
echo -at Shoutcast: [^K]4Connection Failed!
}
write -c stream.info
set %stream.temp 001
set %stream.kb-file 2
sockwrite -n $sockname GET / HTTP/1.1
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Host: www.shoutcast.com
sockwrite -n $sockname $crlf
}
on *:sockclose:stream: {
echo -at Shoutcast: [^K]5Connection Closed!
unset %streaming
}
on *:sockread:stream: {
if (!%streaming) {
sockread %shout
while ($sockbr) {
if ($regex(%shout,^.*?(name|genre|url|type|icy-br).*?:(.+)$)) {
if ($regml(1) == url) {
set %stream.station $gettok($regml(2),2-,46)
}
if (aacp isincs $regml(2)) { set %stream.type aac }
if (mpeg isincs $regml(2)) { set %stream.type mp1 }
if ($regml(1) == icy-br) {
write -a stream.info $regml(2) $+ kb
set %streaming 1
break
}
else {
write -a stream.info $regml(2)
}
}
sockread %shout
}
}
else {
if (!%stream.info) {
set %stream.info 1
loadbuf -o shoutcast 5 stream.info
}
sockread &a 8192
while ($sockbr) {
set %f $+(stream-temp,%stream.kb-file,.mp3)
bwrite %f -1 -1 &a
if ($dialog(shoutcast)) {
did -ra shoutcast 16 Buffer: $int($shoutkb($file(%f).size))) $+ / $+ $calc(%stream.kb / 1024) kb
did -ra shoutcast 13 $duration($calc($calc($ticks - %stream.start) / 1000))
}
if ($dialog(shoutcast_mini)) {
did -ra shoutcast_mini 7 %stream.station
did -ra shoutcast_mini 6 Buffer: $int($shoutkb($file(%f).size))) $+ / $+ $calc(%stream.kb / 1024) kb
did -ra shoutcast_mini 8 $duration($calc($calc($ticks - %stream.start) / 1000))
}
if ($file(%f).size >= %stream.kb) {
inc %stream.kb-file 1
if (%stream.kb-file == 20) {
set %stream.kb-file 1
}
if (%stream.act == p) {
splay -q %f
}
if (%stream.act == ps) {
if ($len(%stream.temp) == 1) { %stream.temp = $+(000,%stream.temp) }
if ($len(%stream.temp) == 2) { %stream.temp = $+(00,%stream.temp) }
if ($len(%stream.temp) == 3) { %stream.temp = $+(0,%stream.temp) }
splay -q %f
.copy -o %f $+(%stream.store,TEMPSTREAM_,%stream.temp,.,%stream.type)
if ($dialog(shoutcast)) {
did -ra shoutcast 25 $findfile(%stream.store,TEMPSTREAM_*.*,0,1)
did -ra shoutcast 27 $tempstream.size
}
inc %stream.temp
stream.loadtemp
}
if (%stream.act == s) {
if ($len(%stream.temp) == 1) { %stream.temp = $+(000,%stream.temp) }
if ($len(%stream.temp) == 2) { %stream.temp = $+(00,%stream.temp) }
if ($len(%stream.temp) == 3) { %stream.temp = $+(0,%stream.temp) }
.copy -o %f $+(%stream.store,TEMPSTREAM_,%stream.temp,.,%stream.type)
if ($dialog(shoutcast)) {
did -ra shoutcast 25 $findfile(%stream.store,TEMPSTREAM_*.*,0,1)
did -ra shoutcast 27 $tempstream.size
}
inc %stream.temp
if ($dialog(shoutcast)) { stream.loadtemp }
}
if ($dialog(shoutcast)) { did -z shoutcast 2 5 }
write -c $+(stream-temp,%stream.kb-file,.mp3)
}
sockread &a 8192
}
}
}
##########################################################
##
## Popmenu
##
##########################################################
menu status,channel,nicklist,query,menubar {
Pain
.Shoutcast
..$iif($dialog(shoutcast) != $null,$style(2)) Open Shoutcast:/dialog -m shoutcast shoutcast
..$iif($dialog(shoutcast) == $null,$style(2)) Close Shoutcast:/dialog -x shoutcast
..-
..Spamm: {
describe $active >> Listening to: $gettok($did(shoutcast,2).seltext,1,32) >> $gettok($did(shoutcast,2).seltext,2,32) $&
>> for $duration($calc($calc($ticks - %stream.start) / 1000))
}
..Advertise Shoutcast:/describe $active is using @pain`s mIRC-Shoutcast-Client
}
##########################################################
##
## Dialog
##
##########################################################
dialog shoutcast {
title "mIRC Shoutcast-Client"
size -1 -1 221 107
option dbu
tab "Streams", 28, 2 0 216 104
edit "", 4, 8 20 205 10, tab 28
list 2, 8 31 205 54, tab 28 size hsbar vsbar
button "Add", 6, 8 87 32 12, tab 28
button "Edit", 7, 42 87 32 12, tab 28
button "Delete", 8, 76 87 32 12, tab 28
button "Play", 14, 140 87 35 12, tab 28
button "Stop", 15, 177 87 35 12, tab 28
tab "Infos", 29
list 5, 8 20 205 56, tab 29 size hsbar vsbar
text "Buffer:", 16, 9 79 54 8, tab 29
text "", 13, 64 79 45 8, tab 29
radio "256kb", 9, 118 78 22 10, tab 29 push
radio "512kb", 10, 142 78 22 10, tab 29 push
radio "768kb", 11, 166 78 22 10, tab 29 push
radio "1024kb", 12, 190 78 22 10, tab 29 push
text "Temporary Streams Size:", 26, 108 92 61 8, tab 29
text "", 27, 170 92 42 8, tab 29
text "", 25, 59 92 28 8, tab 29
text "Temporary Streams:", 24, 9 92 49 8, tab 29
tab "Playback / Saving", 30
radio "Only Play Streams", 18, 9 21 65 10, tab 30 push
radio "Only Save Streams", 22, 77 21 65 10, tab 30 push
radio "Play and Save Streamm", 19, 146 21 65 10, tab 30 push
button "Select Save Location", 21, 8 87 60 12, tab 30
button "View Saved Streams", 23, 8 73 60 12, tab 30
edit "", 20, 70 89 142 10, tab 30
tab "Temporary Files", 32
list 34, 8 20 203 64, tab 32 size hsbar vsbar
button "Megre temporary saved to one file", 3, 8 87 203 12, tab 32
tab "Saved Streams", 38
list 33, 8 20 203 79, tab 38 size hsbar vsbar
box "", 1, 5 14 210 88
menu "Maximize / Minimize", 31
item "Maximize", 17, 31
item "Minimize", 35, 31
}
dialog shoutcast_mini {
title "mIRC Shoutcast-Client"
size -1 -1 154 24
option dbu
box "", 1, 2 -1 150 23
text "Station:", 5, 4 4 19 8
text "Buffer:", 6, 4 12 71 8
text "Text Label", 7, 24 4 125 8
text "Text Label", 8, 78 12 71 8
menu "Maximize / Minimize", 2
item "Maximize", 3, 2
item "Minimize", 4, 2
}
alias shoutcast {
$iif($dialog(shoutcast), dialog -x shoutcast, dialog -m shoutcast shoutcast)
}
alias -l shoutkb { return $round($calc($1 /1024),2) }
##########################################################
##
## Dialog init
##
##########################################################
on *:dialog:shoutcast:init:0: {
load.streams
if (!%stream.kb) {
did -c shoutcast 9
set %stream.kb 262144
}
if (%stream.kb == 262144) { did -c shoutcast 9 }
if (%stream.kb == 524288) { did -c shoutcast 10 }
if (%stream.kb == 786432) { did -c shoutcast 11 }
if (%stream.kb == 1048576) { did -c shoutcast 12 }
if (%stream.kb == 2097152) { did -c shoutcast 13 }
if (!%stream.act) { set %stream.act p }
if (%stream.act == p) { did -c shoutcast 18 }
if (%stream.act == s) { did -c shoutcast 22 }
if (%stream.act == ps) { did -c shoutcast 19 }
if (!%stream.store) { set %stream.store $nofile($mircexe) }
did -ra shoutcast 20 %stream.store
unset %stream.mini
did -b shoutcast 17
if (%stream.info) {
.timer 1 1 did -f shoutcast 29
.timer 1 1 loadbuf -o shoutcast 5 stream.info
}
}
##########################################################
##
## Dialog close
##
##########################################################
on *:dialog:shoutcast:close:0: {
if (!%stream.mini) {
stop.stream
stream_del_temp
unset %stream.info
}
else {
unset %stream.mini
}
}
##########################################################
##
## Dialog sclick / dslick
##
##########################################################
on *:dialog:shoutcast_mini:init:0: {
if (%stream.mini) {
did -e shoutcast_mini 3
did -b shoutcast_mini 4
}
set %stream.info 1
}
on *:dialog:shoutcast_mini:menu:3: {
set %stream.mini 1
dialog -m shoutcast shoutcast
dialog -x shoutcast_mini
}
on *:dualog:shoutcast_mini:sclick:0: {
if (%stream.mini) {
did -e shoutcast.mini 17
did -b shoutcast.mini 35
}
}
on *:dialog:shoutcast:dclick:2: {
echo -a $did
stop.stream
play.stream
stream_del_temp
}
on *:dialog:shoutcast:menu:*: {
if ($did == 17) {
unset %stream.mini
did -b shoutcast 17
did -e shoutcast 35
}
if ($did == 35) {
set %stream.mini 1
dialog -x shoutcast
dialog -m shoutcast_mini shoutcast_mini
}
}
on *:dialog:shoutcast:sclick:9,10,11,12,13,18,22,19,21,23: {
if ($did == 9) { set %stream.kb 262144 }
if ($did == 10) { set %stream.kb 524288 }
if ($did == 11) { set %stream.kb 786432 }
if ($did == 12) { set %stream.kb 1048576 }
if ($did == 13) { set %stream.kb 2097152 }
if ($did == 18) { set %stream.act p }
if ($did == 22) {
set %stream.act s
splay stop
}
if ($did == 19) { set %stream.act ps }
if ($did == 21) {
set %stream.store $sdir(%stream.store,Select a folder to save Shoutcast-Streams)
did -ra shoutcast 20 %stream.store
}
if ($did == 23) { run explorer.exe %stream.store }
}
on *:dialog:shoutcast:sclick:*: {
if ($did == 2) { did -ra shoutcast 4 $readini(shoutcast.ini, $gettok($gettok($did(shoutcast,2).seltext,2,47),1,58), pls) }
if ($did == 6) { ;ADD
writeini shoutcast.ini $gettok($gettok($did(shoutcast,4),2,47),1,58) pls $did($dname, 4)
load.streams
}
if ($did == 8) { ;DEL
remini shoutcast.ini $gettok($gettok($did(shoutcast,4),2,47),1,58)
load.streams
}
if ($did == 7) { ;EDIT
remini shoutcast.ini $gettok($gettok($did(shoutcast,2).seltext,2,47),1,58)
writeini shoutcast.ini $gettok($gettok($did(shoutcast,4),2,47),1,58) pls $did($dname, 4)
load.streams
}
if ($did == 14) {
stop.stream
play.stream
stream_del_temp
}
if ($did == 15) {
stream.mergetemp
stop.stream
}
if ($did == 32) {
stream.loadtemp
}
if ($did == 38) {
stream.loadstreams
}
if ($did == 3) {
stream.mergetemp
}
}
##########################################################
##
## Aliases
##
##########################################################
alias stream.loadtemp {
if ($dialog(shoutcast)) {
did -r shoutcast 34
var %x 1
while (%x <= $findfile(%stream.store,TEMPSTREAM_*.*,0,1)) {
did -a shoutcast 34 $findfile(%stream.store,TEMPSTREAM_*.*, %x ,1)
inc %x
}
}
}
alias stream.loadstreams {
if ($dialog(shoutcast)) {
did -r shoutcast 33
var %x 1
while (%x <= $findfile(%stream.store,*Shoutcast-Stream*.*,0,1)) {
did -a shoutcast 33 $findfile(%stream.store,*Shoutcast-Stream*.*, %x ,1)
inc %x
}
}
}
alias stream.mergetemp {
var %x 1
var %filetype $did(shoutcast,34,1)
%filetype = $gettok($right(%filetype,5),2,46)
write -c $+(%stream.store,%stream.station,Shoutcast-Stream__,%stream.startdate,.,%filetype)
while (%x <= $did(shoutcast,34).lines) {
.copy -a $did(shoutcast,34,%x) $+(%stream.store,%stream.station,Shoutcast-Stream__,%stream.startdate,.,%filetype)
.remove $did(shoutcast,34,%x)
inc %x
}
did -r shoutcast 34
var %x 1
while (%x <= $findfile(%stream.store,TEMPSTREAM_*.*,0,1)) {
did -a shoutcast 34 $findfile(%stream.store,TEMPSTREAM_*.*, %x ,1)
inc %x
}
stream_del_temp
}
alias stream_del_temp {
var %x 1
var %y $findfile(%stream.store,TEMPSTREAM_*.*,0,1)
while (%x <= $findfile(%stream.store,TEMPSTREAM_*.*,0)) {
.remove $findfile(%stream.store,TEMPSTREAM_*.*, %x ,1)
}
}
alias load.streams {
did -r shoutcast 2
var %x 1
while (%x <= $ini(shoutcast.ini,0)) {
did -a shoutcast 2 $readini(shoutcast.ini, $ini(shoutcast.ini, %x), pls)
inc %x
}
did -c shoutcast 2 1
}
alias play.stream {
set %stream.startdate $replace($date,$chr(47),-) $+ __ $+ $replace($time,:,-)
set %stream.start $ticks
sockclose stream
unset %streaming
sockopen stream $gettok($gettok($did(shoutcast,2).seltext,2,47),1,58) $gettok($gettok($did(shoutcast,2).seltext,2,47),2,58)
did -f shoutcast 29
.timer 1 1 loadbuf -o shoutcast 5 stream.info
}
alias stop.stream {
sockclose stream
unset %streaming
splay stop
did -r shoutcast 5
.remove stream-temp1.mp3
.remove stream-temp2.mp3
.remove stream-temp3.mp3
.remove stream-temp4.mp3
.remove stream-temp5.mp3
.remove stream-temp6.mp3
.remove stream-temp7.mp3
.remove stream-temp8.mp3
.remove stream-temp9.mp3
.remove stream-temp10.mp3
.remove stream-temp11.mp3
.remove stream-temp12.mp3
.remove stream-temp13.mp3
.remove stream-temp14.mp3
.remove stream-temp15.mp3
.remove stream-temp16.mp3
.remove stream-temp17.mp3
.remove stream-temp18.mp3
.remove stream-temp19.mp3
.remove stream-temp20.mp3
}
alias tempstream.size {
var %size 0
var %x 1
var %y $findfile(%stream.store,TEMPSTREAM_*.*,0)
while (%x <= %y) {
inc %size $file($findfile(%stream.store,TEMPSTREAM_*.*,%x)).size
inc %x
}
return $bytes(%size).suf
}
##########################################################
##
## Socket-Connection
##
##########################################################
on *:sockopen:stream: {
if ($sockerr) {
echo -at Shoutcast: [^K]4Connection Failed!
}
write -c stream.info
set %stream.temp 001
set %stream.kb-file 2
sockwrite -n $sockname GET / HTTP/1.1
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Host: www.shoutcast.com
sockwrite -n $sockname $crlf
}
on *:sockclose:stream: {
echo -at Shoutcast: [^K]5Connection Closed!
unset %streaming
}
on *:sockread:stream: {
if (!%streaming) {
sockread %shout
while ($sockbr) {
if ($regex(%shout,^.*?(name|genre|url|type|icy-br).*?:(.+)$)) {
if ($regml(1) == url) {
set %stream.station $gettok($regml(2),2-,46)
}
if (aacp isincs $regml(2)) { set %stream.type aac }
if (mpeg isincs $regml(2)) { set %stream.type mp1 }
if ($regml(1) == icy-br) {
write -a stream.info $regml(2) $+ kb
set %streaming 1
break
}
else {
write -a stream.info $regml(2)
}
}
sockread %shout
}
}
else {
if (!%stream.info) {
set %stream.info 1
loadbuf -o shoutcast 5 stream.info
}
sockread &a 8192
while ($sockbr) {
set %f $+(stream-temp,%stream.kb-file,.mp3)
bwrite %f -1 -1 &a
if ($dialog(shoutcast)) {
did -ra shoutcast 16 Buffer: $int($shoutkb($file(%f).size))) $+ / $+ $calc(%stream.kb / 1024) kb
did -ra shoutcast 13 $duration($calc($calc($ticks - %stream.start) / 1000))
}
if ($dialog(shoutcast_mini)) {
did -ra shoutcast_mini 7 %stream.station
did -ra shoutcast_mini 6 Buffer: $int($shoutkb($file(%f).size))) $+ / $+ $calc(%stream.kb / 1024) kb
did -ra shoutcast_mini 8 $duration($calc($calc($ticks - %stream.start) / 1000))
}
if ($file(%f).size >= %stream.kb) {
inc %stream.kb-file 1
if (%stream.kb-file == 20) {
set %stream.kb-file 1
}
if (%stream.act == p) {
splay -q %f
}
if (%stream.act == ps) {
if ($len(%stream.temp) == 1) { %stream.temp = $+(000,%stream.temp) }
if ($len(%stream.temp) == 2) { %stream.temp = $+(00,%stream.temp) }
if ($len(%stream.temp) == 3) { %stream.temp = $+(0,%stream.temp) }
splay -q %f
.copy -o %f $+(%stream.store,TEMPSTREAM_,%stream.temp,.,%stream.type)
if ($dialog(shoutcast)) {
did -ra shoutcast 25 $findfile(%stream.store,TEMPSTREAM_*.*,0,1)
did -ra shoutcast 27 $tempstream.size
}
inc %stream.temp
stream.loadtemp
}
if (%stream.act == s) {
if ($len(%stream.temp) == 1) { %stream.temp = $+(000,%stream.temp) }
if ($len(%stream.temp) == 2) { %stream.temp = $+(00,%stream.temp) }
if ($len(%stream.temp) == 3) { %stream.temp = $+(0,%stream.temp) }
.copy -o %f $+(%stream.store,TEMPSTREAM_,%stream.temp,.,%stream.type)
if ($dialog(shoutcast)) {
did -ra shoutcast 25 $findfile(%stream.store,TEMPSTREAM_*.*,0,1)
did -ra shoutcast 27 $tempstream.size
}
inc %stream.temp
if ($dialog(shoutcast)) { stream.loadtemp }
}
if ($dialog(shoutcast)) { did -z shoutcast 2 5 }
write -c $+(stream-temp,%stream.kb-file,.mp3)
}
sockread &a 8192
}
}
}