Fixed: albums with no track info werent being sorted when target bitrate was selected

This commit is contained in:
Remy
2011-07-18 13:30:22 -07:00
parent c9b82b8585
commit 460b897374
2 changed files with 9 additions and 3 deletions

View File

@@ -105,8 +105,11 @@ def sortNZBList(resultlist, albumid):
myDB = db.DBConnection()
tracks = myDB.select('SELECT TrackDuration from tracks WHERE AlbumID=?', [albumid])
# album length in milliseconds
albumlength = sum([pair[0] for pair in tracks])
# album length in milliseconds - if there is no track info, return False
try:
albumlength = sum([pair[0] for pair in tracks])
except TypeError:
return False
# target size, in bytes
targetsize = albumlength/1000 * bitrate * 128

View File

@@ -92,7 +92,6 @@ def searchNZB(albumid=None):
logger.info(u"Parsing results from "+searchURL)
d = feedparser.parse(searchURL)
logger.debug('Parsing complete. Found %i results' % len(d.entries))
if not len(d.entries):
@@ -173,6 +172,10 @@ def searchNZB(albumid=None):
logger.debug('Sorting results list')
bestqual = helpers.sortNZBList(resultlist, albumid)
if not bestqual:
logger.info('No track information for %s - %s. Defaulting to highest quality' % (albums[0], albums[1]))
bestqual = sorted(resultlist, key=lambda title: title[1], reverse=True)[0]
else: