Streaming mp3 server with NS-K330 NAS running SnakeOS

I just got a NS-K330 NAS off Deal Extreme, it’s a super cheap-o 3W network attached storage device.  Just add a USB powered HD and you’re ready to go.

The operating system that it comes installed with doesn’t do very much, so the good hackers over at SnakeOS have made a simple BusyBox-based distribution that you can use to replace it.  In 3 minutes you’ve got an embedded Linux server running ssh/sftp, ftp, samba, http.  Did I mention it only draws 3W?

Once I got SnakeOS installed I was disappointed to discover the embedded web server doesn’t support directory listings.  It does however support CGI scripting.  It took me a few minutes to put this together, but here are two scripts you can install in your web server /cgi-bin directory to enable directory browsing and automatic generation of m3u files for your mp3 collection:

# Generates a directory listing, links directory to m3u generator
echo "Content-type: text/html"
echo ""
| sed -r 's/%20/ /g' \ | sed -r "s/%27/'/" \
| sed -r 's/^\///'` echo "<h2><a href=\"/cgi-bin/m3u?$QUERY\">/$QUERY</a></h2>" ls -l "../$QUERY" | grep ^d \
| awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' \ | sed -r 's/^[ ]+//' \ | sed -r "s/^(.*)$/<a href=\"?$QUERY\/\1\">\1<\/a><br>/" ls -l "../$QUERY" | grep -v ^d \
| awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' \ | sed -r 's/^[ ]+//' \ | awk "{printf(\"<a href=\\\"/$QUERY/%s\\\">%s<br>\", \$0, \$0);}"
# Generates m3u from query parameter
echo "Content-type: audio/mpegurl"
echo ""
| sed -r 's/%20/ /g' \ | sed -r "s/%27/'/g" \
| sed -r 's/^\///'` find "../$QUERY" -name *.mp3 \
| sed -r 's/\.\./http:\/\/' \ | sed -r 's/ /%20/g'

Not the cleanest of scripts, but it gets it done.  BusyBox doesn’t have a complete “find” implementation so this kinda limited what I could do.

As I’m writing this it does not appear this system is the most robust of web servers… Both WinAMP and Windows Media Player are seizing up part way through songs and reporting network errors. Hmm. I guess for $40 I can’t complain.

One Reply to “Streaming mp3 server with NS-K330 NAS running SnakeOS”

  1. Pleasantly surprised you can get a full featured Linux server / NAS which draws only 3w for $40 shipped. Plus it streams media to my PS3 and my new Samsung TV. Remarkable.
    Streaming music over FTP appears to be quite reliable.

Leave a Reply