To read a file’s metadata with hsaudiotag, pick a class corresponding to the file you want to read, create an instance of it with the a file object or a filename as an argument, and fetch the attributes from it. For example, if you want to fetch attributes from a mp4 file, you’d do:
>>> from hsaudiotag import mp4
>>> myfile = mp4.File('foo.m4a')
>>> myfile.artist
'Built To Spill'
>>> myfile.album
'There Is No Enemy'
>>> myfile.duration
218
The mpeg.Mpeg and aiff.File classes are special cases where tags are contained in the tag attribute.
Since v1.1, there’s a new wrapper class, auto.File which automatically detects the type of the file and provides a unified interface to its attributes (something the different classes of hsaudiotag don’t have). To use it, instantiate it like you would with any other class, that is auto.File(filename_or_file_object). All the attributes are in the wrapper, but if you want to access the “original” class, use the original attribute. Example:
>>> from hsaudiotag import auto
>>> myfile = auto.File('foo.m4a')
>>> myfile.artist
'Built To Spill'
>>> myfile.album
'There Is No Enemy'
>>> myfile.duration
218
>>>> myfile.original
<mp4.File object>