From 8c9b834bc4f34737620c8d3303b69b4d6955d836 Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Wed, 13 Aug 2014 18:31:08 +0000 Subject: [PATCH] Check for total number of tracks before continuing. Prevents ZeroDivisonError's --- headphones/importer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/headphones/importer.py b/headphones/importer.py index f8008b1a..4bb3f9a7 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -432,9 +432,16 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): tracks = myDB.action('SELECT * from alltracks WHERE ReleaseID=?', [releaseid]).fetchall() - # This is used to see how many tracks you have from an album - to mark it as downloaded. Default is 80%, can be set in config as ALBUM_COMPLETION_PCT + # This is used to see how many tracks you have from an album - to + # mark it as downloaded. Default is 80%, can be set in config as + # ALBUM_COMPLETION_PCT total_track_count = len(tracks) + if total_track_count == 0: + logger.warning("Total track count is zero for Release ID " + + "'%s', skipping.", releaseid) + continue + for track in tracks: controlValueDict = {"TrackID": track['TrackID'],