Back to index

eyed3  0.6.18
Classes | Functions | Variables
frames Namespace Reference

Classes

class  FrameException
class  FrameHeader
class  Frame
class  TextFrame
class  DateFrame
class  UserTextFrame
class  URLFrame
class  UserURLFrame
class  CommentFrame
class  LyricsFrame
class  ImageFrame
class  ObjectFrame
class  PlayCountFrame
class  UniqueFileIDFrame
class  UnknownFrame
class  MusicCDIdFrame
class  FrameSet

Functions

def cleanNulls
def id3EncodingToString
def unsyncData
def deunsyncData
def splitUnicode
 Used for splitting user text tags that use null byte(s) to seperate a description and its text.
def createFrame
 Create and return the appropriate frame.
def map2_2FrameId
def dump_data_to_file
def encodeUnicode
 A suxtitute for Python's 'unicode' constructor which handles invalid string encodings (as seen in the real world).

Variables

list timeStampFormats
string ARTIST_FID = "TPE1"
string BAND_FID = "TPE2"
string CONDUCTOR_FID = "TPE3"
string REMIXER_FID = "TPE4"
string COMPOSER_FID = "TCOM"
list ARTIST_FIDS
string ALBUM_FID = "TALB"
string TITLE_FID = "TIT2"
string SUBTITLE_FID = "TIT3"
string CONTENT_TITLE_FID = "TIT1"
list TITLE_FIDS = [TITLE_FID, SUBTITLE_FID, CONTENT_TITLE_FID]
string COMMENT_FID = "COMM"
string LYRICS_FID = "USLT"
string GENRE_FID = "TCON"
string TRACKNUM_FID = "TRCK"
string DISCNUM_FID = "TPOS"
string USERTEXT_FID = "TXXX"
string CDID_FID = "MCDI"
string IMAGE_FID = "APIC"
string OBJECT_FID = "GEOB"
string URL_COMMERCIAL_FID = "WCOM"
string URL_COPYRIGHT_FID = "WCOP"
string URL_AUDIOFILE_FID = "WOAF"
string URL_ARTIST_FID = "WOAR"
string URL_AUDIOSRC_FID = "WOAS"
string URL_INET_RADIO_FID = "WORS"
string URL_PAYMENT_FID = "WPAY"
string URL_PUBLISHER_FID = "WPUB"
list URL_FIDS
string USERURL_FID = "WXXX"
string PLAYCOUNT_FID = "PCNT"
string UNIQUE_FILE_ID_FID = "UFID"
string BPM_FID = "TBPM"
string PUBLISHER_FID = "TPUB"
dictionary obsoleteFrames
string OBSOLETE_DATE_FID = "TDAT"
string OBSOLETE_YEAR_FID = "TYER"
string OBSOLETE_TIME_FID = "TIME"
string OBSOLETE_ORIG_RELEASE_FID = "TORY"
string OBSOLETE_RECORDING_DATE_FID = "TRDA"
list DATE_FIDS
dictionary frameDesc
dictionary TAGS2_2_TO_TAGS_2_3_AND_4
list NULL_FRAME_FLAGS = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
tuple TEXT_FRAME_RX = re.compile("^T[A-Z0-9][A-Z0-9][A-Z0-9]$")
tuple USERTEXT_FRAME_RX = re.compile("^" + USERTEXT_FID + "$")
tuple URL_FRAME_RX = re.compile("^W[A-Z0-9][A-Z0-9][A-Z0-9]$")
tuple USERURL_FRAME_RX = re.compile("^" + USERURL_FID + "$")
tuple COMMENT_FRAME_RX = re.compile("^" + COMMENT_FID + "$")
tuple LYRICS_FRAME_RX = re.compile("^" + LYRICS_FID + "$")
tuple CDID_FRAME_RX = re.compile("^" + CDID_FID + "$")
tuple IMAGE_FRAME_RX = re.compile("^" + IMAGE_FID + "$")
tuple OBJECT_FRAME_RX = re.compile("^" + OBJECT_FID + "$")
tuple PLAYCOUNT_FRAME_RX = re.compile("^" + PLAYCOUNT_FID + "$")
tuple UNIQUE_FILE_ID_FRAME_RX = re.compile("^" + UNIQUE_FILE_ID_FID + "$")
list KNOWN_BAD_FRAMES
string LATIN1_ENCODING = "\x00"
string UTF_16_ENCODING = "\x01"
string UTF_16BE_ENCODING = "\x02"
string UTF_8_ENCODING = "\x03"
 DEFAULT_ENCODING = LATIN1_ENCODING;
