#!/bin/bash

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

hash_image() {
    python3 <<END
import hashlib, mutagen
file = mutagen.File('$1')
artwork = file.tags['APIC:'].data
print(hashlib.sha1(artwork).hexdigest())
END
}

check_equal "$(hash_image "$DIRNAME/obama.mp3")" 794865299f4fac10ba5719b203f0c71b5b524e95
check_equal "$(hash_image "$DIRNAME/ra[ven].mp3")" 5cd44d9e64c90d137ed3614213e309afec060dbc
