eyed3.id3 package

Submodules

eyed3.id3.apple module

Here lies Apple frames, all of which are non-standard. All of these would have been standard user text frames by anyone not being a bastard, on purpose.

class eyed3.id3.apple.PCST(_=None)[source]

Bases: eyed3.id3.frames.Frame

Indicates a podcast. The 4 bytes of data is undefined, and is typically all 0.

render()[source]
class eyed3.id3.apple.TKWD(_=None)[source]

Bases: eyed3.id3.frames.TextFrame

Podcast keywords.

class eyed3.id3.apple.TDES(_=None)[source]

Bases: eyed3.id3.frames.TextFrame

Podcast description. One encoding byte followed by text per encoding.

class eyed3.id3.apple.TGID(_=None)[source]

Bases: eyed3.id3.frames.TextFrame

Podcast URL of the audio file. This should be a W frame!

class eyed3.id3.apple.WFED(_=None, url='')[source]

Bases: eyed3.id3.frames.TextFrame

Another podcast URL, the feed URL it is said.

class eyed3.id3.apple.GRP1(_=None)[source]

Bases: eyed3.id3.frames.TextFrame

Apple grouping, could be a TIT1 conversion.

eyed3.id3.frames module

exception eyed3.id3.frames.FrameException(*args)[source]

Bases: eyed3.Error

class eyed3.id3.frames.Frame(**kwargs)[source]

Bases: object

property header
parse(**kwargs)
render()[source]
static decompress(data)[source]
static compress(data)[source]
static decrypt(data)[source]
static encrypt(data)[source]
property text_delim
property encoding
class eyed3.id3.frames.TextFrame(**kwargs)[source]

Bases: eyed3.id3.frames.Frame

Text frames. Data string format: encoding (one byte) + text

property text
parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.UserTextFrame(**kwargs)[source]

Bases: eyed3.id3.frames.TextFrame

property description
parse(data, frame_header)[source]

Data string format: encoding (one byte) + description + b”” + text

render()[source]
class eyed3.id3.frames.DateFrame(id, date='')[source]

Bases: eyed3.id3.frames.TextFrame

parse(data, frame_header)[source]
property date
class eyed3.id3.frames.UrlFrame(id, url='')[source]

Bases: eyed3.id3.frames.Frame

property url
parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.UserUrlFrame(**kwargs)[source]

Bases: eyed3.id3.frames.UrlFrame

Data string format: encoding (one byte) + description + b”” + url (iso-8859-1)

property description
parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.ImageFrame(**kwargs)[source]

Bases: eyed3.id3.frames.Frame

OTHER = 0
ICON = 1
OTHER_ICON = 2
FRONT_COVER = 3
BACK_COVER = 4
LEAFLET = 5
MEDIA = 6
LEAD_ARTIST = 7
ARTIST = 8
CONDUCTOR = 9
BAND = 10
COMPOSER = 11
LYRICIST = 12
RECORDING_LOCATION = 13
DURING_RECORDING = 14
DURING_PERFORMANCE = 15
VIDEO = 16
BRIGHT_COLORED_FISH = 17
ILLUSTRATION = 18
MIN_TYPE = 0
MAX_TYPE = 20
URL_MIME_TYPE = b'-->'
URL_MIME_TYPE_STR = '-->'
URL_MIME_TYPE_VALUES = (b'-->', '-->')
property description
property mime_type
property picture_type
parse(data, frame_header)[source]
render()[source]
static picTypeToString(t)[source]
static stringToPicType(s)[source]
makeFileName(name=None)[source]
class eyed3.id3.frames.ObjectFrame(**kwargs)[source]

Bases: eyed3.id3.frames.Frame

property description
property mime_type
property filename
parse(data, frame_header)[source]

Parse the frame from data bytes using details from frame_header.

Data string format: <Header for ‘General encapsulated object’, ID: “GEOB”> Text encoding $xx MIME type <text string> $00 Filename <text string according to encoding> $00 (00) Content description <text string according to encoding> $00 (00) Encapsulated object <binary data>

render()[source]
class eyed3.id3.frames.PrivateFrame(id=b'PRIV', owner_id=b'', owner_data=b'')[source]

Bases: eyed3.id3.frames.Frame

PRIV

parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')[source]

Bases: eyed3.id3.frames.Frame

property toc
parse(data, frame_header)[source]
class eyed3.id3.frames.PlayCountFrame(id=b'PCNT', count=0)[source]

Bases: eyed3.id3.frames.Frame

parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.PopularityFrame(id=b'POPM', email=b'', rating=0, count=0)[source]

