Back to index

eyed3  0.6.18
Public Member Functions | Public Attributes | Static Public Attributes
tag.TagHeader Class Reference

List of all members.

Public Member Functions

def __init__
def clear
def setVersion
def parse
def render

Public Attributes

 unsync
 extended
 experimental
 tagSize

Static Public Attributes

int SIZE = 10
 version = None;
 majorVersion = None;
 minorVersion = None;
 revVersion = None;
int unsync = 0
int extended = 0
int experimental = 0
int footer = 0
int tagSize = 0

Detailed Description

Definition at line 36 of file tag.py.


Constructor & Destructor Documentation

def tag.TagHeader.__init__ (   self)

Definition at line 55 of file tag.py.

00055 
00056    def __init__(self):
00057       self.clear();

Here is the call graph for this function:


Member Function Documentation

def tag.TagHeader.clear (   self)

Definition at line 58 of file tag.py.

00058 
00059    def clear(self):
00060       self.setVersion(None);
00061       self.unsync = 0;
00062       self.extended = 0;
00063       self.experimental = 0;
00064       self.tagSize = 0;

Here is the call graph for this function:

Here is the caller graph for this function:

def tag.TagHeader.parse (   self,
  f 
)

Definition at line 101 of file tag.py.

00101 
00102    def parse(self, f):
00103       self.clear();
00104 
00105       # The first three bytes of a v2 header is "ID3".
00106       if f.read(3) != "ID3":
00107          return 0;
00108       TRACE_MSG("Located ID3 v2 tag");
00109 
00110       # The next 2 bytes are the minor and revision versions.
00111       version = f.read(2);
00112       major = 2;
00113       minor = ord(version[0]);
00114       rev = ord(version[1]);
00115       TRACE_MSG("TagHeader [major]: " + str(major));
00116       TRACE_MSG("TagHeader [minor]: " + str(minor));
00117       TRACE_MSG("TagHeader [revis]: " + str(rev));
00118       if not (major == 2 and (minor >= 2 and minor <= 4)):
00119          raise TagException("ID3 v" + str(major) + "." + str(minor) +\
00120                             " is not supported.");
00121       # Get all the version madness in sync.
00122       self.setVersion([major, minor, rev]);
00123 
00124       # The first 4 bits of the next byte are flags.
00125       (self.unsync,
00126        self.extended,
00127        self.experimental,
00128        self.footer) = bytes2bin(f.read(1))[0:4];
00129       TRACE_MSG("TagHeader [flags]: unsync(%d) extended(%d) "\
00130                 "experimental(%d) footer(%d)" % (self.unsync, self.extended,
00131                                                  self.experimental,
00132                                                  self.footer));
00133 
00134       # The size of the extended header (optional), frames, and padding
00135       # afer unsynchronization.  This is a sync safe integer, so only the
00136       # bottom 7 bits of each byte are used.
00137       tagSizeStr = f.read(4);
00138       TRACE_MSG("TagHeader [size string]: 0x%02x%02x%02x%02x" %\
00139                 (ord(tagSizeStr[0]), ord(tagSizeStr[1]),
00140                  ord(tagSizeStr[2]), ord(tagSizeStr[3])));
00141       self.tagSize = bin2dec(bytes2bin(tagSizeStr, 7));
00142       TRACE_MSG("TagHeader [size]: %d (0x%x)" % (self.tagSize, self.tagSize));
00143 
00144       return 1;

Here is the call graph for this function:

def tag.TagHeader.render (   self,
  tagLen = None 
)

Definition at line 145 of file tag.py.

00145 
00146    def render(self, tagLen = None):
00147       if tagLen != None:
00148          self.tagSize = tagLen;
00149 
00150       data = "ID3";
00151       data += chr(self.minorVersion) + chr(self.revVersion);
00152       # not not the values so we only get 1's and 0's.
00153       data += bin2bytes([not not self.unsync,
00154                          not not self.extended,
00155                          not not self.experimental,
00156                          not not self.footer,
00157                          0, 0, 0, 0]);
00158       TRACE_MSG("Setting tag size to %d" % tagLen);
00159       szBytes = bin2bytes(bin2synchsafe(dec2bin(tagLen, 32)));
00160       data += szBytes;
00161       TRACE_MSG("TagHeader rendered %d bytes" % len(data));
00162       return data;

Here is the call graph for this function:

def tag.TagHeader.setVersion (   self,
  v 
)

Definition at line 65 of file tag.py.

00065 
00066    def setVersion(self, v):
00067       if v == None:
00068          self.version = None;
00069          self.majorVersion = None;
00070          self.minorVersion = None;
00071          self.revVersion = None;
00072          return;
00073 
00074       if v == ID3_CURRENT_VERSION:
00075          if self.majorVersion == None or self.minorVersion == None:
00076             v = ID3_DEFAULT_VERSION;
00077          else:
00078             return;
00079       elif v == ID3_ANY_VERSION:
00080          v = ID3_DEFAULT_VERSION;
00081 
00082       # Handle 3-element lists or tuples.
00083       if isinstance(v, tuple) or isinstance(v, list):
00084          self.version = eyeD3.utils.versionsToConstant(v);
00085          (self.majorVersion,
00086           self.minorVersion,
00087           self.revVersion) = v;
00088       # Handle int constants.
00089       elif isinstance(v, int):
00090          (self.majorVersion,
00091           self.minorVersion,
00092           self.revVersion) = eyeD3.utils.constantToVersions(v);
00093          self.version = v;
00094       else:
00095          raise TypeError("Wrong type: %s" % str(type(v)));

Here is the caller graph for this function:


Member Data Documentation

int tag.TagHeader.experimental = 0 [static]

Definition at line 47 of file tag.py.

Definition at line 62 of file tag.py.

int tag.TagHeader.extended = 0 [static]

Definition at line 46 of file tag.py.

Definition at line 61 of file tag.py.

int tag.TagHeader.footer = 0 [static]

Definition at line 49 of file tag.py.

tag.TagHeader.majorVersion = None; [static]

Definition at line 40 of file tag.py.

tag.TagHeader.minorVersion = None; [static]

Definition at line 41 of file tag.py.

tag.TagHeader.revVersion = None; [static]

Definition at line 42 of file tag.py.

int tag.TagHeader.SIZE = 10 [static]

Definition at line 37 of file tag.py.

int tag.TagHeader.tagSize = 0 [static]

Definition at line 52 of file tag.py.

Definition at line 63 of file tag.py.

int tag.TagHeader.unsync = 0 [static]

Definition at line 45 of file tag.py.

Definition at line 60 of file tag.py.

tag.TagHeader.version = None; [static]

Definition at line 39 of file tag.py.


The documentation for this class was generated from the following file: