Пример #1
0
    def genres(self, album):
        """Return the current genres of an album if they exist and
        the force option is not set or get genres from whatlastgenre.
        """
        if album.genre and not self.config['force']:
            self._log.info('not forcing genre update for album {0}', album)
            return album.genre

        metadata = Metadata(
            path=album.item_dir().decode(),
            type='beet',
            artists=[(t.artist, t.mb_artistid) for t in album.items()],
            albumartist=(album.albumartist, album.mb_albumartistid),
            album=album.album,
            mbid_album=album.mb_albumid,
            mbid_relgrp=album.mb_releasegroupid,
            year=album.year,
            releasetype=album.albumtype)

        genres, _ = self.wlg.query_album(metadata)
        try:
            genres = self.config['separator'].get(str).join(genres)
            self._log.info('genres for album {0}: {1}', album, genres)
        except TypeError:
            self._log.info('No genres found for album {0}', album)

        return genres
 def test_create_queries_with_albumartist(self):
     metadata = Metadata(path='/tmp',
                         type='test',
                         albumartist=('AlbumArtist', None),
                         artists=[('Artist A', None), ('Artist B', None),
                                  ('Artist C', None), ('Artist D', None)],
                         album='Album',
                         mbid_album=None,
                         mbid_relgrp=None,
                         year=1987,
                         releasetype=None)
     queries = self.wlg.create_queries(metadata)
     self.assertEqual(len(queries), 2 * len(self.wlg.daprs))
 def test_query_album(self):
     metadata = Metadata(path='/tmp',
                         type='test',
                         artists=[('Artist A', None), ('Artist B', None),
                                  ('Artist C', None), ('Artist D', None)],
                         albumartist=('AlbumArtist', None),
                         album='Album',
                         mbid_album=None,
                         mbid_relgrp=None,
                         year=1987,
                         releasetype=None)
     genres, release = self.wlg.query_album(metadata)
     self.assertIsNotNone(genres)
     self.assertIsNone(release)
 def test_create_queries_without_albumartist(self):
     metadata = Metadata(path='/tmp',
                         type='test',
                         artists=[('Artist A', None), ('Artist B', None),
                                  ('Artist C', None), ('Artist D', None)],
                         albumartist=(None, None),
                         album='Album',
                         mbid_album=None,
                         mbid_relgrp=None,
                         year=1987,
                         releasetype=None)
     # vaqueries enabled
     self.wlg.conf.set('wlg', 'vaqueries', str(True))
     queries = self.wlg.create_queries(metadata)
     self.assertEqual(len(queries), 5 * len(self.wlg.daprs))
     # va queries disabled
     self.wlg.conf.set('wlg', 'vaqueries', str(False))
     queries = self.wlg.create_queries(metadata)
     self.assertEqual(len(queries), 1 * len(self.wlg.daprs))