Bases: eyed3.id3.frames.Frame

Frame type for ‘POPM’ frames; popularity. Frame format: <Header for ‘Popularimeter’, ID: “POPM”> Email to user <text string> $00 Rating $xx Counter $xx xx xx xx (xx …)

property rating
property email
property count
parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.UniqueFileIDFrame(id=b'UFID', owner_id=b'', uniq_id=b'')[source]

Bases: eyed3.id3.frames.Frame

property owner_id
property uniq_id
parse(data, frame_header)[source]

Data format Owner identifier <text string> $00 Identifier up to 64 bytes binary data>

render()[source]
class eyed3.id3.frames.LanguageCodeMixin[source]

Bases: object

property lang
class eyed3.id3.frames.DescriptionLangTextFrame(**kwargs)[source]

Bases: eyed3.id3.frames.Frame, eyed3.id3.frames.LanguageCodeMixin

property description
property text
parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.CommentFrame(id=b'COMM', description='', lang=b'eng', text='')[source]

Bases: eyed3.id3.frames.DescriptionLangTextFrame

class eyed3.id3.frames.LyricsFrame(id=b'USLT', description='', lang=b'eng', text='')[source]

Bases: eyed3.id3.frames.DescriptionLangTextFrame

class eyed3.id3.frames.TermsOfUseFrame(**kwargs)[source]

Bases: eyed3.id3.frames.Frame, eyed3.id3.frames.LanguageCodeMixin

property text
parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.TocFrame(**kwargs)[source]

Bases: eyed3.id3.frames.Frame

Table of content frame. There may be more than one, but only one may have the top-level flag set.

Data format: Element ID: <string>TOC flags: %000000ab Entry count: %xx Child elem IDs: <string>(… num entry count) Description: TIT2 frame (optional)

TOP_LEVEL_FLAG_BIT = 6
ORDERED_FLAG_BIT = 7
parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.RelVolAdjFrameV24(fid=b'RVA2', identifier=None, channel_type=None, adjustment=None, peak=None)[source]

Bases: eyed3.id3.frames.Frame

CHANNEL_TYPE_OTHER = 0
CHANNEL_TYPE_MASTER = 1
CHANNEL_TYPE_FRONT_RIGHT = 2
CHANNEL_TYPE_FRONT_LEFT = 3
CHANNEL_TYPE_BACK_RIGHT = 4
CHANNEL_TYPE_BACK_LEFT = 5
CHANNEL_TYPE_FRONT_CENTER = 6
CHANNEL_TYPE_BACK_CENTER = 7
CHANNEL_TYPE_BASS = 8
property identifier
property channel_type
property adjustment
property peak
parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.RelVolAdjFrameV23(fid=b'RVAD')[source]

Bases: eyed3.id3.frames.Frame

FRONT_CHANNEL_RIGHT_BIT = 0
FRONT_CHANNEL_LEFT_BIT = 1
BACK_CHANNEL_RIGHT_BIT = 2
BACK_CHANNEL_LEFT_BIT = 3
FRONT_CENTER_CHANNEL_BIT = 4
BASS_CHANNEL_BIT = 5
CHANNEL_DEFN = [('front_right', 0), ('front_left', 1), ('front_right_peak', None), ('front_left_peak', None), ('back_right', 2), ('back_left', 3), ('back_right_peak', None), ('back_left_peak', None), ('front_center', 4), ('front_center_peak', None), ('bass', 5), ('bass_peak', None)]
class VolumeAdjustments(master: int = 0, master_peak: int = 0, front_right: int = 0, front_left: int = 0, front_right_peak: int = 0, front_left_peak: int = 0, back_right: int = 0, back_left: int = 0, back_right_peak: int = 0, back_left_peak: int = 0, front_center: int = 0, front_center_peak: int = 0, back_center: int = 0, back_center_peak: int = 0, bass: int = 0, bass_peak: int = 0, other: int = 0, other_peak: int = 0)[source]

Bases: object

master: int = 0
master_peak: int = 0
front_right: int = 0
front_left: int = 0
front_right_peak: int = 0
front_left_peak: int = 0
back_right: int = 0
back_left: int = 0
back_right_peak: int = 0
back_left_peak: int = 0
front_center: int = 0
front_center_peak: int = 0
back_center: int = 0
back_center_peak: int = 0
bass: int = 0
bass_peak: int = 0
other: int = 0
other_peak: int = 0
property has_master_channel
property has_front_channel
property has_back_channel
property has_front_center_channel
property has_back_center_channel
property has_bass_channel
property has_other_channel
boundsCheck()[source]
setChannelAdj(chan_type, value)[source]
setChannelPeak(chan_type, value)[source]
toV24() → list[source]

