Ejemplo n.º 1
0
class USLT(Frame):
    """Unsynchronised lyrics/text transcription.

    Lyrics have a three letter ISO language code ('lang'), a
    description ('desc'), and a block of plain text ('text').
    """

    _framespec = [
        EncodingSpec('encoding'),
        StringSpec('lang', 3),
        EncodedTextSpec('desc'),
        EncodedTextSpec('text'),
    ]

    @property
    def HashKey(self):
        return '%s:%s:%r' % (self.FrameID, self.desc, self.lang)

    def __str__(self):
        return self.text.encode('utf-8')

    def __unicode__(self):
        return self.text

    def __eq__(self, other):
        return self.text == other

    __hash__ = Frame.__hash__
Ejemplo n.º 2
0
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__
Ejemplo n.º 3
0
class USER(Frame):
    """Terms of use.

    Attributes:

    * encoding -- text encoding
    * lang -- ISO three letter language code
    * text -- licensing terms for the audio
    """

    _framespec = [
        EncodingSpec('encoding'),
        StringSpec('lang', 3),
        EncodedTextSpec('text'),
    ]

    @property
    def HashKey(self):
        return '%s:%r' % (self.FrameID, self.lang)

    def __str__(self):
        return self.text.encode('utf-8')

    def __unicode__(self):
        return self.text

    def __eq__(self, other):
        return self.text == other

    __hash__ = Frame.__hash__

    def _pprint(self):
        return "%r=%s" % (self.lang, self.text)
Ejemplo n.º 4
0
class LINK(FrameOpt):
    """Linked information.

    Attributes:

    * frameid -- the ID of the linked frame
    * url -- the location of the linked frame
    * data -- further ID information for the frame
    """

    _framespec = [
        StringSpec('frameid', 4),
        Latin1TextSpec('url'),
    ]

    _optionalspec = [BinaryDataSpec('data')]

    @property
    def HashKey(self):
        try:
            return "%s:%s:%s:%r" % (
                self.FrameID, self.frameid, self.url, self.data)
        except AttributeError:
            return "%s:%s:%s" % (self.FrameID, self.frameid, self.url)

    def __eq__(self, other):
        try:
            return (self.frameid, self.url, self.data) == other
        except AttributeError:
            return (self.frameid, self.url) == other

    __hash__ = FrameOpt.__hash__
Ejemplo n.º 5
0
class SYLT(Frame):
    """Synchronised lyrics/text."""

    _framespec = [
        EncodingSpec('encoding'),
        StringSpec('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 u"".join(text for (text, time) in self.text)
        
    def __bytes__(self):
        return text_type(self).encode("utf-8")
Ejemplo n.º 6
0
class PIC(APIC):
    """Attached Picture.

    The 'mime' attribute of an ID3v2.2 attached picture must be either
    'PNG' or 'JPG'.
    """
    _framespec = [EncodingSpec('encoding'), StringSpec('mime', 3),
                  ByteSpec('type'), EncodedTextSpec('desc'),
                  BinaryDataSpec('data')]
Ejemplo n.º 7
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))
Ejemplo n.º 8
0
class OWNE(Frame):
    """Ownership frame."""

    _framespec = [
        EncodingSpec('encoding'),
        Latin1TextSpec('price'),
        StringSpec('date', 8),
        EncodedTextSpec('seller'),
    ]

    def __str__(self):
        return self.seller.encode('utf-8')

    def __unicode__(self):
        return self.seller

    def __eq__(self, other):
        return self.seller == other

    __hash__ = Frame.__hash__
Ejemplo n.º 9
0
class LNK(LINK):
    """Linked information"""
    _framespec = [StringSpec('frameid', 3), Latin1TextSpec('url')]
    _optionalspec = [BinaryDataSpec('data')]