rendered paste body;########################################################################################
;# Shoutcast stream recorder v1.1 for mIRC 5.9x and higher
;# just load it and type /shoutcast
;# you can listen the stream while recording it but due to the /splay command
;# you will get a small blank every ~10 seconds :(
;#
;# (c)2002 gamo @ [irc.kewl.org - #uk]
;########################################################################################
dialog shout {
title "Shoutcast stream recorder"
size -1 -1 139 152
option dbu
edit "", 1, 3 8 94 10
box "Address", 2, 1 1 98 19
box "Port", 3, 98 1 40 19
edit "", 4, 100 8 36 10
box "", 5, 1 16 137 121
list 6, 3 21 133 41, size vsbar
text "Output:", 7, 4 65 20 8
edit "", 8, 24 64 91 10, read autohs
button "[...]", 9, 116 64 19 10
button "Close", 10, 111 139 27 12, cancel
box "Infos", 11, 1 76 137 61
text "Radio Name:", 12, 5 84 31 8, right
edit "", 13, 37 83 98 10, read autohs
text "Radio URL:", 14, 5 95 31 8, right
edit "", 15, 37 94 98 10, read autohs
edit "", 17, 3 125 43 10, read
text "Genre:", 18, 5 106 31 8, right
edit "", 19, 37 105 98 10, read autohs
edit "", 20, 48 125 43 10, read
edit "", 21, 93 125 43 10, read
box "Bitrate", 22, 1 117 47 20
box "Record time", 23, 47 117 45 20
box "File size", 24, 91 117 47 20
button "Start", 25, 82 139 27 12
button "Play", 26, 1 139 27 12, disable
}
on *:dialog:shout:init:*: {
hmake shout 100
hadd shout file $mircdir $+ Radio.mp3
hadd shout head 0
did -ra shout 8 $hget(shout,file)
}
on *:dialog:shout:sclick:26: {
if (!$hget(shout,ispl)) { shp -p | did -ra shout 26 Stop }
else { shp -s | did -ra shout 26 Play }
}
on *:dialog:shout:sclick:10: sockclose shoutcast | shp -s | hfree shout | .timershout off
on *:dialog:shout:sclick:9: var %a = $sfile($mircdir,Choose a file) | if (%a) { hadd shout file %a | did -ra shout 8 %a }
on *:dialog:shout:sclick:25: {
if ($did(shout,25) == Start) {
if ($isfile($+(",$hget(shout,file),"))) { var %a = $input(The specified file allready exist, do you want to overwrite it ?) | if (!%a) return }
write -c $+(",$hget(shout,file),")
var %ip = $did(shout,1), %port = $did(shout,4)
if (!%ip) || (!%port) { var %a = $input(Enter a valid IP/Port,260) | return }
hadd shout ip %ip | hadd shout port %port
did -ra shout 6 Connecting to: $+($hget(shout,ip),:,$hget(shout,port)) ...
did -ra shout 25 Stop
sockopen shoutcast $hget(shout,ip) $hget(shout,port)
did -e shout 26
}
else {
sockclose shoutcast
did -a shout 6 Stream stopped | did -ra shout 25 Start | did -ra shout 26 Play
.timershout off | hadd shout head 0 | shp -s | did -b shout 26
}
}
alias shoutcast dialog $iif($dialog(shout),-v,-m shout) shout
on *:sockopen:shoutcast: {
if ($sockerr) { disp Can't connect to: $+($hget(shout,ip),:,$hget(shout,port)) | return }
var %a = sockwrite -n shoutcast
%a GET / HTTP/1.0
%a Host: $sock(shoutcast).ip
%a User-Agent: mSSC/1.1
%a Accept: */*
%a Icy-MetaData:0
%a Connection: close
%a
}
on *:sockread:shoutcast: {
var %a
if (!$hget(shout,head)) {
sockread %a
while ($sockbr) {
if (%a) {
tokenize 58 %a
if (%a == ICY 200 OK) { disp Connected successfuly }
elseif ($1 == icy-name) { did -ra shout 13 $2- }
elseif ($1 == icy-genre) { did -ra shout 19 $2- }
elseif ($1 == icy-url) { did -ra shout 15 $2- }
}
if (icy-br:* iswm %a) { hadd shout head 1 | did -ra shout 17 $2 | .timershout -m 0 500 shoutinf | break }
sockread %a
}
}
else {
sockread &a 8192
while ($sockbr) {
if ($hget(shout,play)) {
var %f = $+(shtmp,$hget(shout,wrt),.mp3)
bwrite %f -1 -1 &a
if ($file(%f).size >= 131072) {
if ($hget(shout,wrt) == 3) hadd shout wrt 1
else hinc shout wrt 1
if (!$hget(shout,ready)) { hinc shout ready | splay %f | disp Play: buffering ok, now playing }
else splay -q %f
write -c $+(shtmp,$hget(shout,wrt),.mp3)
}
}
bwrite $shortfn($hget(shout,file)) -1 -1 &a
sockread &a 8192
}
}
}
alias -l shoutinf {
did -ra shout 20 $duration($calc($sound($shortfn($hget(shout,file))).length /1000))
did -ra shout 21 $bytes($file($shortfn($hget(shout,file))).size,m) Mb
}
alias disp { did -a shout 6 $1- | did -c shout 6 $did(shout,6).lines }
alias -l shp {
if ($1 == -p) {
write -c shtmp1.mp3 | write -c shtmp2.mp3 | write -c shtmp3.mp3
hadd shout play 1 | hadd shout ready 0 | hadd shout wrt 1
disp Play: Please Wait (buffering 128kb) ...
hadd shout ispl 1
}
if ($1 == -s) {
splay stop | hadd shout play 0 | hadd shout ready 0 | hadd shout wrt 1 | hadd shout ispl 0
if ($isfile(shtmp1.mp3)) .remove shtmp1.mp3 | if ($isfile(shtmp2.mp3)) .remove shtmp2.mp3
if ($isfile(shtmp3.mp3)) .remove shtmp3.mp3
disp Play: Stopped
}
}