Back to index

eyed3  0.6.18
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
frames.DateFrame Class Reference
Inheritance diagram for frames.DateFrame:
Inheritance graph
[legend]
Collaboration diagram for frames.DateFrame:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def setDate
def getDate
def getYear
def getMonth
def getDay
def getHour
def getMinute
def getSecond
def render
def __unicode__
def __str__
def unsync
def deunsync
def decompress
def compress
def decrypt
def encrypt
def disassembleFrame
def assembleFrame
def getFrameDesc
def getTextDelim

Public Attributes

 date_str
 text
 description
 encoding
 header
 decompressedSize
 groupId
 encryptionMethod
 dataLen
 unsync_default

Static Public Attributes

 date = None;
string date_str = u""

Private Member Functions

def _set
def __padDateField

Detailed Description

Definition at line 760 of file frames.py.


Constructor & Destructor Documentation

def frames.DateFrame.__init__ (   self,
  frameHeader,
  data = None,
  date_str = None,
  encoding = DEFAULT_ENCODING,
  unsync_default = False 
)

Reimplemented from frames.TextFrame.

Definition at line 765 of file frames.py.

00765 
00766                 encoding=DEFAULT_ENCODING, unsync_default=False):
00767       if data != None:
00768           TextFrame.__init__(self, frameHeader, data=data,
00769                              encoding=encoding, unsync_default=unsync_default)
00770           self._set(data, frameHeader)
00771       else:
00772           assert(date_str and isinstance(date_str, unicode))
00773           TextFrame.__init__(self, frameHeader, text=date_str,
00774                              encoding=encoding, unsync_default=unsync_default)
00775       self.setDate(self.text)

Here is the call graph for this function:


Member Function Documentation

def frames.DateFrame.__padDateField (   self,
  f,
  sz 
) [private]

Definition at line 851 of file frames.py.

00851 
00852    def __padDateField(self, f, sz):
00853       fStr = str(f);
00854       if len(fStr) == sz:
00855          pass;
00856       elif len(fStr) < sz:
00857          fStr = ("0" * (sz - len(fStr))) + fStr;
00858       else:
00859          raise TagException("Invalid date field: " + fStr);
00860       return fStr;

Here is the caller graph for this function:

def frames.Frame.__str__ (   self) [inherited]

Reimplemented in frames.URLFrame.

Definition at line 586 of file frames.py.

00586 
00587    def __str__(self):
00588       desc = self.getFrameDesc();
00589       return '<%s Frame (%s)>' % (desc, self.header.id);

Here is the call graph for this function:

def frames.TextFrame.__unicode__ (   self) [inherited]

Reimplemented in frames.UserTextFrame.

Definition at line 747 of file frames.py.

00747 
00748    def __unicode__(self):
00749       return u'<%s (%s): %s>' % (self.getFrameDesc(), self.header.id,
00750                                  self.text);

Here is the call graph for this function:

def frames.DateFrame._set (   self,
  data,
  frameHeader 
) [private]

Reimplemented from frames.TextFrame.

Definition at line 776 of file frames.py.

00776 
00777    def _set(self, data, frameHeader):
00778       TextFrame._set(self, data, frameHeader)
00779       if self.header.id[:2] != "TD" and self.header.minorVersion >= 4:
00780          raise FrameException("Invalid frame id for DateFrame: " + \
00781                               self.header.id)

Here is the caller graph for this function:

def frames.Frame.assembleFrame (   self,
  data 
) [inherited]

Definition at line 659 of file frames.py.

00659 
00660    def assembleFrame (self, data):
00661       formatFlagData = "";
00662       if self.header.minorVersion == 3:
00663          if self.header.compressed:
00664             formatFlagData += bin2bytes(dec2bin(len(data), 32));
00665          if self.header.encrypted:
00666             formatFlagData += bin2bytes(dec2bin(self.encryptionMethod, 8));
00667          if self.header.grouped:
00668             formatFlagData += bin2bytes(dec2bin(self.groupId, 8));
00669       else:
00670          if self.header.grouped:
00671             formatFlagData += bin2bytes(dec2bin(self.groupId, 8));
00672          if self.header.encrypted:
00673             formatFlagData += bin2bytes(dec2bin(self.encryptionMethod, 8));
00674          if self.header.compressed or self.header.dataLenIndicator:
00675             # Just in case, not sure about this?
00676             self.header.dataLenIndicator = 1;
00677             formatFlagData += bin2bytes(dec2bin(len(data), 32));
00678 
00679       if self.header.compressed:
00680           data = self.compress(data);
00681       if self.header.encrypted:
00682           data = self.encrypt(data);
00683       if self.header.unsync or self.unsync_default:
00684           data = self.unsync(data)
00685 
00686       data = formatFlagData + data;
00687       return self.header.render(len(data)) + data;

Here is the call graph for this function:

Here is the caller graph for this function:

def frames.Frame.compress (   self,
  data 
) [inherited]

Definition at line 604 of file frames.py.

