Пример #1
0
    def test_create_file_from_template(self):
        self.ogsrelid = "3083"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        taggerutils = TaggerUtils(self.source_dir, self.target_dir, self.tagger_config, self.album)

        create_file = os.path.join(self.target_dir, "info.nfo")
        assert taggerutils.create_file_from_template("/info.txt", create_file)

        assert os.path.exists(create_file)

        assert taggerutils.create_nfo(self.target_dir)

        # copy file to source directory and rename it
        self.copy_files_single_album(17)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir, self.tagger_config, self.album)

        taggerutils._get_target_list()
        assert self.album.discs[0].tracks[0].new_file == "01-yonderboi-intro.flac"
        assert taggerutils.create_m3u(self.target_dir)
Пример #2
0
    def test_get_target_list_with_multiple_release_artists(self):
        """
            Some releases do have multiple release-artists (see 2452735),
            the release artists are treated differently from the track artists,
            check it in here, to make sure it is really working (should be in
            test_discogs.py usually)
        """
        self.ogsrelid = "2454735"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        taggerutils = TaggerUtils(self.source_dir, self.target_dir, self.tagger_config, self.album)

        taggerutils._get_target_list()

        assert len(self.album.artists) == 2
        assert self.album.artists[0] == "Frank Zappa"
        assert self.album.artists[1] == "Ensemble Modern"

        assert self.album.artist == "Frank Zappa"
        assert self.album.discs[0].tracks[0].new_file == "01-frank_zappa-intro"
Пример #3
0
    def test_get_target_list_single_disc(self):
        self.ogsrelid = "3083"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        # copy file to source directory and rename it
        self.copy_files_single_album(17)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir, self.tagger_config, self.album)

        taggerutils._get_target_list()

        assert self.album.sourcedir == self.source_dir
        assert self.album.discs[0].sourcedir == None

        assert self.album.target_dir == os.path.join(self.target_dir, "yonderboi-shallow_and_profound-(molecd023-2)-2000")
        assert self.album.discs[0].target_dir == None

        assert self.album.discs[0].tracks[0].orig_file == "01-song.flac"
        assert self.album.discs[0].tracks[0].new_file == "01-yonderboi-intro.flac"

        assert self.album.discs[0].tracks[16].orig_file == "17-song.flac"
        assert self.album.discs[0].tracks[16].new_file == "17-yonderboi-outro.flac"

        assert self.album.discs[0].copy_files[0] == "album.cue"
        assert self.album.discs[0].copy_files[1] == "album.m3u"
        assert self.album.discs[0].copy_files[2] == "id.txt"
Пример #4
0
    def test_get_target_list_single_disc_with_subtracks(self):
        """
            Some releases do have "subtracks" (see 513904, track 15), which means that there
            are two tracks assigned to one position (e.g. 15.1 and 15.2). This gets quite
            complicated, because this is rather similar to the multi-disc handling
        """
        self.ogsrelid = "513904"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        # copy file to source directory and rename it
        self.copy_files_single_album(14)

        target_file_name = "513904.json"
        shutil.copyfile(self.source_copy_file, os.path.join(self.source_dir, target_file_name))

        taggerutils = TaggerUtils(self.source_dir, self.target_dir, self.tagger_config, self.album)

        try:
            taggerutils._get_target_list()
        except TaggerError as te:
            assert True
            return

        assert False
Пример #5
0
    def test_create_file_from_template(self):
        self.ogsrelid = "3083"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir,
                                                  "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        taggerutils = TaggerUtils(self.source_dir, self.target_dir,
                                  self.tagger_config, self.album)

        create_file = os.path.join(self.target_dir, "info.nfo")
        assert taggerutils.create_file_from_template("/info.txt", create_file)

        assert os.path.exists(create_file)

        assert taggerutils.create_nfo(self.target_dir)

        # copy file to source directory and rename it
        self.copy_files_single_album(17)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir,
                                  self.tagger_config, self.album)

        taggerutils._get_target_list()
        assert self.album.discs[0].tracks[
            0].new_file == "01-yonderboi-intro.flac"
        assert taggerutils.create_m3u(self.target_dir)