Return a list of RVA2 frames

parse(data, frame_header)[source]
render()[source]
class eyed3.id3.frames.StartEndTuple(start, end)

Bases: tuple

A 2-tuple, with names ‘start’ and ‘end’.

property end

Alias for field number 1

property start

Alias for field number 0

class eyed3.id3.frames.ChapterFrame(id=b'CHAP', element_id=None, times=None, offsets=None, sub_frames=None)[source]

Bases: eyed3.id3.frames.Frame

Frame type for chapter/section of the audio file. <ID3v2.3 or ID3v2.4 frame header, ID: “CHAP”> (10 bytes) Element ID <text string> $00 Start time $xx xx xx xx End time $xx xx xx xx Start offset $xx xx xx xx End offset $xx xx xx xx <Optional embedded sub-frames>

NO_OFFSET = 4294967295

No offset value, aka ‘0xff0xff0xff0xff’

parse(data, frame_header)[source]
render()[source]
property title
property subtitle
property user_url
class eyed3.id3.frames.FrameSet[source]

Bases: dict

parse(f, tag_header, extended_header)[source]

Read frames starting from the current read position of the file object. Returns the amount of padding which occurs after the tag, but before the audio content. A return valule of 0 does not mean error.

getAllFrames()[source]

Return all the frames in the set as a list. The list is sorted in an arbitrary but consistent order.

setTextFrame(**kwargs)
eyed3.id3.frames.deunsyncData(data)[source]
eyed3.id3.frames.createFrame(tag_header, frame_header, data)[source]
eyed3.id3.frames.decodeUnicode(bites, encoding)[source]
eyed3.id3.frames.splitUnicode(data, encoding)[source]
eyed3.id3.frames.id3EncodingToString(encoding)[source]
eyed3.id3.frames.stringToEncoding(s)[source]
eyed3.id3.frames.map2_2FrameId(orig_id)[source]

eyed3.id3.headers module

class eyed3.id3.headers.TagHeader(version=(2, 4, 0))[source]

Bases: object

SIZE = 10
clear()[source]
property version
property major_version
property minor_version
property rev_version
parse(f)[source]

Parse an ID3 v2 header starting at the current position of f.

If a header is parsed True is returned, otherwise False. If a header is found but malformed an eyed3.id3.tag.TagException is thrown.

render(tag_len=None)[source]
class eyed3.id3.headers.ExtendedTagHeader[source]

Bases: object

RESTRICT_TAG_SZ_LARGE = 0
RESTRICT_TAG_SZ_MED = 1
RESTRICT_TAG_SZ_SMALL = 2
RESTRICT_TAG_SZ_TINY = 3
RESTRICT_TEXT_ENC_NONE = 0
RESTRICT_TEXT_ENC_UTF8 = 1
RESTRICT_TEXT_LEN_NONE = 0
RESTRICT_TEXT_LEN_1024 = 1
RESTRICT_TEXT_LEN_128 = 2
RESTRICT_TEXT_LEN_30 = 3
RESTRICT_IMG_ENC_NONE = 0
RESTRICT_IMG_ENC_PNG_JPG = 1
RESTRICT_IMG_SZ_NONE = 0
RESTRICT_IMG_SZ_256 = 1
RESTRICT_IMG_SZ_64 = 2
RESTRICT_IMG_SZ_64_EXACT = 3
property update_bit
property crc_bit
property crc
property restrictions_bit
property tag_size_restriction
property tag_size_restriction_description
property text_enc_restriction
property text_enc_restriction_description
property text_length_restriction
property text_length_restriction_description
property image_enc_restriction
property image_enc_restriction_description
property image_size_restriction
property image_size_restriction_description
render(version, frame_data, padding=0)[source]
parse(fp, version)[source]

Parse an ID3 v2 extended header starting at the current position of fp and per the format defined by version. This method should only be called when the presence of an extended header is known since it moves the file position. If a header is found but malformed an eyed3.id3.tag.TagException is thrown. The return value is None.

class eyed3.id3.headers.FrameHeader(**kwargs)[source]

Bases: object

A header for each and every ID3 frame in a tag.

TAG_ALTER = None
FILE_ALTER = None
READ_ONLY = None
COMPRESSED = None
ENCRYPTED = None
GROUPED = None
UNSYNC = None
DATA_LEN = None
copyFlags(rhs)[source]
property major_version
property minor_version
property version
property tag_alter
property file_alter
property read_only
property compressed
property encrypted
property grouped
property unsync
property data_length_indicator
render(data_size)[source]
static parse(f, version)[source]

