Beispiel #1
0
    def gen_tag(self, track, fake_art=False):
        tag = Tag()

        if track.has_key('album'):
            tag.album = track['album']
        if track.has_key('artist'):
            tag.artist = track['artist']
        if track.has_key('title'):
            tag.title = track['title']
        if track.has_key('discNumber'):
            tag.disc_num = int(track['discNumber'])
        if track.has_key('trackNumber'):
            tag.track_num = int(track['trackNumber'])
        if track.has_key('genre'):
            tag.genre = track['genre']
        if track.has_key('albumArtist') and track['albumArtist'] != track['artist']:
            tag.album_artist = track['albumArtist']
        if track.has_key('year') and int(track['year']) != 0:
            tag.recording_date = track['year']
        if track.has_key('albumArtRef'):
            art = None
            if self.__art is None:
                if fake_art:
                    art = '\0' * self.__art_size
                else:
                    if self.load_art():
                        art = self.__art
                    else:
                        art = None
            else:
                art = self.__art
            if art is not None:
                tag.images.set(0x03, art, 'image/jpeg', u'Front cover')
        return tag
Beispiel #2
0
    def gen_tag(self, track, fake_art=False):
        tag = Tag()

        if track.has_key('album'):
            tag.album = track['album']
        if track.has_key('artist'):
            tag.artist = track['artist']
        if track.has_key('title'):
            tag.title = track['title']
        if track.has_key('discNumber'):
            tag.disc_num = int(track['discNumber'])
        if track.has_key('trackNumber'):
            tag.track_num = int(track['trackNumber'])
        if track.has_key('genre'):
            tag.genre = track['genre']
        if track.has_key(
                'albumArtist') and track['albumArtist'] != track['artist']:
            tag.album_artist = track['albumArtist']
        if track.has_key('year') and int(track['year']) != 0:
            tag.recording_date = track['year']
        if track.has_key('albumArtRef'):
            art = None
            if self.__art is None:
                if fake_art:
                    art = '\0' * self.__art_size
                else:
                    if self.load_art():
                        art = self.__art
                    else:
                        art = None
            else:
                art = self.__art
            if art is not None:
                tag.images.set(0x03, art, 'image/jpeg', u'Front cover')
        return tag
Beispiel #3
0
def testTagMainProps():
    tag = Tag()

    # No version yet
    assert tag.version == ID3_DEFAULT_VERSION
    assert not (tag.isV1())
    assert tag.isV2()

    assert tag.artist is None
    tag.artist = u"Autolux"
    assert tag.artist == u"Autolux"
    assert len(tag.frame_set) == 1

    tag.artist = u""
    assert len(tag.frame_set) == 0
    tag.artist = u"Autolux"

    assert tag.album is None
    tag.album = u"Future Perfect"
    assert tag.album == u"Future Perfect"

    assert tag.album_artist is None
    tag.album_artist = u"Various Artists"
    assert (tag.album_artist == u"Various Artists")

    assert (tag.title is None)
    tag.title = u"Robots in the Garden"
    assert (tag.title == u"Robots in the Garden")

    assert (tag.track_num == (None, None))
    tag.track_num = 7
    assert (tag.track_num == (7, None))
    tag.track_num = (7, None)
    assert (tag.track_num == (7, None))
    tag.track_num = (7, 15)
    assert (tag.frame_set[frames.TRACKNUM_FID][0].text == "07/15")
    assert (tag.track_num == (7, 15))
    tag.track_num = (7, 150)
    assert (tag.frame_set[frames.TRACKNUM_FID][0].text == "007/150")
    assert (tag.track_num == (7, 150))
    tag.track_num = (1, 7)
    assert (tag.frame_set[frames.TRACKNUM_FID][0].text == "01/07")
    assert (tag.track_num == (1, 7))
    tag.track_num = None
    assert (tag.track_num == (None, None))
    tag.track_num = None, None
Beispiel #4
0
def testTagMainProps():
    tag = Tag()

    # No version yet
    assert_equal(tag.version, ID3_DEFAULT_VERSION)
    assert_false(tag.isV1())
    assert_true(tag.isV2())

    assert_equal(tag.artist, None)
    tag.artist = u"Autolux"
    assert_equal(tag.artist, u"Autolux")
    assert_equal(len(tag.frame_set), 1)

    tag.artist = u""
    assert_equal(len(tag.frame_set), 0)
    tag.artist = u"Autolux"

    assert_equal(tag.album, None)
    tag.album = u"Future Perfect"
    assert_equal(tag.album, u"Future Perfect")

    assert_equal(tag.album_artist, None)
    tag.album_artist = u"Various Artists"
    assert_equal(tag.album_artist, u"Various Artists")

    assert_equal(tag.title, None)
    tag.title = u"Robots in the Garden"
    assert_equal(tag.title, u"Robots in the Garden")

    assert_equal(tag.track_num, (None, None))
    tag.track_num = 7
    assert_equal(tag.track_num, (7, None))
    tag.track_num = (7, None)
    assert_equal(tag.track_num, (7, None))
    tag.track_num = (7, 15)
    assert_equal(tag.frame_set[frames.TRACKNUM_FID][0].text, "07/15")
    assert_equal(tag.track_num, (7, 15))
    tag.track_num = (7, 150)
    assert_equal(tag.frame_set[frames.TRACKNUM_FID][0].text, "007/150")
    assert_equal(tag.track_num, (7, 150))
    tag.track_num = (1, 7)
    assert_equal(tag.frame_set[frames.TRACKNUM_FID][0].text, "01/07")
    assert_equal(tag.track_num, (1, 7))
    tag.track_num = None
    assert_equal(tag.track_num, (None, None))
    tag.track_num = None, None
Beispiel #5
0
def testTagMainProps():
    tag = Tag()

    # No version yet
    assert tag.version == ID3_DEFAULT_VERSION
    assert not(tag.isV1())
    assert tag.isV2()

    assert tag.artist is None
    tag.artist = "Autolux"
    assert tag.artist == "Autolux"
    assert len(tag.frame_set) == 1

    tag.artist = ""
    assert len(tag.frame_set) == 0
    tag.artist = "Autolux"

    assert tag.album is None
    tag.album = "Future Perfect"
    assert tag.album == "Future Perfect"

    assert tag.album_artist is None
    tag.album_artist = "Various Artists"
    assert (tag.album_artist == "Various Artists")

    assert (tag.title is None)
    tag.title = "Robots in the Garden"
    assert (tag.title == "Robots in the Garden")

    assert (tag.track_num == (None, None))
    tag.track_num = 7
    assert (tag.track_num == (7, None))
    tag.track_num = (7, None)
    assert (tag.track_num == (7, None))
    tag.track_num = (7, 15)
    assert (tag.frame_set[frames.TRACKNUM_FID][0].text == "07/15")
    assert (tag.track_num == (7, 15))
    tag.track_num = (7, 150)
    assert (tag.frame_set[frames.TRACKNUM_FID][0].text == "007/150")
    assert (tag.track_num == (7, 150))
    tag.track_num = (1, 7)
    assert (tag.frame_set[frames.TRACKNUM_FID][0].text == "01/07")
    assert (tag.track_num == (1, 7))
    tag.track_num = None
    assert (tag.track_num == (None, None))
    tag.track_num = None, None