Пример #6
0
    def test_get_target_list_with_multiple_release_artists(self):
        """
            Some releases do have multiple release-artists (see 2452735),
            the release artists are treated differently from the track artists,
            check it in here, to make sure it is really working (should be in
            test_discogs.py usually)
        """
        self.ogsrelid = "2454735"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir,
                                                  "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        taggerutils = TaggerUtils(self.source_dir, self.target_dir,
                                  self.tagger_config, self.album)

        taggerutils._get_target_list()

        assert len(self.album.artists) == 2
        assert self.album.artists[0] == "Frank Zappa"
        assert self.album.artists[1] == "Ensemble Modern"

        assert self.album.artist == "Frank Zappa"
        assert self.album.discs[0].tracks[0].new_file == "01-frank_zappa-intro"
Пример #7
0
    def test_get_target_list_single_disc_with_subtracks(self):
        """
            Some releases do have "subtracks" (see 513904, track 15), which means that there
            are two tracks assigned to one position (e.g. 15.1 and 15.2). This gets quite
            complicated, because this is rather similar to the multi-disc handling
        """
        self.ogsrelid = "513904"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir,
                                                  "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        # copy file to source directory and rename it
        self.copy_files_single_album(14)

        target_file_name = "513904.json"
        shutil.copyfile(self.source_copy_file,
                        os.path.join(self.source_dir, target_file_name))

        taggerutils = TaggerUtils(self.source_dir, self.target_dir,
                                  self.tagger_config, self.album)

        try:
            taggerutils._get_target_list()
        except TaggerError as te:
            assert True
            return

        assert False
Пример #8
0
    def setUp(self):
        self.ogsrelid = "1448190"

        # construct config with only default values
        self.tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()
Пример #9
0
    def setUp(self):
        self.ogsrelid = "1448190"

        # construct config with only default values
        self.tagger_config = TaggerConfig(
            os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()
Пример #10
0
    def test_tag_single_album_with_video_tracks(self):
        self.ogsrelid = "13748"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir,
                                                  "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        # copy file to source directory and rename it
        self.copy_files_single_album(7)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir,
                                  self.tagger_config, self.album)

        taggerutils._get_target_list()

        testTagHandler = TagHandler(self.album, self.tagger_config)
        testFileHandler = FileHandler(self.album, self.tagger_config)

        testFileHandler.copy_files()

        testTagHandler.tag_album()

        target_dir = os.path.join(self.target_dir, self.album.target_dir)
        metadata = MediaFile(
            os.path.join(target_dir,
                         "01-coldcut-timber_(chopped_down_radio_edit).flac"))

        assert metadata.artist == "Coldcut"
        assert metadata.albumartists == ["Coldcut", "Hexstatic"]
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 1998
        assert metadata.disctotal == 1
        assert metadata.genre == "Electronic"
        assert metadata.tracktotal == 7

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None

        assert metadata.country == "Canada"

        metadata = MediaFile(
            os.path.join(
                target_dir,
                "07-coldcut-timber_(the_cheech_wizards_polythump_requiem_for_the_ancient_forests_mix).flac"
            ))

        assert metadata.artist == "Coldcut"
        assert metadata.albumartists == ["Coldcut", "Hexstatic"]
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.tracktotal == 7
Пример #11
0
def test_map_singledisc():
    ogsrelid = "3083"

    # construct config with only default values
    tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

    dummy_response = TestDummyResponse(ogsrelid)
    dummy_discogs_album = DummyDiscogsAlbum(dummy_response)
    album = dummy_discogs_album.map()

    assert len(album.labels) == 2
    assert album.labels[0] == "Mole Listening Pearls"

    assert len(album.catnumbers) == len(album.labels)
    assert album.catnumbers[0] == "MOLECD023-2"

    assert len(album.images) == 4
    assert album.images[
        0] == "http://api.discogs.com/image/R-3083-1167766285.jpeg"

    assert album.title == "Shallow And Profound"

    assert len(album.artists) == 1
    assert album.artists[0] == "Yonderboi"

    assert len(album.genres) == 1

    assert len(album.styles) == 2

    assert not album.is_compilation

    assert album.disctotal == 1
    assert len(album.discs) == album.disctotal

    assert len(album.discs[0].tracks) == 17

    # first track on first disc
    track = album.discs[0].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 1
    assert track.title == "Intro"
    assert track.artists[0] == "Yonderboi"
    assert track.non_existent_tag == None

    # last track on first disc
    track = album.discs[0].tracks[16]

    assert track.tracknumber == 17
    assert track.discnumber == 1
    assert track.title == "Outro"
    assert track.artists[0] == "Yonderboi"
    assert track.non_existent_tag == None
Пример #12
0
def test_map_singledisc():
    ogsrelid = "3083"

    # construct config with only default values
    tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

    dummy_response = TestDummyResponse(ogsrelid)
    dummy_discogs_album = DummyDiscogsAlbum(dummy_response)
    album = dummy_discogs_album.map()

    assert len(album.labels) == 2
    assert album.labels[0] == "Mole Listening Pearls"

    assert len(album.catnumbers) == len(album.labels)
    assert album.catnumbers[0] == "MOLECD023-2"

    assert len(album.images) == 4
    assert album.images[0] == "http://api.discogs.com/image/R-3083-1167766285.jpeg"

    assert album.title == "Shallow And Profound"

    assert len(album.artists) == 1
    assert album.artists[0] == "Yonderboi"

    assert len(album.genres) == 1

    assert len(album.styles) == 2

    assert not album.is_compilation

    assert album.disctotal == 1
    assert len(album.discs) == album.disctotal

    assert len(album.discs[0].tracks) == 17

# first track on first disc
    track = album.discs[0].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 1
    assert track.title == "Intro"
    assert track.artists[0] == "Yonderboi"
    assert track.non_existent_tag == None

# last track on first disc
    track = album.discs[0].tracks[16]

    assert track.tracknumber == 17
    assert track.discnumber == 1
    assert track.title == "Outro"
    assert track.artists[0] == "Yonderboi"
    assert track.non_existent_tag == None
Пример #13
0
    def test_tag_single_album_with_video_tracks(self):
        self.ogsrelid = "13748"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        # copy file to source directory and rename it
        self.copy_files_single_album(7)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir, self.tagger_config, self.album)

        taggerutils._get_target_list()

        testTagHandler = TagHandler(self.album, self.tagger_config)
        testFileHandler = FileHandler(self.album, self.tagger_config)

        testFileHandler.copy_files()

        testTagHandler.tag_album()

        target_dir = os.path.join(self.target_dir, self.album.target_dir)
        metadata = MediaFile(os.path.join(target_dir, "01-coldcut-timber_(chopped_down_radio_edit).flac"))

        assert metadata.artist == "Coldcut"
        assert metadata.albumartists == ["Coldcut", "Hexstatic"]
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 1998
        assert metadata.disctotal == 1
        assert metadata.genre == "Electronic"
        assert metadata.tracktotal == 7

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None

        assert metadata.country == "Canada"

        metadata = MediaFile(os.path.join(target_dir, "07-coldcut-timber_(the_cheech_wizards_polythump_requiem_for_the_ancient_forests_mix).flac"))

        assert metadata.artist == "Coldcut"
        assert metadata.albumartists == ["Coldcut", "Hexstatic"]
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.tracktotal == 7
Пример #14
0
    def test_tag_album_wo_country(self):
        self.ogsrelid = "543030"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir,
                                                  "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        # copy file to source directory and rename it
        self.copy_files_single_album(11)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir,
                                  self.tagger_config, self.album)

        taggerutils._get_target_list()

        testTagHandler = TagHandler(self.album, self.tagger_config)
        testFileHandler = FileHandler(self.album, self.tagger_config)

        testFileHandler.copy_files()

        testTagHandler.tag_album()

        target_dir = os.path.join(self.target_dir, self.album.target_dir)
        metadata = MediaFile(
            os.path.join(target_dir, "01-front_242-masterhit.flac"))

        assert metadata.artist == "Front 242"
        assert metadata.albumartist == "Front 242"
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 1992
        assert metadata.disctotal == 1
        assert metadata.genre == "Electronic"

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None

        assert metadata.country == ""
