From adc1f9f35cea6ec67179392c70a99888d30ade4a Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 11 Jan 2013 01:19:07 -0500 Subject: [PATCH 1/5] Try not to reprocess torrent folders that are being kept for seeding during forced post processing --- headphones/postprocessor.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 665ce5c5..785ab393 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -840,11 +840,15 @@ def forcePostProcess(): # First try to see if there's a match in the snatched table, then we'll try to parse the foldername # TODO: Iterate through underscores -> spaces, spaces -> dots, underscores -> dots (this might be hit or miss since it assumes # all spaces/underscores came from sab replacing values - snatched = myDB.action('SELECT AlbumID, Title, Kind from snatched WHERE FolderName LIKE ?', [folder_basename]).fetchone() + snatched = myDB.action('SELECT AlbumID, Title, Kind, Status from snatched WHERE FolderName LIKE ?', [folder_basename]).fetchone() if snatched: - logger.info('Found a match in the database: %s. Verifying to make sure it is the correct album' % snatched['Title']) - verify(snatched['AlbumID'], folder, snatched['Kind']) - continue + if headphones.KEEP_TORRENT_FILES and snatched['Kind'] == 'torrent' and snatched['Status'] == 'Processed': + logger.info(folder_basename + ' is a torrent folder being preserved for seeding and has already been processed. Skipping.') + continue + else: + logger.info('Found a match in the database: %s. Verifying to make sure it is the correct album' % snatched['Title']) + verify(snatched['AlbumID'], folder, snatched['Kind']) + continue # Try to parse the folder name into a valid format # TODO: Add metadata lookup From 120ad6393f9c88907841db3244b3da1d371c23c9 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 11 Jan 2013 01:33:17 -0500 Subject: [PATCH 2/5] Added a filter for FLAC files based on title if we're not specifically looking for lossless --- headphones/searcher.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index be26c5e0..a1911137 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)] + resultlist[:] = [result for result in resultlist if verifyresult(result[0], artistterm, term, losslessOnly)] if len(resultlist): @@ -686,7 +686,7 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): -def verifyresult(title, artistterm, term): +def verifyresult(title, artistterm, term, lossless): title = re.sub('[\.\-\/\_]', ' ', title) @@ -705,10 +705,15 @@ def verifyresult(title, artistterm, term): #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 and 'remix' in title: + if 'remix' not in term.lower() and 'remix' in title.lower(): 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: @@ -1252,7 +1257,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)] + resultlist[:] = [result for result in resultlist if verifyresult(result[0], artistterm, term, losslessOnly)] if len(resultlist): From d91da42f50347f3d41ba014568478b2d1569bdcd Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 11 Jan 2013 05:46:43 -0500 Subject: [PATCH 3/5] Added an option to allow lossless if no good lossy matches found (works for nzbs only right now) --- data/interfaces/default/config.html | 4 ++++ headphones/__init__.py | 5 ++++- headphones/searcher.py | 11 +++++++++++ headphones/webserve.py | 4 +++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index f77bf985..bf9790d8 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -350,6 +350,10 @@ Preferred Bitrate: kbps
Reject if less than % or more than % of the target size (leave blank for no limit)