int DEFAULT_ID3_MAJOR_VERSION = 2
int DEFAULT_ID3_MINOR_VERSION = 4
string DEFAULT_LANG = "eng"

Class Documentation

class frames::FrameException
Thrown by invalid frames

Definition at line 318 of file frames.py.


Function Documentation

def frames.cleanNulls (   s)

Definition at line 299 of file frames.py.

00299 
00300 def cleanNulls(s):
00301     return "/".join([x for x in s.split('\x00') if x])

Here is the caller graph for this function:

def frames.createFrame (   frameHeader,
  data,
  tagHeader 
)

Create and return the appropriate frame.

Exceptions: ....

Definition at line 2187 of file frames.py.

02187 
02188 def createFrame(frameHeader, data, tagHeader):
02189   f = None
02190 
02191   # Text Frames
02192   if TEXT_FRAME_RX.match(frameHeader.id):
02193      if USERTEXT_FRAME_RX.match(frameHeader.id):
02194         f = UserTextFrame(frameHeader, data=data,
02195                           unsync_default=tagHeader.unsync)
02196      else:
02197         if frameHeader.id[:2] == "TD" or\
02198            frameHeader.id == OBSOLETE_DATE_FID or\
02199            frameHeader.id == OBSOLETE_YEAR_FID or \
02200            frameHeader.id == OBSOLETE_ORIG_RELEASE_FID:
02201            f = DateFrame(frameHeader, data=data,
02202                          unsync_default=tagHeader.unsync)
02203         else:
02204            f = TextFrame(frameHeader, data=data,
02205                          unsync_default=tagHeader.unsync)
02206   # Comment Frames.
02207   elif COMMENT_FRAME_RX.match(frameHeader.id):
02208      f = CommentFrame(frameHeader, data=data, unsync_default=tagHeader.unsync)
02209   # Lyrics Frames.
02210   elif LYRICS_FRAME_RX.match(frameHeader.id):
02211      f = LyricsFrame(frameHeader, data=data, unsync_default=tagHeader.unsync)
02212   # URL Frames.
02213   elif URL_FRAME_RX.match(frameHeader.id):
02214      if USERURL_FRAME_RX.match(frameHeader.id):
02215         f = UserURLFrame(frameHeader, data=data,
02216                          unsync_default=tagHeader.unsync)
02217      else:
02218         f = URLFrame(frameHeader, data=data, unsync_default=tagHeader.unsync)
02219   # CD Id frame.
02220   elif CDID_FRAME_RX.match(frameHeader.id):
02221      f = MusicCDIdFrame(frameHeader, data=data, unsync_default=tagHeader.unsync)
02222   # Attached picture
02223   elif IMAGE_FRAME_RX.match(frameHeader.id):
02224      f = ImageFrame(frameHeader, data=data, unsync_default=tagHeader.unsync)
02225   # Encapsulated object
02226   elif OBJECT_FRAME_RX.match(frameHeader.id):
02227      f = ObjectFrame(frameHeader, data=data, unsync_default=tagHeader.unsync)
02228   # Play count
02229   elif PLAYCOUNT_FRAME_RX.match(frameHeader.id):
02230      f = PlayCountFrame(frameHeader, data=data, unsync_default=tagHeader.unsync)
02231   # Unique file identifier
02232   elif UNIQUE_FILE_ID_FRAME_RX.match(frameHeader.id):
02233      f = UniqueFileIDFrame(frameHeader, data=data,
02234                            unsync_default=tagHeader.unsync)
02235 
02236   if f == None:
02237      f = UnknownFrame(frameHeader, data=data, unsync_default=tagHeader.unsync)
02238 
02239   return f
02240 