eyed3.id3.tag module

exception eyed3.id3.tag.TagException(*args)[source]

Bases: eyed3.Error

class eyed3.id3.tag.Tag(**kwargs)[source]

Bases: eyed3.core.Tag

clear()[source]

Reset all tag data.

parse(fileobj, version=(3, None, None))[source]
property version
isV1()[source]

Test ID3 major version for v1.x

isV2()[source]

Test ID3 major version for v2.x

setTextFrame(**kwargs)
getTextFrame(fid: bytes)[source]
property composer
property comments
property bpm
property play_count
property publisher
property cd_id
property images
property encoding_date
property best_release_date

This method tries its best to return a date of some sort, amongst alll the possible date frames. The order of preference for a release date is 1) date of original release 2) date of this versions release 3) the recording date. Or None is returned.

getBestDate(prefer_recording_date=False)[source]

This method returns a date of some sort, amongst all the possible date frames. The order of preference is:

  1. date of original release

  2. date of this versions release

  3. the recording date.

Unless prefer_recording_date is True in which case the order is 3, 1, 2.

None will be returned if no dates are available.

property release_date

The date the audio was released. This is NOT the original date the work was released, instead it is more like the pressing or version of the release. Original release date is usually what is intended but many programs use this frame and/or don’t distinguish between the two.

NOTE: ID3v2.3 only has original release date, so setting release_date is the same as original_release_value; they both set TORY.

property original_release_date

The date the work was originally released.

NOTE: ID3v2.3 only stores year. If the Date object is more precise it is store in XDOR, and XDOR is preferred when acessing. The year-only date is stored in the standard TORY frame as well.

property recording_date

The date of the recording. Many applications use this for release date regardless of the fact that this value is rarely known, and release dates are more correct.

property tagging_date
property lyrics
property disc_num
property objects
property privates
property popularities
property genre
property non_std_genre
property user_text_frames
property commercial_url
property copyright_url
property audio_file_url
property audio_source_url
property artist_url
property internet_radio_url
property payment_url
property publisher_url
property user_url_frames
property unique_file_ids
property terms_of_use
property copyright
property encoded_by
save(filename=None, version=None, encoding=None, backup=False, preserve_file_time=False, max_padding=None)[source]

Save the tag. If filename is not give the value from the file_info member is used, or a TagException is raised. The version argument can be used to select an ID3 version other than the version read. Select text encoding with ``encoding or use the existing (or default) encoding. If backup is True the orignal file is preserved; likewise if preserve_file_time is True the file´s modification/access times are not updated.

static remove(filename, version=(3, None, None), preserve_file_time=False)[source]
property chapters
property table_of_contents
property album_type
property artist_origin

Returns None or a ArtistOrigin dataclass: (city, state, country) Any may be None.

frameiter(fids=None)[source]

A iterator for tag frames. If fids is passed it must be a list of frame IDs to filter and return.

property original_artist
class eyed3.id3.tag.FileInfo(file_name, tagsz=0, tpadd=0)[source]

Bases: object

This class is for storing information about a parsed file. It contains info such as the filename, original tag size, and amount of padding; all of which can make rewriting faster.

initStatTimes()[source]
touch(times)[source]

times is a 2-tuple of (atime, mtime).

class eyed3.id3.tag.AccessorBase(fid, fs, match_func=None)[source]

Bases: object

get(*args, **kwargs)[source]
remove(*args, **kwargs)[source]

Returns the removed item or None if not found.

class eyed3.id3.tag.DltAccessor(FrameClass, fid, fs)[source]

Bases: eyed3.id3.tag.AccessorBase

Access matching tag frames by “description” and/or “lang” values.

set(**kwargs)
remove(**kwargs)
get(**kwargs)
class eyed3.id3.tag.CommentsAccessor(fs)[source]

Bases: eyed3.id3.tag.DltAccessor

class eyed3.id3.tag.LyricsAccessor(fs)[source]

Bases: eyed3.id3.tag.DltAccessor

class eyed3.id3.tag.ImagesAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(**kwargs)
remove(**kwargs)
get(**kwargs)
class eyed3.id3.tag.ObjectsAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(**kwargs)
remove(**kwargs)
get(**kwargs)
class eyed3.id3.tag.PrivatesAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(data, owner_id)[source]
remove(owner_id)[source]

Returns the removed item or None if not found.

