Fix bug where a null value for lengthMS would crash an import. Added a fallback to parse the standard min:sec length field.

This commit is contained in:
Timothy Appnel 2013-06-07 23:43:21 -04:00
parent 6baaa7e06e
commit 847edcd6cc

View file

@ -139,8 +139,10 @@ class BeatportTrack(BeatportObject):
self.title = unicode(data['title'])
if 'mixName' in data:
self.mix_name = unicode(data['mixName'])
if 'length' in data:
self.length = timedelta(milliseconds=data['lengthMs'])
self.length = timedelta(milliseconds=data.get('lengthMs',0) or 0)
if self.length == 0:
(min, sec) = data.get('length','0:0').split(':')
self.length = timedelta(minutes=min, seconds=sec)
if 'slug' in data:
self.url = "http://beatport.com/track/{0}/{1}".format(data['slug'],
data['id'])