class NumericTextFrame(TextFrame): """Numerical text strings. The numeric value of these frames can be gotten with unary plus, e.g.:: frame = TLEN('12345') length = +frame """ _framespec = [ EncodingSpec('encoding'), MultiSpec('text', EncodedNumericTextSpec('text'), sep=u'\u0000'), ] def __pos__(self): """Return the numerical value of the string.""" return int(self.text[0])
class COMM(TextFrame): """User comment. User comment frames have a descrption, like TXXX, and also a three letter ISO language code in the 'lang' attribute. """ _framespec = [ EncodingSpec('encoding'), StringSpec('lang', 3), EncodedTextSpec('desc'), MultiSpec('text', EncodedTextSpec('text'), sep=u'\u0000'), ] @property def HashKey(self): return '%s:%s:%r' % (self.FrameID, self.desc, self.lang) def _pprint(self): return "%s=%r=%s" % (self.desc, self.lang, " / ".join(self.text))
class TXXX(TextFrame): """User-defined text data. TXXX frames have a 'desc' attribute which is set to any Unicode value (though the encoding of the text and the description must be the same). Many taggers use this frame to store freeform keys. """ _framespec = [ EncodingSpec('encoding'), EncodedTextSpec('desc'), MultiSpec('text', EncodedTextSpec('text'), sep=u'\u0000'), ] @property def HashKey(self): return '%s:%s' % (self.FrameID, self.desc) def _pprint(self): return "%s=%s" % (self.desc, " / ".join(self.text))
class TimeStampTextFrame(TextFrame): """A list of time stamps. The 'text' attribute in this frame is a list of ID3TimeStamp objects, not a list of strings. """ _framespec = [ EncodingSpec('encoding'), MultiSpec('text', TimeStampSpec('stamp'), sep=u','), ] def __bytes__(self): return text_type(self).encode('utf-8') def __str__(self): return u','.join([stamp.text for stamp in self.text]) def _pprint(self): return u" / ".join([stamp.text for stamp in self.text])
class OWNE(Frame): """Ownership frame.""" _framespec = [ EncodingSpec('encoding'), Latin1TextSpec('price'), StringSpec('date', 8), EncodedTextSpec('seller'), ] def __bytes__(self): return self.seller.encode('utf-8') def __str__(self): return self.seller def __eq__(self, other): return self.seller == other __hash__ = Frame.__hash__
class PairedTextFrame(Frame): """Paired text strings. Some ID3 frames pair text strings, to associate names with a more specific involvement in the song. The 'people' attribute of these frames contains a list of pairs:: [['trumpet', 'Miles Davis'], ['bass', 'Paul Chambers']] Like text frames, these frames also have an encoding attribute. """ _framespec = [ EncodingSpec('encoding'), MultiSpec('people', EncodedTextSpec('involvement'), EncodedTextSpec('person')) ] def __eq__(self, other): return self.people == other __hash__ = Frame.__hash__
class SYLT(Frame): """Synchronised lyrics/text.""" _framespec = [ EncodingSpec('encoding'), FixedWidthStringSpec('lang', 3), ByteSpec('format'), ByteSpec('type'), EncodedTextSpec('desc'), SynchronizedTextSpec('text'), ] @property def HashKey(self): return '%s:%s:%r' % (self.FrameID, self.desc, self.lang) def __eq__(self, other): return str(self) == other __hash__ = Frame.__hash__ def __str__(self): return "".join(text for (text, time) in self.text)
class COMR(FrameOpt): """Commercial frame.""" _framespec = [ EncodingSpec('encoding'), Latin1TextSpec('price'), StringSpec('valid_until', 8), Latin1TextSpec('contact'), ByteSpec('format'), EncodedTextSpec('seller'), EncodedTextSpec('desc'), ] _optionalspec = [Latin1TextSpec('mime'), BinaryDataSpec('logo')] @property def HashKey(self): return '%s:%s' % (self.FrameID, self._writeData()) def __eq__(self, other): return self._writeData() == other._writeData() __hash__ = FrameOpt.__hash__