#!/bin/sh

# This file is maintained at http://git.mdcc.cx/draai
#
# Copyright: © 2008 Joost van Baal. This program is in the public domain.

# dr_file2tag - build tag info from filename
#
# example usage:
#   eval `dr_file2tag 03-Wochtzchée-Sleepin_instructions_\(extract\).ogg`
#

set -e

file="$1"
# [artist-]title.{ogg,mp3}

# strip .mp3 , .ogg
file="`echo $file | sed 's/\.[^\.]*$//'`"

# strip leading 01-
file="`echo $file | sed 's/^[0-9]*-//'`"

file="`echo $file | sed 's/_/ /g'`"

artist="`echo $file | cut -d- -f1`"

if test "$artist" != "$file"
then
    echo "ARTIST=$artist"
    file="`echo $file | cut -d- -f2`"
fi

echo "TITLE=$file"

# oggenc(1):
# ARTIST is -a, ALBUM is -l TITLE is -t.