Пример #15
0
    def test_tag_album_wo_country(self):
        self.ogsrelid = "543030"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        # copy file to source directory and rename it
        self.copy_files_single_album(11)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir, self.tagger_config, self.album)

        taggerutils._get_target_list()

        testTagHandler = TagHandler(self.album, self.tagger_config)
        testFileHandler = FileHandler(self.album, self.tagger_config)

        testFileHandler.copy_files()

        testTagHandler.tag_album()

        target_dir = os.path.join(self.target_dir, self.album.target_dir)
        metadata = MediaFile(os.path.join(target_dir, "01-front_242-masterhit.flac"))

        assert metadata.artist == "Front 242"
        assert metadata.albumartist == "Front 242"
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 1992
        assert metadata.disctotal == 1
        assert metadata.genre == "Electronic"

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None

        assert metadata.country == ""
Пример #16
0
    def test_get_target_list_single_disc(self):
        self.ogsrelid = "3083"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir,
                                                  "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        # copy file to source directory and rename it
        self.copy_files_single_album(17)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir,
                                  self.tagger_config, self.album)

        taggerutils._get_target_list()

        assert self.album.sourcedir == self.source_dir
        assert self.album.discs[0].sourcedir == None

        assert self.album.target_dir == os.path.join(
            self.target_dir,
            "yonderboi-shallow_and_profound-(molecd023-2)-2000")
        assert self.album.discs[0].target_dir == None

        assert self.album.discs[0].tracks[0].orig_file == "01-song.flac"
        assert self.album.discs[0].tracks[
            0].new_file == "01-yonderboi-intro.flac"

        assert self.album.discs[0].tracks[16].orig_file == "17-song.flac"
        assert self.album.discs[0].tracks[
            16].new_file == "17-yonderboi-outro.flac"

        assert self.album.discs[0].copy_files[0] == "album.cue"
        assert self.album.discs[0].copy_files[1] == "album.m3u"
        assert self.album.discs[0].copy_files[2] == "id.txt"
Пример #17
0
    def test_year(self):
        """test the year property of the DiscogsAlbum
        """
        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)

        discogs_album.release.data["year"] = "2000"
        assert discogs_album.year == "2000"

        discogs_album.release.data["year"] = "xxxx"
        assert discogs_album.year == "1900"

        discogs_album.release.data["year"] = None
        assert discogs_album.year == "1900"

        discogs_album.release.data["year"] = 2000
        assert discogs_album.year == "2000"

        discogs_album.release.data["year"] = 20
        assert discogs_album.year == "1900"
Пример #18
0
def test_map_multidisc_with_disctitle():
    ogsrelid = "288308"

    # construct config with only default values
    tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

    dummy_response = TestDummyResponse(ogsrelid)
    dummy_discogs_album = DummyDiscogsAlbum(dummy_response)
    album = dummy_discogs_album.map()

    assert len(album.labels) == 1
    assert album.labels[0] == "Epic"

    assert len(album.catnumbers) == len(album.labels)
    assert album.catnumbers[0] == "E2K 69635"

    assert len(album.images) == 4
    assert album.images[
        0] == "http://api.discogs.com/image/R-288308-1333554422.jpeg"

    assert album.title == "Ladies & Gentlemen - The Best Of George Michael"

    assert len(album.artists) == 1
    logger.debug("album.artists %s" % album.artists[0])
    assert album.artists[0] == "George Michael"

    assert len(album.genres) == 2
    assert album.genres[0] == "Electronic"
    assert album.genres[1] == "Pop"

    assert len(album.styles) == 2
    assert album.styles[0] == "Downtempo"
    assert album.styles[1] == "Synth-pop"

    # in discogs it is a compilation
    assert album.is_compilation

    assert album.disctotal == 2
    assert len(album.discs) == album.disctotal

    assert len(album.discs[0].tracks) == 14
    assert len(album.discs[1].tracks) == 14

    # first track on first disc
    track = album.discs[0].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 1
    assert track.discsubtitle == "For The Heart"
    assert track.title == "Jesus To A Child"
    assert track.artists[0] == "George Michael"
    assert track.non_existent_tag == None

    # last track on first disc
    track = album.discs[0].tracks[13]

    assert track.tracknumber == 14
    assert track.discnumber == 1
    assert track.discsubtitle == "For The Heart"
    assert track.title == "A Different Corner"
    assert track.artists[0] == "George Michael"
    assert track.non_existent_tag == None

    # first track on second disc
    track = album.discs[1].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 2
    assert track.title == "Outside"
    assert track.discsubtitle == "For The Feet"
    assert track.artists[0] == "George Michael"
    assert track.non_existent_tag == None
    logger.debug("1discsubtitle: %s " % track.discsubtitle)

    # last track on first disc
    track = album.discs[1].tracks[13]

    logger.debug("2discsubtitle: %s " % track.discsubtitle)

    assert track.tracknumber == 14
    assert track.discnumber == 2
    assert track.title == "Somebody To Love"
    assert track.discsubtitle == "For The Feet"
    assert track.artists[0] == "George Michael With Queen"
    assert track.non_existent_tag == None
