APEv2

APEv2 reading and writing.

The APEv2 format is most commonly used with Musepack files, but is also the format of choice for WavPack and other formats. Some MP3s also have APEv2 tags, but this can cause problems with many MP3 decoders and taggers.

APEv2 tags, like Vorbis comments, are freeform key=value pairs. APEv2 keys can be any ASCII string with characters from 0x20 to 0x7E, between 2 and 255 characters long. Keys are case-sensitive, but readers are recommended to be case insensitive, and it is forbidden to multiple keys which differ only in case. Keys are usually stored title-cased (e.g. ‘Artist’ rather than ‘artist’).

APEv2 values are slightly more structured than Vorbis comments; values are flagged as one of text, binary, or an external reference (usually a URI).

Based off the format specification found at http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification.

exception mutagen.apev2.error
exception mutagen.apev2.APENoHeaderError
exception mutagen.apev2.APEUnsupportedVersionError
exception mutagen.apev2.APEBadItemError
class mutagen.apev2.APEv2File(filething)

Bases: FileType

Parameters:

filething (filething) –

tags
Type:

APEv2

add_tags()

Adds new tags to the file.

Raises:

mutagen.MutagenError – if tags already exist or adding is not possible.

static score(filename, fileobj, header)

Returns a score for how likely the file can be parsed by this type.

Parameters:
  • filename (fspath) – a file path

  • fileobj (fileobj) – a file object open in rb mode. Position is undefined

  • header (bytes) – data of undefined length, starts with the start of the file.

Returns:

negative if definitely not a matching type, otherwise a score,

the bigger the more certain that the file can be loaded.

Return type:

int

class mutagen.apev2.APEv2(filething=None)

A file with an APEv2 tag.

ID3v1 tags are silently ignored and overwritten.

Bases:

mutagen.Metadata

pprint()

Return tag key=value pairs in a human-readable format.

load(filething)

Load tags from a filename.

Raises apev2.error

save(filething=None)

Save changes to a file.

If no filename is given, the one most recently loaded is used.

Tags are always written at the end of the file, and include a header and a footer.

delete(filething=None)

Remove tags from a file.