From d1ebe423c9693ba78f9330f60c11885d460f67c8 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Fri, 7 Jun 2013 20:53:53 -0700 Subject: [PATCH] changelog/thanks/style for #319 --- beetsplug/beatport.py | 11 +++++++---- docs/changelog.rst | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/beetsplug/beatport.py b/beetsplug/beatport.py index 1e26baac2..c68901cc1 100644 --- a/beetsplug/beatport.py +++ b/beetsplug/beatport.py @@ -139,10 +139,13 @@ class BeatportTrack(BeatportObject): self.title = unicode(data['title']) if 'mixName' in data: self.mix_name = unicode(data['mixName']) - 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) + self.length = timedelta(milliseconds=data.get('lengthMs', 0) or 0) + if not self.length: + try: + min, sec = data.get('length', '0:0').split(':') + self.length = timedelta(minutes=int(min), seconds=int(sec)) + except ValueError: + pass if 'slug' in data: self.url = "http://beatport.com/track/{0}/{1}".format(data['slug'], data['id']) diff --git a/docs/changelog.rst b/docs/changelog.rst index 37eae87e7..784d2eb88 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -34,6 +34,8 @@ And some bug fixes: * Python 2.6 compatibility for :doc:`/plugins/beatport`. Thanks Wesley Bitter. * Don't move the config file during a null migration. Thanks to Theofilos Intzoglou. +* Fix an occasional crash in the :doc:`/plugins/beatport` when a length + field was missing from the API response. Thanks to Timothy Appnel. 1.2.0 (June 5, 2013)