Пример #19
0
def test_map_multidisc_with_disctitle_for_tracks():
    ogsrelid = "282923"

    # construct config with only default values
    tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

    dummy_response = TestDummyResponse(ogsrelid)
    dummy_discogs_album = DummyDiscogsAlbum(dummy_response)
    album = dummy_discogs_album.map()

    assert len(album.labels) == 1
    assert album.labels[0] == "Columbia"

    assert len(album.catnumbers) == len(album.labels)
    assert album.catnumbers[0] == "COL 513783 2"

    assert album.title == "Live In Concert 2002"

    assert len(album.artists) == 1
    logger.debug("album.artists %s" % album.artists[0])
    assert album.artists[0] == "Deine Lakaien"

    assert len(album.genres) == 1
    assert album.genres[0] == "Electronic"

    assert len(album.styles) == 1
    assert album.styles[0] == "Synth-pop"

    assert not album.is_compilation

    assert album.disctotal == 2
    assert len(album.discs) == album.disctotal

    assert len(album.discs[0].tracks) == 9
    assert len(album.discs[1].tracks) == 13

    # first track on first disc
    track = album.discs[0].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 1
    assert not track.discsubtitle
    assert track.title == "Colour-Ize"
    assert track.artists[0] == "Deine Lakaien"
    assert track.non_existent_tag == None

    # first track on second disc
    track = album.discs[1].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 2
    assert track.title == "Silence In Your Eyes"
    assert track.discsubtitle == None
    assert track.artists[0] == "Deine Lakaien"
    assert track.non_existent_tag == None

    # last track without disctitle on second disc
    track = album.discs[1].tracks[10]

    assert track.tracknumber == 11
    assert track.discnumber == 2
    assert track.title == "Sometimes"
    assert track.discsubtitle == None
    assert track.artists[0] == "Deine Lakaien"
    assert track.non_existent_tag == None

    # first track with disctitle on second disc
    track = album.discs[1].tracks[11]

    assert track.tracknumber == 12
    assert track.discnumber == 2
    assert track.title == "Stupid"
    assert track.discsubtitle == "Bonustracks"
    assert track.artists[0] == "Deine Lakaien"
    assert track.non_existent_tag == None
