| ApeTag (version 1.2) | index /data/code/ape_tag_libs/python/ApeTag.py |
Module for manipulating APE and ID3v1 tags
Public Function Arguments
-------------------------
fil: filename string OR already opened file or file-like object that supports
flush, seek, read, truncate, tell, and write
fields: dictionary like object of tag fields that has an iteritems method
which is an iterator of key, value tuples.
APE:
key: must be a regular string with length 2-255 inclusive, containing
only ASCII characters in the range 0x20-0x7f
value: must be a string or a list or tuple of them, or an ApeItem
ID3:
key: must be title, artist, album, year, comment, genre, or track*
(i.e. track or tracknumber)
value: should be a string except for track* and genre
track*: integer or sting representation of one
genre: integer or string (if string, must be a case insensitive
match for one of the strings in id3genres to be recognized)
removefields (updateape and updatetags): iterable of fields to remove from the
APE tag (and set to blank in the ID3 tag).
Public Functions Return
-----------------------
0 on success of delete functions
bool on success of has functions
string on success of getraw functions
dict on success of create, update, replace, modify, or getfields
key is the field name as a string
(APE) value is an ApeItem, which is a list subclass with the field values
stored in the list as strings, and the following special attributes:
key: same as key of dict
readonly: whether the field was marked read only
type: type of tag field (utf8, binary, external, or reserved),
utf8 type means values in list are unicode strings
(ID3) value is a regular string
Public Functions Raise
----------------------
IOError on problem accessing file (make sure read/write access is allowed
for the file if you are trying to modify the tag)
(APE functions only) UnicodeError on problems converting regular strings to
UTF-8 (See note, or just use unicode strings)
TagError on other errors
Callback Functions
------------------
The modify* functions take callback functions and extra keyword arguments.
The callback functions are called with the tag dictionary and any extra keyword
arguments given in the call to modify*. This dictionary should be modified and
must be returned by the callback functions. There isn't much error checking
done after this stage, so incorrectly written callback functions may result in
corrupt tags or exceptions being raised elsewhere in the module. The
modifytags function takes two separate callback functions, one for the APE tag
and one for the ID3 tag. See the _update*tagcallback functions for examples of
how callback functions should be written.
Notes
-----
When using functions that modify both tags, the accepted arguments and return
value are the same for the APE funtion.
Raising errors other than IOError, UnicodeError, or TagError is considered a
bug unless fields contains a non-basestring (or a list containing a
non-basestring).
Only APEv2 tags are supported. APEv1 tags without a header are not supported.
Only writes ID3v1.1 tags. Assumes all tags are ID3v1.1. The only exception to
this is when it detects an ID3v1.0 tag, it will return 0 as the track
number in getfields.
The APE tag is appended to the end of the file. If the file already has an
ID3v1 tag at the end, it is recognized and the APE tag is placed directly
before it.
Default maximum size for the APE tag is 8192 bytes, as recommended by the APE
spec. This can be changed by modifying the _maxapesize variable.
Read-only flags can be read, created, and modified (they are not respected).
If you are storing non 7-bit ASCII data in a tag, you should pass in unicode
strings instead of regular strings, or pass in an already created ApeItem.
Inserting binary data into tags is "strongly unrecommended."
This library doesn't check to make sure that tag items marked as external are
in the proper format.
APEv2 specification is here:
http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification
| Classes | ||||||||||||||||||
|
| ||||||||||||||||||
| Functions | ||
| ||
| Data | ||
| __version__ = '1.2' apeitemkeys = ['Title', 'Artist', 'Album', 'Year', 'Comment', 'Genre', 'Track', 'Debut Album', 'Subtitle', 'Publisher', 'Conductor', 'Composer', 'Copyright', 'Publicationright', 'File', 'EAN/UPC', 'ISBN', 'Catalog', 'LC', 'Record Date', ...] id3genres = ['Blues', 'Classic Rock', 'Country', 'Dance', 'Disco', 'Funk', 'Grunge', 'Hip-Hop', 'Jazz', 'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R & B', 'Rap', 'Reggae', 'Rock', 'Techno', 'Industrial', ...] | ||