From 847edcd6ccf4897facd0fa87eedb552409d9e40f Mon Sep 17 00:00:00 2001 From: Timothy Appnel Date: Fri, 7 Jun 2013 23:43:21 -0400 Subject: [PATCH] Fix bug where a null value for lengthMS would crash an import. Added a fallback to parse the standard min:sec length field. --- beetsplug/beatport.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/beetsplug/beatport.py b/beetsplug/beatport.py index 158cec09c..1e26baac2 100644 --- a/beetsplug/beatport.py +++ b/beetsplug/beatport.py @@ -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'])