#!/bin/bash

. "${BASH_SOURCE%/*}/funcs.sh"

get_metadata() {
    python3 <<END
import mutagen
file = mutagen.File('$1')
tags = ['%s=%s' % (k, v) for k, v in file.tags.items() if k[0] == 'T']
print('\n'.join(sorted(tags)))
END
}

cmp -s - <(get_metadata "$DIRNAME/obama.mp3") <<END
TALB=US State of the Union 2011
TCON=Spoken
TCOP=Public Domain
TDRC=2011-01-25
TIT2=The Internet [excerpt]
TLEN=6000
TPE1=Barack Obama
TPOS=0/0
TRCK=1/1
TSSE=MP3FS
END

cmp -s - <(get_metadata "$DIRNAME/raven.mp3") <<END
TALB=The Raven
TCON=Speech
TDRC=2007
TIT2=the_raven
TLEN=20970
TPE1=Edgar Allen Poe
TRCK=01
TSSE=MP3FS
END
