#!/bin/sh
# ffms2m3u.sh - create playlist for all files on a Firefly Media Server
# created by scruss on Tue Sep 2 20:28:06 EDT 2008
# if you're running this from a cron job, it's probably a good idea to fill
#  in the real paths for sqlite3 and awk.

# where the Firefly database lives
DATABASE="/usr/var/cache/mt-daapd/songs3.db"
# server domain name or IP address
SERVER="server.example.com"
# Port to talk to server - don't leave blank
PORT="3689"

echo 'select id, title, artist, album, track,song_length from songs order by album, track, artist, title;' |\
 sqlite3 $DATABASE |\
 awk -v server="$SERVER" -v port="$PORT" -F\| 'BEGIN{print "#EXTM3U";} {print "#EXTINF:" int($6/1000) "," $3 " - " $2 "\nhttp://" server ":" port "/rsp/stream/" $1;}'


