diff --git a/headphones/searcher.py b/headphones/searcher.py index 272c16df..df0760d3 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -562,7 +562,7 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): #when looking for "Foo - Foo" we don't want "Foobar" #this should be less of an issue when it isn't a self-titled album so we'll only check vs artist if len(resultlist): - resultlist[:] = [result for result in resultlist if verifyresult(result[0], artistterm, term, losslessOnly)] + resultlist[:] = [result for result in resultlist if verifyresult(result[0], artistterm, term)] if len(resultlist): @@ -584,7 +584,6 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): else: logger.info('Target size: %s' % helpers.bytes_to_mb(targetsize)) newlist = [] - flac_list = [] if headphones.PREFERRED_BITRATE_HIGH_BUFFER: high_size_limit = targetsize * int(headphones.PREFERRED_BITRATE_HIGH_BUFFER)/100 @@ -599,11 +598,6 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): if high_size_limit and (result[1] > high_size_limit): logger.info(result[0] + " is too large for this album - not considering it. (Size: " + helpers.bytes_to_mb(result[1]) + ", Maxsize: " + helpers.bytes_to_mb(high_size_limit)) - - # Add lossless nzbs to the "flac list" which we can use if there are no good lossy matches - if 'flac' in result[0].lower(): - flac_list.append((result[0], result[1], result[2], result[3])) - continue if low_size_limit and (result[1] < low_size_limit): @@ -614,11 +608,6 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): newlist.append((result[0], result[1], result[2], result[3], delta)) nzblist = sorted(newlist, key=lambda title: title[4]) - - if not len(nzblist) and len(flac_list) and headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS: - logger.info("Since there were no appropriate lossy matches, going to use lossless instead") - nzblist = sorted(flac_list, key=lambda title: title[1], reverse=True) - except Exception, e: @@ -649,6 +638,10 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): else: logger.info('No more results found for %s' % term) return "none" + + if not len(nzblist): + logger.info('No appropriate matches found for %s' % term) + return "none" logger.info(u"Pre-processing result") @@ -697,7 +690,7 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): -def verifyresult(title, artistterm, term, lossless): +def verifyresult(title, artistterm, term): title = re.sub('[\.\-\/\_]', ' ', title) @@ -716,15 +709,10 @@ def verifyresult(title, artistterm, term, lossless): #another attempt to weed out substrings. We don't want "Vol III" when we were looking for "Vol II" # Filter out remix search results (if we're not looking for it) - if 'remix' not in term.lower() and 'remix' in title.lower(): + if 'remix' not in term and 'remix' in title: logger.info("Removed " + title + " from results because it's a remix album and we're not looking for a remix album right now") return False - # Filter out FLAC if we're not specifically looking for it - if headphones.PREFERRED_QUALITY == (0 or '0') and 'flac' in title.lower() and not lossless: - logger.info("Removed " + title + " from results because it's a lossless album and we're not looking for a lossless album right now") - return False - tokens = re.split('\W', term, re.IGNORECASE | re.UNICODE) for token in tokens: @@ -1268,7 +1256,7 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): #when looking for "Foo - Foo" we don't want "Foobar" #this should be less of an issue when it isn't a self-titled album so we'll only check vs artist if len(resultlist): - resultlist[:] = [result for result in resultlist if verifyresult(result[0], artistterm, term, losslessOnly)] + resultlist[:] = [result for result in resultlist if verifyresult(result[0], artistterm, term)] if len(resultlist):