00604 
00605    def compress(self, data):
00606       TRACE_MSG("before compression: %d bytes" % len(data));
00607       data = zlib.compress(data);
00608       TRACE_MSG("after compression: %d bytes" % len(data));
00609       return data;

Here is the call graph for this function:

Here is the caller graph for this function:

def frames.Frame.decompress (   self,
  data 
) [inherited]

Definition at line 598 of file frames.py.

00598 
00599    def decompress(self, data):
00600       TRACE_MSG("before decompression: %d bytes" % len(data));
00601       data = zlib.decompress(data, 15, self.decompressedSize);
00602       TRACE_MSG("after decompression: %d bytes" % len(data));
00603       return data;

Here is the call graph for this function:

Here is the caller graph for this function:

def frames.Frame.decrypt (   self,
  data 
) [inherited]

Definition at line 610 of file frames.py.

00610 
00611    def decrypt(self, data):
00612       raise FrameException("Encryption not supported");

Here is the caller graph for this function:

def frames.Frame.deunsync (   self,
  data 
) [inherited]

Definition at line 594 of file frames.py.

00594 
00595    def deunsync(self, data):
00596        data = deunsyncData(data)
00597        return data

Here is the call graph for this function:

Here is the caller graph for this function:

def frames.Frame.disassembleFrame (   self,
  data 
) [inherited]

Definition at line 616 of file frames.py.

00616 
00617    def disassembleFrame(self, data):
00618       # Format flags in the frame header may add extra data to the
00619       # beginning of this data.
00620       if self.header.minorVersion <= 3:
00621          # 2.3:  compression(4), encryption(1), group(1) 
00622          if self.header.compressed:
00623             self.decompressedSize = bin2dec(bytes2bin(data[:4]));
00624             data = data[4:];
00625             TRACE_MSG("Decompressed Size: %d" % self.decompressedSize);
00626          if self.header.encrypted:
00627             self.encryptionMethod = bin2dec(bytes2bin(data[0]));
00628             data = data[1:];
00629             TRACE_MSG("Encryption Method: %d" % self.encryptionMethod);
00630          if self.header.grouped:
00631             self.groupId = bin2dec(bytes2bin(data[0]));
00632             data = data[1:];
00633             TRACE_MSG("Group ID: %d" % self.groupId);
00634       else:
00635          # 2.4:  group(1), encrypted(1), dataLenIndicator(4,7)
00636          if self.header.grouped:
00637             self.groupId = bin2dec(bytes2bin(data[0]));
00638             data = data[1:];
00639          if self.header.encrypted:
00640             self.encryptionMethod = bin2dec(bytes2bin(data[0]));
00641             data = data[1:];
00642             TRACE_MSG("Encryption Method: %d" % self.encryptionMethod);
00643             TRACE_MSG("Group ID: %d" % self.groupId);
00644          if self.header.dataLenIndicator:
00645             self.dataLen = bin2dec(bytes2bin(data[:4], 7));
00646             data = data[4:];
00647             TRACE_MSG("Data Length: %d" % self.dataLen);
00648             if self.header.compressed:
00649                self.decompressedSize = self.dataLen;
00650                TRACE_MSG("Decompressed Size: %d" % self.decompressedSize);
00651 
00652       if self.header.unsync or self.unsync_default:
00653          data = self.deunsync(data)
00654       if self.header.encrypted:
00655          data = self.decrypt(data);
00656       if self.header.compressed:
00657          data = self.decompress(data);
00658       return data;

Here is the call graph for this function:

Here is the caller graph for this function:

def frames.Frame.encrypt (   self,
  data 
) [inherited]

Definition at line 613 of file frames.py.

00613 
00614    def encrypt(self, data):
00615       raise FrameException("Encryption not supported");

Here is the caller graph for this function:

def frames.DateFrame.getDate (   self)

Definition at line 812 of file frames.py.

00812 
00813    def getDate(self):
00814       return self.date_str

Here is the caller graph for this function:

def frames.DateFrame.getDay (   self)

Definition at line 827 of file frames.py.

00827 
00828    def getDay(self):
00829       if self.date:
00830          return self.__padDateField(self.date[2], 2);
00831       else:
00832          return None;

Here is the call graph for this function:

def frames.Frame.getFrameDesc (   self) [inherited]

Definition at line 688 of file frames.py.

00688 
00689    def getFrameDesc(self):
00690       try:
00691          return frameDesc[self.header.id];
00692       except KeyError:
00693          try:
00694             return obsoleteFrames[self.header.id];
00695          except KeyError:
00696             return "UNKOWN FRAME";

Here is the caller graph for this function:

def frames.DateFrame.getHour (   self)

Definition at line 833 of file frames.py.

00833 
00834    def getHour(self):
00835       if self.date:
00836          return self.__padDateField(self.date[3], 2);
00837       else:
00838          return None;

Here is the call graph for this function:

Definition at line 839 of file frames.py.

00839 
00840    def getMinute(self):
00841       if self.date:
00842          return self.__padDateField(self.date[4], 2);
00843       else:
00844          return None;

Here is the call graph for this function:

def frames.DateFrame.getMonth (   self)