def frames.deunsyncData (   data)

Definition at line 559 of file frames.py.

00559 
00560 def deunsyncData(data):
00561     output = []
00562     safe = True
00563     for val in data:
00564         if safe:
00565             output.append(val)
00566             safe = (val != '\xff')
00567         else:
00568             if val != '\x00':
00569                 output.append(val)
00570             safe = True
00571     return ''.join(output)
00572 

Here is the caller graph for this function:

def frames.dump_data_to_file (   s,
  f 
)

Definition at line 2246 of file frames.py.

02246 
02247 def dump_data_to_file(s, f):
02248     f = file(f, "w")
02249     for c in s:
02250         f.write("\\x%.2x" % ord(c))
02251     f.write("\n")
02252     f.close()

def frames.encodeUnicode (   bytes,
  encoding 
)

A suxtitute for Python's 'unicode' constructor which handles invalid string encodings (as seen in the real world).

Definition at line 2256 of file frames.py.

02256 
02257 def encodeUnicode(bytes, encoding):
02258     if (encoding == id3EncodingToString(UTF_16_ENCODING) and
02259             len(bytes) % 2 and
02260             bytes[-2:] == "\x00\x00"):
02261         # Fixes: utf16, odd number of bytes (including 2-byte BOM) where
02262         #        the final byte is \x00
02263         # Users have sent tags with an invalid utf16 encoding thus 
02264         # python's unicode type can't decode. Fix this edge case.
02265         bytes = bytes[:-1]
02266 
02267     return unicode(bytes, encoding)
02268 

Here is the call graph for this function:

Here is the caller graph for this function:

def frames.id3EncodingToString (   encoding)

Definition at line 302 of file frames.py.

00302 
00303 def id3EncodingToString(encoding):
00304     if encoding == LATIN1_ENCODING:
00305         return "latin_1";
00306     elif encoding == UTF_8_ENCODING:
00307         return "utf_8";
00308     elif encoding == UTF_16_ENCODING:
00309         return "utf_16";
00310     elif encoding == UTF_16BE_ENCODING:
00311         return "utf_16_be";
00312     else:
00313         if strictID3():
00314             raise ValueError;
00315         else:
00316             return "latin_1";

Here is the call graph for this function:

Here is the caller graph for this function:

def frames.map2_2FrameId (   originalId)

Definition at line 2241 of file frames.py.

02241 
02242 def map2_2FrameId(originalId):
02243     if not TAGS2_2_TO_TAGS_2_3_AND_4.has_key(originalId):
02244         return originalId
02245     return TAGS2_2_TO_TAGS_2_3_AND_4[originalId]

Here is the caller graph for this function:

def frames.splitUnicode (   data,
  encoding 
)

Used for splitting user text tags that use null byte(s) to seperate a description and its text.

Definition at line 2164 of file frames.py.

02164 
02165 def splitUnicode(data, encoding):
02166     if encoding == LATIN1_ENCODING or encoding == UTF_8_ENCODING:
02167         retval = data.split("\x00", 1)
02168     elif encoding == UTF_16_ENCODING or encoding == UTF_16BE_ENCODING:
02169         # Two null bytes split, but since each utf16 char is also two 
02170         # bytes we need to ensure we found a proper boundary.
02171         (d, t) = data.split("\x00\x00", 1)
02172         if (len(d) % 2) != 0:
02173             (d, t) = data.split("\x00\x00\x00", 1)
02174             d += "\x00"
02175         retval = (d, t)
02176 
02177     if len(retval) != 2:
02178         # What we have here is an invalid tag in that contains only piece
02179         # of the information. In the spirit of not crashing on crap tags
02180         # return it as the ... description
02181         retval = (retval[0], "")
02182 
02183     return retval

Here is the caller graph for this function:

def frames.unsyncData (   data)

Definition at line 540 of file frames.py.

00540 
00541 def unsyncData(data):
00542     output = []
00543     safe = True
00544     for val in data:
00545         if safe:
00546             output.append(val)
00547             if val == '\xff':
00548                 safe = False
00549         elif val == '\x00' or val >= '\xe0':
00550             output.append('\x00')
00551             output.append(val)
00552             safe = (val != '\xff')
00553         else:
00554             output.append(val)
00555             safe = True
00556     if not safe:
00557         output.append('\x00')
00558     return ''.join(output)

Here is the caller graph for this function:


Variable Documentation

string frames.ALBUM_FID = "TALB"

Definition at line 41 of file frames.py.

string frames.ARTIST_FID = "TPE1"

Definition at line 34 of file frames.py.

Initial value:
00001 [ARTIST_FID, BAND_FID, CONDUCTOR_FID,
00002                       REMIXER_FID, COMPOSER_FID]

Definition at line 39 of file frames.py.

string frames.BAND_FID = "TPE2"

Definition at line 35 of file frames.py.

string frames.BPM_FID = "TBPM"

Definition at line 70 of file frames.py.

string frames.CDID_FID = "MCDI"

Definition at line 52 of file frames.py.

tuple frames.CDID_FRAME_RX = re.compile("^" + CDID_FID + "$")

Definition at line 267 of file frames.py.

string frames.COMMENT_FID = "COMM"

Definition at line 46 of file frames.py.

tuple frames.COMMENT_FRAME_RX = re.compile("^" + COMMENT_FID + "$")

Definition at line 265 of file frames.py.

string frames.COMPOSER_FID = "TCOM"

Definition at line 38 of file frames.py.

string frames.CONDUCTOR_FID = "TPE3"

Definition at line 36 of file frames.py.

string frames.CONTENT_TITLE_FID = "TIT1"

Definition at line 44 of file frames.py.

Initial value:
00001 ["TDRL", "TDOR", "TDRC", OBSOLETE_YEAR_FID,
00002                       OBSOLETE_DATE_FID]

Definition at line 88 of file frames.py.

Definition at line 294 of file frames.py.

Definition at line 295 of file frames.py.

Definition at line 296 of file frames.py.

string frames.DEFAULT_LANG = "eng"

Definition at line 297 of file frames.py.

string frames.DISCNUM_FID = "TPOS"

Definition at line 50 of file frames.py.

dictionary frames.frameDesc

Definition at line 91 of file frames.py.

string frames.GENRE_FID = "TCON"

Definition at line 48 of file frames.py.

string frames.IMAGE_FID = "APIC"

Definition at line 53 of file frames.py.

tuple frames.IMAGE_FRAME_RX = re.compile("^" + IMAGE_FID + "$")

Definition at line 268 of file frames.py.

Initial value:
00001 [
00002     "\x00\x00MP",
00003     "\x00MP3",
00004     " MP3",
00005     "MP3e",
00006     "\x00MP",
00007     " MP",
00008     "MP3",
00009     "COM ",
00010     "TCP ", # iTunes
00011     "CM1 "  # Script kiddie
00012 ]

Definition at line 276 of file frames.py.

string frames.LATIN1_ENCODING = "\x00"

Definition at line 289 of file frames.py.

string frames.LYRICS_FID = "USLT"

Definition at line 47 of file frames.py.

tuple frames.LYRICS_FRAME_RX = re.compile("^" + LYRICS_FID + "$")

Definition at line 266 of file frames.py.

list frames.NULL_FRAME_FLAGS = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Definition at line 259 of file frames.py.

string frames.OBJECT_FID = "GEOB"

Definition at line 54 of file frames.py.

tuple frames.OBJECT_FRAME_RX = re.compile("^" + OBJECT_FID + "$")

Definition at line 269 of file frames.py.

string frames.OBSOLETE_DATE_FID = "TDAT"

Definition at line 82 of file frames.py.

Definition at line 85 of file frames.py.

Definition at line 86 of file frames.py.

string frames.OBSOLETE_TIME_FID = "TIME"

Definition at line 84 of file frames.py.

string frames.OBSOLETE_YEAR_FID = "TYER"

Definition at line 83 of file frames.py.