Пример #20
0
    def test_tag_album_with_specific_track_artists(self):
        self.ogsrelid = "112146"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir,
                                                  "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        self.copy_files(self.album)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir,
                                  self.tagger_config, self.album)

        taggerutils._get_target_list()

        testTagHandler = TagHandler(self.album, self.tagger_config)
        testFileHandler = FileHandler(self.album, self.tagger_config)

        testFileHandler.copy_files()

        testTagHandler.tag_album()

        target_dir = os.path.join(self.target_dir, self.album.target_dir,
                                  self.album.disc(1).target_dir)
        metadata = MediaFile(
            os.path.join(
                target_dir,
                "01-artful_dodger-re-rewind_the_crowd_say_bo_selecta_(radio_edit).flac"
            ))

        assert metadata.artist == "Artful Dodger"
        assert metadata.albumartist == "Artful Dodger"
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 2000
        assert metadata.disctotal == 2
        assert metadata.genre == "Electronic"

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None

        metadata = MediaFile(
            os.path.join(
                target_dir,
                "04-artful_dodger_feat_romina_johnson-movin_too_fast_(artful_dodger_original_mix).flac"
            ))

        assert metadata.artist == "Artful Dodger Feat. Romina Johnson"
        assert metadata.albumartist == "Artful Dodger"
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 2000
        assert metadata.disctotal == 2
        assert metadata.track == 4
        assert metadata.genre == "Electronic"

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None

        target_dir = os.path.join(self.target_dir, self.album.target_dir,
                                  self.album.disc(2).target_dir)
        metadata = MediaFile(
            os.path.join(target_dir,
                         "20-paul_johnson-get_get_down_(illicit_remix).flac"))

        assert metadata.artist == "Paul Johnson"
        assert metadata.albumartist == "Artful Dodger"
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 2000
        assert metadata.disctotal == 2
        assert metadata.disc == 2
        assert metadata.track == 20
        assert metadata.genre == "Electronic"

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None
Пример #21
0
def test_map_multidisc():
    ogsrelid = "1448190"

    # construct config with only default values
    tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

    dummy_response = TestDummyResponse(ogsrelid)
    dummy_discogs_album = DummyDiscogsAlbum(dummy_response)
    album = dummy_discogs_album.map()

    assert len(album.labels) == 1
    assert album.labels[0] == "Polystar"

    assert len(album.catnumbers) == len(album.labels)
    assert album.catnumbers[0] == "560 938-2"

    assert len(album.images) == 4
    assert album.images[
        0] == "http://api.discogs.com/image/R-1448190-1220476110.jpeg"

    assert album.title == "Megahits 2001 Die Erste"

    assert len(album.artists) == 1
    assert album.artists[0] == "Various"

    assert len(album.genres) == 4

    assert len(album.styles) == 4

    assert album.is_compilation

    assert album.disctotal == 2
    assert len(album.discs) == album.disctotal

    assert len(album.discs[0].tracks) == 20
    assert len(album.discs[1].tracks) == 20

    # first track on first disc
    track = album.discs[0].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 1
    assert track.title == "La Passion (Radio Cut)"
    assert track.artists[0] == "Gigi D'Agostino"
    assert track.non_existent_tag == None

    # last track on first disc
    track = album.discs[0].tracks[19]

    assert track.tracknumber == 20
    assert track.discnumber == 1
    assert track.title == "Last Resort (Album Version Explizit)"
    assert track.artists[0] == "Papa Roach"
    assert track.non_existent_tag == None

    # first track on second disc
    track = album.discs[1].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 2
    assert track.title == "Ich Will, Dass Du Mich Liebst (Radio Edit)"
    assert track.artists[0] == "Die 3. Generation"
    assert track.non_existent_tag == None

    # last track on first disc
    track = album.discs[1].tracks[19]

    assert track.tracknumber == 20
    assert track.discnumber == 2
    assert track.title == "I Just Wanna Love U (Give It 2 Me) (Radio Edit)"
    assert track.artists[0] == "Jay-Z"
    assert track.non_existent_tag == None

    # special character handling
    track = album.discs[1].tracks[18]

    logger.debug("track.artists: %s" % track.artists[0])
    assert track.artists[0] == "D-Flame Feat. Eißfeldt"
Пример #22
0
def test_map_multidisc_with_disctitle():
    ogsrelid = "288308"

    # construct config with only default values
    tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

    dummy_response = TestDummyResponse(ogsrelid)
    dummy_discogs_album = DummyDiscogsAlbum(dummy_response)
    album = dummy_discogs_album.map()

    assert len(album.labels) == 1
    assert album.labels[0] == "Epic"

    assert len(album.catnumbers) == len(album.labels)
    assert album.catnumbers[0] == "E2K 69635"

    assert len(album.images) == 4
    assert album.images[0] == "http://api.discogs.com/image/R-288308-1333554422.jpeg"

    assert album.title == "Ladies & Gentlemen - The Best Of George Michael"

    assert len(album.artists) == 1
    logger.debug("album.artists %s" % album.artists[0])
    assert album.artists[0] == "George Michael"

    assert len(album.genres) == 2
    assert album.genres[0] == "Electronic"
    assert album.genres[1] == "Pop"

    assert len(album.styles) == 2
    assert album.styles[0] == "Downtempo"
    assert album.styles[1] == "Synth-pop"