+
+ + +
diff --git a/headphones/__init__.py b/headphones/__init__.py index 6a4421a9..dbf1c384 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -96,6 +96,7 @@ PREFERRED_QUALITY = None PREFERRED_BITRATE = None PREFERRED_BITRATE_HIGH_BUFFER = None PREFERRED_BITRATE_LOW_BUFFER = None +PREFERRED_BITRATE_ALLOW_LOSSLESS = False DETECT_BITRATE = False ADD_ARTISTS = False CORRECT_METADATA = False @@ -284,7 +285,7 @@ def initialize(): PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, PUSHOVER_ENABLED, PUSHOVER_PRIORITY, PUSHOVER_KEYS, PUSHOVER_ONSNATCH, MIRRORLIST, \ MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \ XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \ - PREFERRED_BITRATE_LOW_BUFFER,CACHE_SIZEMB + PREFERRED_BITRATE_LOW_BUFFER, PREFERRED_BITRATE_ALLOW_LOSSLESS, CACHE_SIZEMB if __INITIALIZED__: return False @@ -344,6 +345,7 @@ def initialize(): PREFERRED_BITRATE = check_setting_str(CFG, 'General', 'preferred_bitrate', '') PREFERRED_BITRATE_HIGH_BUFFER = check_setting_int(CFG, 'General', 'preferred_bitrate_high_buffer', '') PREFERRED_BITRATE_LOW_BUFFER = check_setting_int(CFG, 'General', 'preferred_bitrate_low_buffer', '') + PREFERRED_BITRATE_ALLOW_LOSSLESS = bool(check_setting_int(CFG, 'General', 'preferred_bitrate_allow_lossless', 0)) DETECT_BITRATE = bool(check_setting_int(CFG, 'General', 'detect_bitrate', 0)) ADD_ARTISTS = bool(check_setting_int(CFG, 'General', 'auto_add_artists', 1)) CORRECT_METADATA = bool(check_setting_int(CFG, 'General', 'correct_metadata', 0)) @@ -666,6 +668,7 @@ def config_write(): new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE new_config['General']['preferred_bitrate_high_buffer'] = PREFERRED_BITRATE_HIGH_BUFFER new_config['General']['preferred_bitrate_low_buffer'] = PREFERRED_BITRATE_LOW_BUFFER + new_config['General']['preferred_bitrate_allow_lossless'] = int(PREFERRED_BITRATE_ALLOW_LOSSLESS) new_config['General']['detect_bitrate'] = int(DETECT_BITRATE) new_config['General']['auto_add_artists'] = int(ADD_ARTISTS) new_config['General']['correct_metadata'] = int(CORRECT_METADATA) diff --git a/headphones/searcher.py b/headphones/searcher.py index a1911137..272c16df 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -584,6 +584,7 @@ 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 @@ -598,6 +599,11 @@ 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): @@ -608,6 +614,11 @@ 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: diff --git a/headphones/webserve.py b/headphones/webserve.py index 8bee2eb9..8eeb982f 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -617,6 +617,7 @@ class WebInterface(object): "pref_bitrate" : headphones.PREFERRED_BITRATE, "pref_bitrate_high" : headphones.PREFERRED_BITRATE_HIGH_BUFFER, "pref_bitrate_low" : headphones.PREFERRED_BITRATE_LOW_BUFFER, + "pref_bitrate_allow_lossless" : checked(headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS), "detect_bitrate" : checked(headphones.DETECT_BITRATE), "move_files" : checked(headphones.MOVE_FILES), "rename_files" : checked(headphones.RENAME_FILES), @@ -708,7 +709,7 @@ class WebInterface(object): delete_lossless_files=0, prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0, xbmc_enabled=0, xbmc_host=None, xbmc_username=None, xbmc_password=None, xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, synoindex_enabled=False, pushover_enabled=0, pushover_onsnatch=0, pushover_keys=None, pushover_priority=0, mirror=None, customhost=None, customport=None, - customsleep=None, hpuser=None, hppass=None, preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, cache_sizemb=None, **kwargs): + customsleep=None, hpuser=None, hppass=None, preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, preferred_bitrate_allow_lossless=0, cache_sizemb=None, **kwargs): headphones.HTTP_HOST = http_host headphones.HTTP_PORT = http_port @@ -765,6 +766,7 @@ class WebInterface(object): headphones.PREFERRED_BITRATE = preferred_bitrate headphones.PREFERRED_BITRATE_HIGH_BUFFER = preferred_bitrate_high_buffer headphones.PREFERRED_BITRATE_LOW_BUFFER = preferred_bitrate_low_buffer + headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS = preferred_bitrate_allow_lossless headphones.DETECT_BITRATE = detect_bitrate headphones.MOVE_FILES = move_files headphones.CORRECT_METADATA = correct_metadata From 99a66e4955ec29d8f09bc68e563c7974c396e01f Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 11 Jan 2013 06:25:05 -0500 Subject: [PATCH 4/5] Added option to customize album art name --- data/interfaces/default/config.html | 28 +++++++++++++++++++++++++++- headphones/__init__.py | 5 ++++- headphones/postprocessor.py | 27 +++++++++++++++++++++++---- headphones/webserve.py | 4 +++- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index bf9790d8..95d3e2e7 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -371,7 +371,13 @@ - + +
+
+ as .jpg +
+ Use $Artist/$artist, $Album/$album, $Year/$year +
@@ -886,6 +892,26 @@ $("#encoderoptions").slideUp(); } }); + + if ($("#add_album_art").is(":checked")) + { + $("#album_art_options").show(); + } + else + { + $("#album_art_options").hide(); + } + + $("#add_album_art").click(function(){ + if ($("#add_album_art").is(":checked")) + { + $("#album_art_options").slideDown(); + } + else + { + $("#album_art_options").slideUp(); + } + }); if ($("#prowl").is(":checked")) { diff --git a/headphones/__init__.py b/headphones/__init__.py index dbf1c384..7bc31b73 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -104,6 +104,7 @@ MOVE_FILES = False RENAME_FILES = False CLEANUP_FILES = False ADD_ALBUM_ART = False +ALBUM_ART_FORMAT = None EMBED_ALBUM_ART = False EMBED_LYRICS = False DOWNLOAD_DIR = None @@ -274,7 +275,7 @@ def initialize(): CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, MUSIC_DIR, DESTINATION_DIR, \ LOSSLESS_DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, \ RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, KEEP_TORRENT_FILES, \ - ADD_ALBUM_ART, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \ + ADD_ALBUM_ART, ALBUM_ART_FORMAT, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \ TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, \ RUTRACKER, RUTRACKER_USER, RUTRACKER_PASSWORD, WHATCD, WHATCD_USERNAME, WHATCD_PASSWORD, DOWNLOAD_TORRENT_DIR, \ LIBRARYSCAN, LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \ @@ -355,6 +356,7 @@ def initialize(): FILE_FORMAT = check_setting_str(CFG, 'General', 'file_format', 'Track Artist - Album [Year]- Title') CLEANUP_FILES = bool(check_setting_int(CFG, 'General', 'cleanup_files', 0)) ADD_ALBUM_ART = bool(check_setting_int(CFG, 'General', 'add_album_art', 0)) + ALBUM_ART_FORMAT = check_setting_str(CFG, 'General', 'album_art_format', 'folder') EMBED_ALBUM_ART = bool(check_setting_int(CFG, 'General', 'embed_album_art', 0)) EMBED_LYRICS = bool(check_setting_int(CFG, 'General', 'embed_lyrics', 0)) DOWNLOAD_DIR = check_setting_str(CFG, 'General', 'download_dir', '') @@ -678,6 +680,7 @@ def config_write(): new_config['General']['file_format'] = FILE_FORMAT new_config['General']['cleanup_files'] = int(CLEANUP_FILES) new_config['General']['add_album_art'] = int(ADD_ALBUM_ART) + new_config['General']['album_art_format'] = ALBUM_ART_FORMAT new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART) new_config['General']['embed_lyrics'] = int(EMBED_LYRICS) new_config['General']['download_dir'] = DOWNLOAD_DIR diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 785ab393..c3f8ac18 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -354,7 +354,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, cleanupFiles(albumpath) if headphones.ADD_ALBUM_ART and artwork: - addAlbumArt(artwork, albumpath) + addAlbumArt(artwork, albumpath, release) if headphones.CORRECT_METADATA: correctMetadata(albumid, release, downloaded_track_list) @@ -425,11 +425,30 @@ def embedAlbumArt(artwork, downloaded_track_list): f.art = artwork f.save() -def addAlbumArt(artwork, albumpath): +def addAlbumArt(artwork, albumpath, release): logger.info('Adding album art to folder') - artwork_file_name = os.path.join(albumpath, 'folder.jpg') - file = open(artwork_file_name, 'wb') + try: + year = release['ReleaseDate'][:4] + except TypeError: + year = '' + + values = { '$Artist': release['ArtistName'], + '$Album': release['AlbumTitle'], + '$Year': year, + '$artist': release['ArtistName'].lower(), + '$album': release['AlbumTitle'].lower(), + '$year': year + } + + album_art_name = helpers.replace_all(headphones.ALBUM_ART_FORMAT.strip(), values).replace('/','_') + ".jpg" + + album_art_name = album_art_name.replace('?','_').replace(':', '_').encode(headphones.SYS_ENCODING, 'replace') + + if album_art_name.startswith('.'): + album_art_name = album_art_name.replace(0, '_') + + file = open(os.path.join(albumpath, album_art_name), 'wb') file.write(artwork) file.close() diff --git a/headphones/webserve.py b/headphones/webserve.py index 8eeb982f..8f13bdbe 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -624,6 +624,7 @@ class WebInterface(object): "correct_metadata" : checked(headphones.CORRECT_METADATA), "cleanup_files" : checked(headphones.CLEANUP_FILES), "add_album_art" : checked(headphones.ADD_ALBUM_ART), + "album_art_format" : headphones.ALBUM_ART_FORMAT, "embed_album_art" : checked(headphones.EMBED_ALBUM_ART), "embed_lyrics" : checked(headphones.EMBED_LYRICS), "dest_dir" : headphones.DESTINATION_DIR, @@ -702,7 +703,7 @@ class WebInterface(object): newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, nzbsrus=0, nzbsrus_uid=None, nzbsrus_apikey=None, nzbx=0, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None, numberofseeders=10, use_isohunt=0, use_kat=0, use_mininova=0, waffles=0, waffles_uid=None, waffles_passkey=None, whatcd=0, whatcd_username=None, whatcd_password=None, - rutracker=0, rutracker_user=None, rutracker_password=None, rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, + rutracker=0, rutracker_user=None, rutracker_password=None, rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, album_art_format=None, embed_album_art=0, embed_lyrics=0, destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0, remix=0, spokenword=0, audiobook=0, autowant_upcoming=False, autowant_all=False, keep_torrent_files=False, interface=None, log_dir=None, cache_dir=None, music_encoder=0, encoder=None, xldprofile=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0, @@ -773,6 +774,7 @@ class WebInterface(object): headphones.RENAME_FILES = rename_files headphones.CLEANUP_FILES = cleanup_files headphones.ADD_ALBUM_ART = add_album_art + headphones.ALBUM_ART_FORMAT = album_art_format headphones.EMBED_ALBUM_ART = embed_album_art headphones.EMBED_LYRICS = embed_lyrics headphones.DESTINATION_DIR = destination_dir From 291ea8b6539b9a4e86d9df27fd6ac64f5ed6b2fe Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 11 Jan 2013 06:58:51 -0500 Subject: [PATCH 5/5] Little bug fix to prevent preprocessing empty nzblist in searcher.py --- headphones/searcher.py | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) 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):