Initial value:
00001 {"EQUA": "Equalisation",
00002                   "IPLS": "Involved people list",
00003                   "RVAD": "Relative volume adjustment",
00004                   "TDAT": "Date",
00005                   "TORY": "Original release year",
00006                   "TRDA": "Recording dates",
00007                   "TYER": "Year"}

Definition at line 73 of file frames.py.

string frames.PLAYCOUNT_FID = "PCNT"

Definition at line 68 of file frames.py.

tuple frames.PLAYCOUNT_FRAME_RX = re.compile("^" + PLAYCOUNT_FID + "$")

Definition at line 270 of file frames.py.

string frames.PUBLISHER_FID = "TPUB"

Definition at line 71 of file frames.py.

string frames.REMIXER_FID = "TPE4"

Definition at line 37 of file frames.py.

string frames.SUBTITLE_FID = "TIT3"

Definition at line 43 of file frames.py.

Definition at line 189 of file frames.py.

tuple frames.TEXT_FRAME_RX = re.compile("^T[A-Z0-9][A-Z0-9][A-Z0-9]$")

Definition at line 261 of file frames.py.

Initial value:
00001 ["%Y",
00002                     "%Y-%m",
00003                     "%Y-%m-%d",
00004                     "%Y-%m-%dT%H",
00005                     "%Y-%m-%dT%H:%M",
00006                     "%Y-%m-%dT%H:%M:%S"]

Definition at line 27 of file frames.py.

string frames.TITLE_FID = "TIT2"

Definition at line 42 of file frames.py.

Definition at line 45 of file frames.py.

string frames.TRACKNUM_FID = "TRCK"

Definition at line 49 of file frames.py.

string frames.UNIQUE_FILE_ID_FID = "UFID"

Definition at line 69 of file frames.py.

tuple frames.UNIQUE_FILE_ID_FRAME_RX = re.compile("^" + UNIQUE_FILE_ID_FID + "$")

Definition at line 271 of file frames.py.

string frames.URL_ARTIST_FID = "WOAR"

Definition at line 58 of file frames.py.

string frames.URL_AUDIOFILE_FID = "WOAF"

Definition at line 57 of file frames.py.

string frames.URL_AUDIOSRC_FID = "WOAS"

Definition at line 59 of file frames.py.

string frames.URL_COMMERCIAL_FID = "WCOM"

Definition at line 55 of file frames.py.

string frames.URL_COPYRIGHT_FID = "WCOP"

Definition at line 56 of file frames.py.

Initial value:
00001 [URL_COMMERCIAL_FID, URL_COPYRIGHT_FID,
00002                       URL_AUDIOFILE_FID, URL_ARTIST_FID, URL_AUDIOSRC_FID,
00003                       URL_INET_RADIO_FID, URL_PAYMENT_FID,
00004                       URL_PUBLISHER_FID]

Definition at line 63 of file frames.py.

tuple frames.URL_FRAME_RX = re.compile("^W[A-Z0-9][A-Z0-9][A-Z0-9]$")

Definition at line 263 of file frames.py.

string frames.URL_INET_RADIO_FID = "WORS"

Definition at line 60 of file frames.py.

string frames.URL_PAYMENT_FID = "WPAY"

Definition at line 61 of file frames.py.

string frames.URL_PUBLISHER_FID = "WPUB"

Definition at line 62 of file frames.py.

string frames.USERTEXT_FID = "TXXX"

Definition at line 51 of file frames.py.

tuple frames.USERTEXT_FRAME_RX = re.compile("^" + USERTEXT_FID + "$")

Definition at line 262 of file frames.py.

string frames.USERURL_FID = "WXXX"

Definition at line 67 of file frames.py.

tuple frames.USERURL_FRAME_RX = re.compile("^" + USERURL_FID + "$")

Definition at line 264 of file frames.py.

string frames.UTF_16_ENCODING = "\x01"

Definition at line 290 of file frames.py.

string frames.UTF_16BE_ENCODING = "\x02"

Definition at line 291 of file frames.py.

string frames.UTF_8_ENCODING = "\x03"

Definition at line 292 of file frames.py.