diff --git a/beetsplug/beatport.py b/beetsplug/beatport.py index c3933ed731..be76b902f6 100644 --- a/beetsplug/beatport.py +++ b/beetsplug/beatport.py @@ -257,10 +257,10 @@ def __init__(self, data): self.url = "https://beatport.com/track/{0}/{1}" \ .format(data['slug'], data['id']) self.track_number = data.get('trackNumber') - if 'bpm' in data: - self.bpm = data['bpm'] - if 'key' in data: - self.musical_key = six.text_type(data['key'].get('shortName')) + self.bpm = data.get('bpm') + self.musical_key = six.text_type( + (data.get('key') or {}).get('shortName') + ) # Use 'subgenre' and if not present, 'genre' as a fallback. if data.get('subGenres'): diff --git a/docs/changelog.rst b/docs/changelog.rst index 261b745053..af9f29c1fe 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -73,6 +73,8 @@ New features: * :doc:`/plugins/beatport`: The plugin now gets the musical key, BPM and the genre for each track. :bug:`2080` +* :doc:`/plugins/beatport`: Fix default assignment of the musical key. + :bug:`3377` Fixes: