Test for presence and non-emptiness in one go.

This commit is contained in:
temrix 2019-09-21 21:14:11 +02:00
parent 9a4175dcd0
commit dfb6fc3f5b
No known key found for this signature in database
GPG key ID: 1DAF66EBB61678D2

View file

@ -263,9 +263,9 @@ class BeatportTrack(BeatportObject):
self.musical_key = six.text_type(data['key'].get('shortName'))
# Use 'subgenre' and if not present, 'genre' as a fallback.
if 'subGenres' in data and data['subGenres']:
if data.get('subGenres'):
self.genre = six.text_type(data['subGenres'][0].get('name'))
elif 'genres' in data and data['genres']:
elif data.get('genres'):
self.genre = six.text_type(data['genres'][0].get('name'))