mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-19 18:15:31 +01:00
Fixed: albums with no track info werent being sorted when target bitrate was selected
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user