From 39225b48d6a8a98ceee732e86db15a621c61e854 Mon Sep 17 00:00:00 2001 From: Remy Date: Sat, 13 Aug 2011 23:40:29 -0700 Subject: [PATCH] Fixed bug preventing new downloads, albumpath fix --- headphones/postprocessor.py | 5 +++++ headphones/searcher.py | 42 +++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 8bf96692..1d8b7076 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -111,6 +111,11 @@ def verify(albumid, albumpath): release = myDB.action('SELECT * from albums WHERE AlbumID=?', [albumid]).fetchone() tracks = myDB.select('SELECT * from tracks WHERE AlbumID=?', [albumid]) + try: + albumpath = str(albumpath) + except UnicodeEncodeError: + albumpath = unicode(albumpath).encode('unicode_escape') + downloaded_track_list = [] for r,d,f in os.walk(albumpath): diff --git a/headphones/searcher.py b/headphones/searcher.py index 42807109..90e5b044 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -382,33 +382,29 @@ def searchNZB(albumid=None, new=False): if new: - # Checks to see if it's already downloaded - i = 0 - while i < len(nzblist): - alreadydownloaded = myDB.select('SELECT * from snatched WHERE URL=?', [nzblist[i][2]]) - - if len(alreadydownloaded) >= 1: - logger.info('%s has already been downloaded. Skipping.' % nzblist[i][0]) - i += 1 - - else: - bestqual = nzblist[i] - break - - try: - x = bestqual[0] - except UnboundLocalError: - logger.info('No more matches for %s' % term) - return - - else: - bestqual = nzblist[0] - - logger.info(u'Found best result: %s - %s' % (bestqual[2], bestqual[0], helpers.bytes_to_mb(bestqual[1]))) + while True: + + if len(nzblist): + + alreadydownloaded = myDB.select('SELECT * from snatched WHERE URL=?', [nzblist[0][2]]) + + if len(alreadydownloaded): + logger.info('%s has already been downloaded. Skipping.' % nzblist[0][0]) + nzblist.pop(0) + + else: + break + else: + logger.info('No more results found for %s' % term) + return + logger.info(u"Pre-processing result") + (data, bestqual) = preprocess(nzblist) + if data and bestqual: + logger.info(u'Found best result: %s - %s' % (bestqual[2], bestqual[0], helpers.bytes_to_mb(bestqual[1]))) nzb_folder_name = '%s - %s [%s]' % (helpers.latinToAscii(albums[0]).encode('UTF-8').replace('/', '_'), helpers.latinToAscii(albums[1]).encode('UTF-8').replace('/', '_'), year) if headphones.SAB_HOST and not headphones.BLACKHOLE: