Library reference

pytag

class pytag.AudioReader(path)

High level interface for pytag. Creates a new object if the audio format is supported, or returns a pytag.FormatNotSupportedError if not.

class pytag.Audio(path)

Extends pytag.AudioReader and adds a write_tags method.

class pytag.FormatNotSupportedError

Codecs

class pytag.codecs.VorbisComment

Base class to read/write vorbis comments as defined at: http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html

process_comments(packet)

Reads the comments.

Parameters:packet (pytag.containers.PacketReader) – Object to read from, has a read method.
Returns:A dict-like object with all the comments.
Return type:pytag.structures.CaseInsensitiveDict
class pytag.codecs.Vorbis

Bases: pytag.codecs.VorbisComment

Constants

pytag.constants.FIELD_NAMES = ('title', 'artist', 'album', 'date', 'tracknumber', 'organization', 'genre', 'performer')

Default comments/tags accepted by pytag

Containers

class pytag.containers.OggPage(fileobj)
as_bytes(update_crc=False)

Get the complete page as bytes.

Paramer update_crc:
 Flag to know if recalculate the CRC.
Returns:Ogg page
Return type:array.array of bytes, typecode = ‘B’
get_packet_info()

Gets the size of the next packet (or partial packet) in the current page. This size can be smaller than the full packet because a packet can we splited in severa pages. Also check it the packet finish in the current page. If page has no more bytes to read, this function iterates to the next page. The idea is use this function as callback in PacketReader, this way, when a packet is readed, the reader doesn’t need to worry about how the packet is saved inside an ogg stream.

Returns:Next packet size and if the packet finish in this page.
Return type:collections.namedtuple of type PacketInfo
get_packet_reader()

Get a packet reader for the current page.

Returns:A packet reader over the same stream used by this OggPage
Return type:PacketReader
is_last_page()

Check if the page is the last in a logical bitstream. :returns: True if is the last one, False if not. :rtype: boolean

next_page()

Iterates to next page.

rest_of_pages()

Iterator over still not readed pages.

class pytag.containers.OggReader(path)
comments_page_position()

Returns the page number where the comments start.

process_comments(packet)

Returns the comments.

class pytag.containers.Ogg(path)
packets_after_comments()

Returns the number of packets in the same page after the comments packet

write_tags(comments)

Write the tags to a new file, if no path is provided, the original file is overwrited

class pytag.containers.PacketReader(fileobj, get_packet_info_callback)

My class doc.

read(_n=-1)

Read up to n bytes from the current packet in the stream and return them. If n is unspecified or -1, read and return all the bytes until the packet end.

Formats

class pytag.formats.OggVorbisReader(path)

Bases: pytag.codecs.Vorbis, pytag.containers.OggReader

class pytag.formats.OggVorbis(path)

Structures

CaseInsensitiveDict

class pytag.structures.CaseInsensitiveDict(data=None, **kwargs)

A case-insensitive dict-like object.

Implements all methods and operations of collections.abc.MutableMapping as well as dict’s dict.copy().

All keys are expected to be strings. The structure always set the key to lower case.

cid = CaseInsensitiveDict()
cid['Key'] = 'value'
cid['KEY'] == 'value'  # True
list(cid) == ['key']   # True

If the constructor, update, or equality comparison operations are given keys that have equal str.lower(), the behavior is undefined.

PytagDict

class pytag.structures.PytagDict(data=None, **kwargs)

A case-insensitive dict-like object where only the values defines in pytag.constants.FIELD_NAMES constant are allowed as keys. If a key is not valid, is ignored without any warning.

Useful Links

Previous topic

Supported formats

Table Of Contents

This Page