diff --git a/nowplaying/musicbrainz.py b/nowplaying/musicbrainz.py index b9e2c03e..5c9c7a85 100755 --- a/nowplaying/musicbrainz.py +++ b/nowplaying/musicbrainz.py @@ -111,8 +111,11 @@ def _check_not_allow_others(): if not mbdata.get('recording-list'): return riddata + newlist = sorted(mbdata['recording-list'], + key=lambda d: d.get('first-release-date', '9999-99-99')) variousartistrid = None - for recording in mbdata['recording-list']: + #logging.debug(newlist) + for recording in newlist: rid = recording['id'] logging.debug('recording id = %s', rid) if not recording.get('release-list'): diff --git a/tests/test_musicbrainz.py b/tests/test_musicbrainz.py index 9562f070..75e5b799 100755 --- a/tests/test_musicbrainz.py +++ b/tests/test_musicbrainz.py @@ -94,7 +94,7 @@ def test_fallback_prince_compblue_purplerain(getmusicbrainz): # pylint: disable # metadata = {'artist': 'Prince', 'title': 'Computer Blue', 'album': 'Purple Rain'} newdata = mbhelper.lastditcheffort(metadata) - assert not newdata.get('musicbrainzartistid') + assert not newdata def test_fallback_princeandther_compblue_purplerain(getmusicbrainz): # pylint: disable=redefined-outer-name @@ -193,7 +193,8 @@ def test_fallback_queen(getmusicbrainz): # pylint: disable=redefined-outer-name metadata = {'artist': 'Queen', 'title': 'We Will Rock You'} newdata = mbhelper.lastditcheffort(metadata) assert newdata['musicbrainzartistid'] == ['0383dadf-2a4e-4d10-a46a-e9e041da8eb3'] - assert newdata['album'] == 'News of the World' + assert newdata['album'] in ['News of the World', + 'Crazy Little Thing Called Love'] # can pull album or a single def test_fallback_grimesfeatjanelle(getmusicbrainz): # pylint: disable=redefined-outer-name