Add musicbrainz support to scanner translator
This commit is contained in:
parent
5974d696f1
commit
988ff66c5e
@ -46,6 +46,15 @@ def translator(data):
|
||||
if albumartist_kwargs:
|
||||
album_kwargs['artists'] = [Artist(**albumartist_kwargs)]
|
||||
|
||||
if 'musicbrainz-trackid' in data:
|
||||
track_kwargs['musicbrainz_id'] = data['musicbrainz-trackid']
|
||||
|
||||
if 'musicbrainz-artistid' in data:
|
||||
artist_kwargs['musicbrainz_id'] = data['musicbrainz-artistid']
|
||||
|
||||
if 'musicbrainz-albumid' in data:
|
||||
album_kwargs['musicbrainz_id'] = data['musicbrainz-albumid']
|
||||
|
||||
track_kwargs['uri'] = data['uri']
|
||||
track_kwargs['length'] = data['duration']
|
||||
track_kwargs['album'] = Album(**album_kwargs)
|
||||
|
||||
@ -25,15 +25,20 @@ class TranslatorTest(unittest.TestCase):
|
||||
'date': FakeGstDate(2006, 1, 1,),
|
||||
'container-format': u'ID3 tag',
|
||||
'duration': 4531,
|
||||
'musicbrainz-trackid': 'mbtrackid',
|
||||
'musicbrainz-albumid': 'mbalbumid',
|
||||
'musicbrainz-artistid': 'mbartistid',
|
||||
}
|
||||
|
||||
self.album = {
|
||||
'name': 'albumname',
|
||||
'num_tracks': 2,
|
||||
'musicbrainz_id': 'mbalbumid',
|
||||
}
|
||||
|
||||
self.artist = {
|
||||
'name': 'name',
|
||||
'musicbrainz_id': 'mbartistid',
|
||||
}
|
||||
|
||||
self.albumartist = {
|
||||
@ -46,6 +51,7 @@ class TranslatorTest(unittest.TestCase):
|
||||
'date': date(2006, 1, 1),
|
||||
'track_no': 1,
|
||||
'length': 4531,
|
||||
'musicbrainz_id': 'mbtrackid',
|
||||
}
|
||||
|
||||
def build_track(self):
|
||||
@ -78,16 +84,31 @@ class TranslatorTest(unittest.TestCase):
|
||||
del self.track['name']
|
||||
self.check()
|
||||
|
||||
def test_missing_track_musicbrainz_id(self):
|
||||
del self.data['musicbrainz-trackid']
|
||||
del self.track['musicbrainz_id']
|
||||
self.check()
|
||||
|
||||
def test_missing_album_name(self):
|
||||
del self.data['album']
|
||||
del self.album['name']
|
||||
self.check()
|
||||
|
||||
def test_missing_album_musicbrainz_id(self):
|
||||
del self.data['musicbrainz-albumid']
|
||||
del self.album['musicbrainz_id']
|
||||
self.check()
|
||||
|
||||
def test_missing_artist_name(self):
|
||||
del self.data['artist']
|
||||
del self.artist['name']
|
||||
self.check()
|
||||
|
||||
def test_missing_artist_musicbrainz_id(self):
|
||||
del self.data['musicbrainz-artistid']
|
||||
del self.artist['musicbrainz_id']
|
||||
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