Fix scan with multiple track artists and add tests
This commit is contained in:
parent
e608f9f213
commit
03750a8bf2
@ -144,6 +144,12 @@ def audio_data_to_track(data):
|
||||
track_kwargs['last_modified'] = int(data['mtime'])
|
||||
track_kwargs['length'] = data[gst.TAG_DURATION] // gst.MSECOND
|
||||
track_kwargs['album'] = Album(**album_kwargs)
|
||||
track_kwargs['artists'] = [Artist(**artist_kwargs)]
|
||||
|
||||
if ('name' in artist_kwargs and
|
||||
type(artist_kwargs['name']) is list):
|
||||
track_kwargs['artists'] = [Artist(**{'name': artist})
|
||||
for artist in artist_kwargs['name']]
|
||||
else:
|
||||
track_kwargs['artists'] = [Artist(**artist_kwargs)]
|
||||
|
||||
return Track(**track_kwargs)
|
||||
|
||||
@ -46,11 +46,18 @@ class TranslatorTest(unittest.TestCase):
|
||||
'musicbrainz_id': 'mbalbumid',
|
||||
}
|
||||
|
||||
self.artist = {
|
||||
self.artist_single = {
|
||||
'name': 'name',
|
||||
'musicbrainz_id': 'mbartistid',
|
||||
}
|
||||
|
||||
self.artist_multiple = {
|
||||
'name': ['name1', 'name2'],
|
||||
'musicbrainz_id': 'mbartistid',
|
||||
}
|
||||
|
||||
self.artist = self.artist_single
|
||||
|
||||
self.albumartist = {
|
||||
'name': 'albumartistname',
|
||||
'musicbrainz_id': 'mbalbumartistid',
|
||||
@ -71,7 +78,14 @@ class TranslatorTest(unittest.TestCase):
|
||||
if self.albumartist:
|
||||
self.album['artists'] = [Artist(**self.albumartist)]
|
||||
self.track['album'] = Album(**self.album)
|
||||
self.track['artists'] = [Artist(**self.artist)]
|
||||
|
||||
if ('name' in self.artist and
|
||||
type(self.artist['name']) is list):
|
||||
self.track['artists'] = [Artist(**{'name': artist})
|
||||
for artist in self.artist['name']]
|
||||
else:
|
||||
self.track['artists'] = [Artist(**self.artist)]
|
||||
|
||||
return Track(**self.track)
|
||||
|
||||
def check(self):
|
||||
@ -122,6 +136,12 @@ class TranslatorTest(unittest.TestCase):
|
||||
del self.artist['musicbrainz_id']
|
||||
self.check()
|
||||
|
||||
def test_multiple_track_artists(self):
|
||||
self.data['artist'] = ['name1', 'name2']
|
||||
self.data['musicbrainz-artistid'] = 'mbartistid'
|
||||
self.artist = self.artist_multiple
|
||||
self.check()
|
||||
|
||||
def test_missing_album_artist(self):
|
||||
del self.data['album-artist']
|
||||
del self.albumartist['name']
|
||||
|
||||
Loading…
Reference in New Issue
Block a user