Definition at line 821 of file frames.py.

00821 
00822    def getMonth(self):
00823       if self.date:
00824          return self.__padDateField(self.date[1], 2);
00825       else:
00826          return None;

Here is the call graph for this function:

Definition at line 845 of file frames.py.

00845 
00846    def getSecond(self):
00847       if self.date:
00848          return self.__padDateField(self.date[5], 2);
00849       else:
00850          return None;

Here is the call graph for this function:

def frames.Frame.getTextDelim (   self) [inherited]

Definition at line 697 of file frames.py.

00697 
00698    def getTextDelim(self):
00699        if self.encoding == UTF_16_ENCODING or \
00700           self.encoding == UTF_16BE_ENCODING:
00701            return "\x00\x00";
00702        else:
00703            return "\x00";

Here is the caller graph for this function:

def frames.DateFrame.getYear (   self)

Definition at line 815 of file frames.py.

00815 
00816    def getYear(self):
00817       if self.date:
00818          return self.__padDateField(self.date[0], 4)
00819       else:
00820          return None

Here is the call graph for this function:

Here is the caller graph for this function:

def frames.DateFrame.render (   self)

Reimplemented from frames.TextFrame.

Definition at line 861 of file frames.py.

00861 
00862    def render(self):
00863        # Conversion crap
00864        if self.header.minorVersion == 4 and\
00865           (self.header.id == OBSOLETE_DATE_FID or\
00866            self.header.id == OBSOLETE_YEAR_FID or\
00867            self.header.id == OBSOLETE_TIME_FID or\
00868            self.header.id == OBSOLETE_RECORDING_DATE_FID):
00869            self.header.id = "TDRC";
00870        elif self.header.minorVersion == 4 and\
00871             self.header.id == OBSOLETE_ORIG_RELEASE_FID:
00872            self.header.id = "TDOR";
00873        elif self.header.minorVersion == 3 and self.header.id == "TDOR":
00874            self.header.id = OBSOLETE_ORIG_RELEASE_FID;
00875        elif self.header.minorVersion == 3 and self.header.id == "TDEN":
00876            TRACE_MSG('Converting TDEN to TXXX(Encoding time) frame')
00877            self.header.id = "TXXX";
00878            self.description = "Encoding time";
00879            data = self.encoding +\
00880                   self.description.encode(id3EncodingToString(self.encoding)) +\
00881                   self.getTextDelim() +\
00882                   self.date_str.encode(id3EncodingToString(self.encoding));
00883            return self.assembleFrame(data)
00884 
00885        elif self.header.minorVersion == 3 and self.header.id[:2] == "TD":
00886            if self.header.id not in ['TDEN', 'TDLY', 'TDTG']:
00887               self.header.id = OBSOLETE_YEAR_FID;
00888 
00889        data = self.encoding +\
00890               self.date_str.encode(id3EncodingToString(self.encoding));
00891        data = self.assembleFrame(data);
00892        return data;
00893 

Here is the call graph for this function:

def frames.DateFrame.setDate (   self,
  d 
)

Definition at line 782 of file frames.py.

00782 
00783    def setDate(self, d):
00784       if not d:
00785          self.date = None
00786          self.date_str = u""
00787          return
00788 
00789       for fmt in timeStampFormats:
00790          try:
00791             if isinstance(d, tuple):
00792                self.date_str = unicode(time.strftime(fmt, d))
00793                self.date = d
00794             else:
00795                assert(isinstance(d, unicode))
00796                # Witnessed oddball tags with NULL bytes (ozzy.tag from id3lib)
00797                d = d.strip("\x00")
00798 
00799                try:
00800                   self.date = time.strptime(d, fmt)
00801                except TypeError, ex:
00802                   continue
00803                self.date_str = d
00804             break
00805          except ValueError:
00806             self.date = None
00807             self.date_str = u""
00808             continue
00809       if strictID3() and not self.date:
00810          raise FrameException("Invalid Date: " + str(d))
00811       self.text = self.date_str

Here is the caller graph for this function:

def frames.Frame.unsync (   self,
  data 
) [inherited]

Definition at line 590 of file frames.py.

00590 
00591    def unsync(self, data):
00592        data = unsyncData(data)
00593        return data

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

frames.Frame.dataLen [inherited]

Definition at line 581 of file frames.py.

frames.DateFrame.date = None; [static]

Definition at line 761 of file frames.py.

string frames.DateFrame.date_str = u"" [static]

Definition at line 762 of file frames.py.

Definition at line 785 of file frames.py.

Definition at line 578 of file frames.py.

Definition at line 877 of file frames.py.

Reimplemented from frames.Frame.

Reimplemented in frames.UserTextFrame.

Definition at line 718 of file frames.py.

Definition at line 580 of file frames.py.

frames.Frame.groupId [inherited]

Definition at line 579 of file frames.py.

frames.Frame.header [inherited]

Definition at line 577 of file frames.py.

Reimplemented from frames.TextFrame.

Definition at line 810 of file frames.py.

Definition at line 584 of file frames.py.


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