# in discogs it is a compilation
    assert album.is_compilation

    assert album.disctotal == 2
    assert len(album.discs) == album.disctotal

    assert len(album.discs[0].tracks) == 14
    assert len(album.discs[1].tracks) == 14

# first track on first disc
    track = album.discs[0].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 1
    assert track.discsubtitle == "For The Heart"
    assert track.title == "Jesus To A Child"
    assert track.artists[0] == "George Michael"
    assert track.non_existent_tag == None

# last track on first disc
    track = album.discs[0].tracks[13]

    assert track.tracknumber == 14
    assert track.discnumber == 1
    assert track.discsubtitle == "For The Heart"
    assert track.title == "A Different Corner"
    assert track.artists[0] == "George Michael"
    assert track.non_existent_tag == None

# first track on second disc
    track = album.discs[1].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 2
    assert track.title == "Outside"
    assert track.discsubtitle == "For The Feet"
    assert track.artists[0] == "George Michael"
    assert track.non_existent_tag == None
    logger.debug("1discsubtitle: %s " % track.discsubtitle)

# last track on first disc
    track = album.discs[1].tracks[13]

    logger.debug("2discsubtitle: %s " % track.discsubtitle)

    assert track.tracknumber == 14
    assert track.discnumber == 2
    assert track.title == "Somebody To Love"
    assert track.discsubtitle == "For The Feet"
    assert track.artists[0] == "George Michael With Queen"
    assert track.non_existent_tag == None
Пример #23
0
    def test_tag_album_with_specific_track_artists(self):
        self.ogsrelid = "112146"

        # construct config with only default values
        tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

        dummy_response = TestDummyResponse(self.ogsrelid)
        discogs_album = DummyDiscogsAlbum(dummy_response)
        self.album = discogs_album.map()

        self.copy_files(self.album)

        taggerutils = TaggerUtils(self.source_dir, self.target_dir, self.tagger_config, self.album)

        taggerutils._get_target_list()

        testTagHandler = TagHandler(self.album, self.tagger_config)
        testFileHandler = FileHandler(self.album, self.tagger_config)

        testFileHandler.copy_files()

        testTagHandler.tag_album()

        target_dir = os.path.join(self.target_dir, self.album.target_dir, self.album.disc(1).target_dir)
        metadata = MediaFile(os.path.join(target_dir, "01-artful_dodger-re-rewind_the_crowd_say_bo_selecta_(radio_edit).flac"))

        assert metadata.artist == "Artful Dodger"
        assert metadata.albumartist == "Artful Dodger"
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 2000
        assert metadata.disctotal == 2
        assert metadata.genre == "Electronic"

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None

        metadata = MediaFile(os.path.join(target_dir, "04-artful_dodger_feat_romina_johnson-movin_too_fast_(artful_dodger_original_mix).flac"))

        assert metadata.artist == "Artful Dodger Feat. Romina Johnson"
        assert metadata.albumartist == "Artful Dodger"
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 2000
        assert metadata.disctotal == 2
        assert metadata.track == 4
        assert metadata.genre == "Electronic"

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None

        target_dir = os.path.join(self.target_dir, self.album.target_dir, self.album.disc(2).target_dir)
        metadata = MediaFile(os.path.join(target_dir, "20-paul_johnson-get_get_down_(illicit_remix).flac"))

        assert metadata.artist == "Paul Johnson"
        assert metadata.albumartist == "Artful Dodger"
        assert metadata.discogs_id == self.ogsrelid
        assert metadata.year == 2000
        assert metadata.disctotal == 2
        assert metadata.disc == 2
        assert metadata.track == 20
        assert metadata.genre == "Electronic"

        # obviously the encoder element is not in the file, but it is returned
        # empty anyway, no need to check this then...
        assert metadata.encoder == None