get(owner_id)[source]
class eyed3.id3.tag.UserTextsAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(**kwargs)
remove(**kwargs)
get(**kwargs)
class eyed3.id3.tag.UniqueFileIdAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(data, owner_id)[source]
remove(owner_id)[source]

Returns the removed item or None if not found.

get(owner_id)[source]
class eyed3.id3.tag.UserUrlsAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(**kwargs)
remove(**kwargs)
get(**kwargs)
class eyed3.id3.tag.PopularitiesAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(email, rating, play_count)[source]
remove(email)[source]

Returns the removed item or None if not found.

get(email)[source]
class eyed3.id3.tag.ChaptersAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(element_id, times, offsets=(None, None), sub_frames=None)[source]
remove(element_id)[source]

Returns the removed item or None if not found.

get(element_id)[source]
class eyed3.id3.tag.TocAccessor(fs)[source]

Bases: eyed3.id3.tag.AccessorBase

set(**kwargs)
remove(element_id)[source]

Returns the removed item or None if not found.

get(element_id)[source]
class eyed3.id3.tag.TagTemplate(pattern, path_friendly='-', dotted_dates=False)[source]

Bases: string.Template

pattern = re.compile('\n \\$(?:\n (?P<escaped>\\$) | # Escape sequence of two delimiters\n (?P<named>[_a-z][_a-z0-9:]*) | # delimiter and a Python identifier\n {(?P<braced>[_a-z][_a-z0-9:]*)} |, re.IGNORECASE|re.VERBOSE)
idpattern = '[_a-z][_a-z0-9:]*'
substitute(tag, zeropad=True)[source]
safe_substitute(tag, zeropad=True)

Module contents

eyed3.id3.isValidVersion(v, fully_qualified=False)[source]

Check the tuple v against the list of valid ID3 version constants. If fully_qualified is True it is enforced that there are 3 components to the version in v. Returns True when valid and False otherwise.

eyed3.id3.normalizeVersion(v)[source]

If version tuple v is of the non-specific type (v1 or v2, any, etc.) a fully qualified version is returned.

eyed3.id3.versionToString(v)[source]

Conversion version tuple v to a string description.

exception eyed3.id3.GenreException(*args)[source]

Bases: eyed3.Error

Excpetion type for exceptions related to genres.

class eyed3.id3.Genre(name=None, id: int = None, genre_map=None)[source]

Bases: object

A genre in terms of a name and and id. Only when name is a “standard” genre (as defined by ID3 v1) will id be a value other than None.

Constructor takes an optional name and ID. If id is provided the name, regardless of value, is set to the string the id maps to. Likewise, if name is passed and is a standard genre the id is set to the correct value. Any invalid id values cause a ValueError to be raised. Genre names that are not in the standard list are still accepted but the id value is set to None.

property id

The Genre’s id property. When setting the value is strictly enforced and if the value is not a valid genre code a ValueError is raised. Otherwise the id is set and the name property is updated to the code’s string name.

property name

The Genre’s name property. When setting the value the name is looked up in the standard genre map and if found the id ppropery is set to the numeric valud and the name is normalized to the sting found in the map. Non standard genres are set (with a warning log) and the id is set to None. It is valid to set the value to None.

static parse(g_str, id3_std=True)[source]

Parses genre information from genre_str. The following formats are supported: 01, 2, 23, 125 - ID3 v1.x style. (01), (2), (129)Hardcore, (9)Metal, Indie - ID3v2 style with and without

refinement.

Raises GenreException when an invalid string is passed.

class eyed3.id3.GenreMap(*args)[source]

Bases: dict

Classic genres defined around ID3 v1 but suitable anywhere. This class is used primarily as a way to map numeric genre values to a string name. Genre strings on the other hand are not required to exist in this list.

The optional *args are passed directly to the dict constructor.

GENRE_MIN = 0
GENRE_MAX = 191
ID3_GENRE_MIN = 0
ID3_GENRE_MAX = 79
WINAMP_GENRE_MIN = 80
WINAMP_GENRE_MAX = 191
GENRE_ID3V1_MAX = 255
get(key)[source]

Return the value for key if key is in the dictionary, else default.

property ids
iter()[source]
class eyed3.id3.TagFile(path, version=(3, None, None))[source]

Bases: eyed3.core.AudioFile

A shim class for dealing with files that contain only ID3 data, no audio.

Construct with a path and invoke _read. All other members are set to None.

initTag(version=(2, 4, 0))[source]

Add a id3.Tag to the file (removing any existing tag if one exists).