Ejemplo n.º 1
0
    def test_update_album_images(self):
        album = Album('00000000-0000-0000-0000-000000000000')
        track1 = Track('00000000-0000-0000-0000-000000000001')
        track1.linked_files.append(self.test_files[0])
        track2 = Track('00000000-0000-0000-0000-000000000002')
        track2.linked_files.append(self.test_files[1])
        album.tracks = [track1, track2]
        album.unmatched_files.files.append(self.test_files[2])
        update_metadata_images(album)
        self.assertEqual(set(self.test_images), set(album.orig_metadata.images))
        self.assertFalse(album.orig_metadata.has_common_images)

        album.tracks.remove(track2)
        update_metadata_images(album)
        self.assertEqual(set(self.test_images), set(album.orig_metadata.images))
        self.assertFalse(album.orig_metadata.has_common_images)

        # album.unmatched_files.files.remove(self.test_files[2])
        album.tracks.remove(track1)
        update_metadata_images(album)
        self.assertEqual(set(self.test_images[1:]), set(album.orig_metadata.images))
        self.assertTrue(album.orig_metadata.has_common_images)

        album.tracks.append(track2)
        update_metadata_images(album)
        self.assertEqual(set(self.test_images[1:]), set(album.orig_metadata.images))
        self.assertTrue(album.orig_metadata.has_common_images)
Ejemplo n.º 2
0
    def test_update_album_images(self):
        album = Album('00000000-0000-0000-0000-000000000000')
        track1 = Track('00000000-0000-0000-0000-000000000001')
        track1.linked_files.append(self.test_files[0])
        track2 = Track('00000000-0000-0000-0000-000000000002')
        track2.linked_files.append(self.test_files[1])
        album.tracks = [track1, track2]
        album.unmatched_files.files.append(self.test_files[2])
        update_metadata_images(album)
        self.assertEqual(set(self.test_images), set(album.orig_metadata.images))
        self.assertFalse(album.orig_metadata.has_common_images)

        album.tracks.remove(track2)
        update_metadata_images(album)
        self.assertEqual(set(self.test_images), set(album.orig_metadata.images))
        self.assertFalse(album.orig_metadata.has_common_images)

        # album.unmatched_files.files.remove(self.test_files[2])
        album.tracks.remove(track1)
        update_metadata_images(album)
        self.assertEqual(set(self.test_images[1:]), set(album.orig_metadata.images))
        self.assertTrue(album.orig_metadata.has_common_images)

        album.tracks.append(track2)
        update_metadata_images(album)
        self.assertEqual(set(self.test_images[1:]), set(album.orig_metadata.images))
        self.assertTrue(album.orig_metadata.has_common_images)
Ejemplo n.º 3
0
 def load_album(self, id, discid=None):
     id = self.mbid_redirects.get(id, id)
     album = self.albums.get(id)
     if album:
         return album
     album = Album(id, discid=discid)
     self.albums[id] = album
     self.album_added.emit(album)
     album.load()
     return album
Ejemplo n.º 4
0
 def load_album(self, id, discid=None):
     id = self.mbid_redirects.get(id, id)
     album = self.albums.get(id)
     if album:
         return album
     album = Album(id, discid=discid)
     self.albums[id] = album
     self.album_added.emit(album)
     album.load()
     return album
Ejemplo n.º 5
0
 def load_album(self, id, discid=None):
     id = self.mbid_redirects.get(id, id)
     album = self.albums.get(id)
     if album:
         log.debug("Album %s already loaded.", id)
         return album
     album = Album(id, discid=discid)
     self.albums[id] = album
     self.album_added.emit(album)
     album.load()
     return album
Ejemplo n.º 6
0
 def load_album(self, album_id, discid=None):
     album_id = self.mbid_redirects.get(album_id, album_id)
     album = self.albums.get(album_id)
     if album:
         log.debug("Album %s already loaded.", album_id)
         return album
     album = Album(album_id, discid=discid)
     self.albums[album_id] = album
     self.album_added.emit(album)
     album.load()
     return album
Ejemplo n.º 7
0
 def load_album(self, id, discid=None):
     if id in self.albumids:
         id = self.albumids[id]
     album = self.get_album_by_id(id)
     if album:
         return album
     album = Album(id, discid=discid)
     self.albums.append(album)
     self.emit(QtCore.SIGNAL("album_added"), album)
     album.load()
     return album