Пример #24
0
def test_map_multidisc_with_disctitle_for_tracks():
    ogsrelid = "282923"

    # construct config with only default values
    tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

    dummy_response = TestDummyResponse(ogsrelid)
    dummy_discogs_album = DummyDiscogsAlbum(dummy_response)
    album = dummy_discogs_album.map()

    assert len(album.labels) == 1
    assert album.labels[0] == "Columbia"

    assert len(album.catnumbers) == len(album.labels)
    assert album.catnumbers[0] == "COL 513783 2"

    assert album.title == "Live In Concert 2002"

    assert len(album.artists) == 1
    logger.debug("album.artists %s" % album.artists[0])
    assert album.artists[0] == "Deine Lakaien"

    assert len(album.genres) == 1
    assert album.genres[0] == "Electronic"

    assert len(album.styles) == 1
    assert album.styles[0] == "Synth-pop"

    assert not album.is_compilation

    assert album.disctotal == 2
    assert len(album.discs) == album.disctotal

    assert len(album.discs[0].tracks) == 9
    assert len(album.discs[1].tracks) == 13

# first track on first disc
    track = album.discs[0].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 1
    assert not track.discsubtitle
    assert track.title == "Colour-Ize"
    assert track.artists[0] == "Deine Lakaien"
    assert track.non_existent_tag == None

# first track on second disc
    track = album.discs[1].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 2
    assert track.title == "Silence In Your Eyes"
    assert track.discsubtitle == None
    assert track.artists[0] == "Deine Lakaien"
    assert track.non_existent_tag == None

# last track without disctitle on second disc
    track = album.discs[1].tracks[10]

    assert track.tracknumber == 11
    assert track.discnumber == 2
    assert track.title == "Sometimes"
    assert track.discsubtitle == None
    assert track.artists[0] == "Deine Lakaien"
    assert track.non_existent_tag == None

# first track with disctitle on second disc
    track = album.discs[1].tracks[11]

    assert track.tracknumber == 12
    assert track.discnumber == 2
    assert track.title == "Stupid"
    assert track.discsubtitle == "Bonustracks"
    assert track.artists[0] == "Deine Lakaien"
    assert track.non_existent_tag == None
Пример #25
0
def test_map_multidisc():
    ogsrelid = "1448190"

    # construct config with only default values
    tagger_config = TaggerConfig(os.path.join(parentdir, "test/empty.conf"))

    dummy_response = TestDummyResponse(ogsrelid)
    dummy_discogs_album = DummyDiscogsAlbum(dummy_response)
    album = dummy_discogs_album.map()

    assert len(album.labels) == 1
    assert album.labels[0] == "Polystar"

    assert len(album.catnumbers) == len(album.labels)
    assert album.catnumbers[0] == "560 938-2"

    assert len(album.images) == 4
    assert album.images[0] == "http://api.discogs.com/image/R-1448190-1220476110.jpeg"

    assert album.title == "Megahits 2001 Die Erste"

    assert len(album.artists) == 1
    assert album.artists[0] == "Various"

    assert len(album.genres) == 4

    assert len(album.styles) == 4

    assert album.is_compilation

    assert album.disctotal == 2
    assert len(album.discs) == album.disctotal

    assert len(album.discs[0].tracks) == 20
    assert len(album.discs[1].tracks) == 20

# first track on first disc
    track = album.discs[0].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 1
    assert track.title == "La Passion (Radio Cut)"
    assert track.artists[0] == "Gigi D'Agostino"
    assert track.non_existent_tag == None

# last track on first disc
    track = album.discs[0].tracks[19]

    assert track.tracknumber == 20
    assert track.discnumber == 1
    assert track.title == "Last Resort (Album Version Explizit)"
    assert track.artists[0] == "Papa Roach"
    assert track.non_existent_tag == None

# first track on second disc
    track = album.discs[1].tracks[0]

    assert track.tracknumber == 1
    assert track.discnumber == 2
    assert track.title == "Ich Will, Dass Du Mich Liebst (Radio Edit)"
    assert track.artists[0] == "Die 3. Generation"
    assert track.non_existent_tag == None

# last track on first disc
    track = album.discs[1].tracks[19]

    assert track.tracknumber == 20
    assert track.discnumber == 2
    assert track.title == "I Just Wanna Love U (Give It 2 Me) (Radio Edit)"
    assert track.artists[0] == "Jay-Z"
    assert track.non_existent_tag == None

# special character handling
    track = album.discs[1].tracks[18]

    logger.debug("track.artists: %s" % track.artists[0])
    assert track.artists[0] == "D-Flame Feat. Eißfeldt"