Main Module

Mutagen aims to be an all purpose tagging library.

import mutagen.[format]
metadata = mutagen.[format].Open(filename)

metadata acts like a dictionary of tags in the file. Tags are generally a list of string-like values, but may have additional methods available depending on tag or format. They may also be entirely different objects for certain keys, again depending on format.

mutagen.File(filename, options=None, easy=False)

Guess the type of the file and try to open it.

The file type is decided by several things, such as the first 128 bytes (which usually contains a file type identifier), the filename extension, and the presence of existing tags.

If no appropriate type could be found, None is returned.

Parameters:
  • options – Sequence of FileType implementations, defaults to all included ones.
  • easy – If the easy wrappers should be returnd if available. For example EasyMP3 instead of MP3.
mutagen.version = (1, 22)

Version tuple.

mutagen.version_string = '1.22'

Version string.

Base Classes

class mutagen.FileType(filename)

Bases: mutagen._util.DictMixin

An abstract object wrapping tags and audio stream information.

Attributes:

  • info – stream information (length, bitrate, sample rate)
  • tags – metadata tags, if any

Each file format has different potential tags and stream information.

FileTypes implement an interface very similar to Metadata; the dict interface, save, load, and delete calls on a FileType call the appropriate methods on its tag data.

delete()

Remove tags from a file.

save()

Save metadata tags.

pprint()

Print stream information and comment key=value pairs.

add_tags()

Adds new tags to the file.

Raises if tags already exist.

mime

A list of mime types

class mutagen.Metadata(*args, **kwargs)

An abstract dict-like object.

Metadata is the base class for many of the tag objects in Mutagen.

delete()

Remove tags from a file.

save()

Save changes to a file.

Internal Classes

Utility classes for Mutagen.

You should not rely on the interfaces here being stable. They are intended for internal use in Mutagen only.

class mutagen._util.DictMixin

Implement the dict API using keys() and __*item__ methods.

Similar to UserDict.DictMixin, this takes a class that defines __getitem__, __setitem__, __delitem__, and keys(), and turns it into a full dict-like object.

UserDict.DictMixin is not suitable for this purpose because it’s an old-style class.

This class is not optimized for very large dictionaries; many functions have linear memory requirements. I recommend you override some of these functions if speed is required.

class mutagen._util.DictProxy(*args, **kwargs)

Bases: mutagen._util.DictMixin

Table Of Contents

Previous topic

API

Next topic

ID3v2

This Page