Ejemplo n.º 8
0
 def test_release(self):
     m = Metadata()
     a = Album("1")
     release_to_metadata(self.json_doc, m, a)
     self.assertEqual(m['album'], 'The Dark Side of the Moon')
     self.assertEqual(m['albumartist'], 'Pink Floyd')
     self.assertEqual(m['albumartistsort'], 'Pink Floyd')
     self.assertEqual(m['asin'], 'b123')
     self.assertEqual(m['barcode'], '123')
     self.assertEqual(m['catalognumber'], 'SHVL 804')
     self.assertEqual(m['date'], '1973-03-24')
     self.assertEqual(m['label'], 'Harvest')
     self.assertEqual(m['musicbrainz_albumartistid'], '83d91898-7763-47d7-b03b-b92132375c47')
     self.assertEqual(m['musicbrainz_albumid'], 'b84ee12a-09ef-421b-82de-0441a926375b')
     self.assertEqual(m['releasecountry'], 'GB')
     self.assertEqual(m['releasestatus'], 'official')
     self.assertEqual(m['script'], 'Latn')
     self.assertEqual(m['~albumartists'], 'Pink Floyd')
     self.assertEqual(m['~albumartists_sort'], 'Pink Floyd')
     self.assertEqual(m['~releaselanguage'], 'eng')
     self.assertEqual(m.getall('~releasecountries'), ['GB', 'NZ'])
     self.assertEqual(a.genres, {
         'genre1': 6, 'genre2': 3,
         'tag1': 6, 'tag2': 3})
     for artist in a._album_artists:
         self.assertEqual(artist.genres, {
             'british': 2,
             'progressive rock': 10})
Ejemplo n.º 9
0
 def test_remove_from_empty_album(self):
     album = Album('00000000-0000-0000-0000-000000000000')
     album.unmatched_files.files.append(File('test1.flac'))
     update_metadata_images(album)
     remove_metadata_images(album, [album.unmatched_files.files[0]])
     self.assertEqual(set(), set(album.metadata.images))
     self.assertEqual(set(), set(album.orig_metadata.images))
     self.assertTrue(album.metadata.has_common_images)
     self.assertTrue(album.orig_metadata.has_common_images)
Ejemplo n.º 10
0
 def test_remove_from_album_with_common_images(self):
     album = Album('00000000-0000-0000-0000-000000000000')
     album.unmatched_files.files = list(self.test_files[1:])
     update_metadata_images(album)
     album.unmatched_files.files.remove(self.test_files[1])
     remove_metadata_images(album, [self.test_files[1]])
     self.assertEqual(set(self.test_images[1:]), set(album.metadata.images))
     self.assertEqual(set(self.test_images[1:]), set(album.orig_metadata.images))
     self.assertTrue(album.metadata.has_common_images)
     self.assertTrue(album.orig_metadata.has_common_images)
Ejemplo n.º 11
0
 def test_preferred_release_country(self):
     m = Metadata()
     a = Album("1")
     release_to_metadata(self.json_doc, m, a)
     self.assertEqual(m['releasecountry'], 'GB')
     config.setting['preferred_release_countries'] = ['NZ', 'GB']
     release_to_metadata(self.json_doc, m, a)
     self.assertEqual(m['releasecountry'], 'NZ')
     config.setting['preferred_release_countries'] = ['GB', 'NZ']
     release_to_metadata(self.json_doc, m, a)
     self.assertEqual(m['releasecountry'], 'GB')
Ejemplo n.º 12
0
 def test_release(self):
     m = Metadata()
     a = Album("1")
     release_to_metadata(self.json_doc, m, a)
     self.assertEqual(m['album'], 'The Dark Side of the Moon')
     self.assertEqual(m['albumartist'], 'Pink Floyd')
     self.assertEqual(m['albumartistsort'], 'Pink Floyd')
     self.assertEqual(m['asin'], 'b123')
     self.assertEqual(m['barcode'], '123')
     self.assertEqual(m['catalognumber'], 'SHVL 804')
     self.assertEqual(m['date'], '1973-03-24')
     self.assertEqual(m['label'], 'Harvest')
     self.assertEqual(m['musicbrainz_albumartistid'], '83d91898-7763-47d7-b03b-b92132375c47')
     self.assertEqual(m['musicbrainz_albumid'], 'b84ee12a-09ef-421b-82de-0441a926375b')
     self.assertEqual(m['releasecountry'], 'GB')
     self.assertEqual(m['releasestatus'], 'official')
     self.assertEqual(m['script'], 'Latn')
     self.assertEqual(m['~albumartists'], 'Pink Floyd')
     self.assertEqual(m['~albumartists_sort'], 'Pink Floyd')
     self.assertEqual(m['~releaselanguage'], 'eng')
     self.assertEqual(a.folksonomy_tags, {'test2': 3, 'test': 6})
Ejemplo n.º 13
0
def _earliest_release_downloaded(album, metadata, original_id, document, http,
                                 error):
    try:
        if error:
            album.log.error("%r", unicode(http.errorString()))
        else:
            try:
                release_node = document.metadata[0].release[0]
                original_album = Album(original_id)
                release_to_metadata(release_node,
                                    original_album.metadata,
                                    config=album.config,
                                    album=original_album)
                get_earliest_release_date(original_album, metadata)
                for track in album._new_tracks:
                    track.metadata["originaldate"] = metadata["originaldate"]
            except:
                error = True
                album.log.error(traceback.format_exc())
    finally:
        album._requests -= 1
        album._finalize_loading(None)
Ejemplo n.º 14
0
 def test_release(self):
     m = Metadata()
     a = Album("1")
     release_to_metadata(self.json_doc, m, a)
     self.assertEqual(m, {})