From 2ed3f8837f6787dbaf27ce406cfade24cbbea3db Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 4 Sep 2011 14:19:29 +0000 Subject: [PATCH] * morituri/common/program.py: If any track is missing duration, set the whole album duration to 0. --- ChangeLog | 6 ++++++ morituri/common/program.py | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae63641..0a65874 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-09-04 Thomas Vander Stichele + + * morituri/common/program.py: + If any track is missing duration, set the whole album duration + to 0. + 2011-09-04 Thomas Vander Stichele * morituri/common/gstreamer.py: diff --git a/morituri/common/program.py b/morituri/common/program.py index c3d47fa..60022b1 100644 --- a/morituri/common/program.py +++ b/morituri/common/program.py @@ -92,13 +92,12 @@ def getMetadata(release): metadata.mbidArtist = urlparse.urlparse(release.artist.id)[2].split("/")[-1] metadata.url = release.getId() - + tainted = False duration = 0 for t in release.tracks: track = TrackMetadata() - track.duration = t.duration - duration += t.duration + if isSingleArtist or t.artist == None: track.artist = metadata.artist track.sortName = metadata.sortName @@ -111,9 +110,22 @@ def getMetadata(release): track.title = t.title track.mbid = urlparse.urlparse(t.id)[2].split("/")[-1] + + track.duration = t.duration + if not track.duration: + log.warning('getMetadata', + 'track %r (%r) does not have duration' % ( + track.title, track.mbid)) + tainted = True + else: + duration += t.duration + metadata.tracks.append(track) - metadata.duration = duration + if not tainted: + metadata.duration = duration + else: + metadata.duration = 0 return metadata