From 53a1458bf6826e6d819574dde5b9feb9a7aa1acb Mon Sep 17 00:00:00 2001 From: Ade Date: Fri, 8 Mar 2013 22:06:30 +1300 Subject: [PATCH] User search term for waffles & rutracker + add year to normal search for waffles --- headphones/searcher.py | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index df0760d3..55f32f96 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -125,7 +125,7 @@ def searchforalbum(albumid=None, new=False, lossless=False): else: foundNZB = "none" - if (headphones.NZBMATRIX or headphones.NEWZNAB or headphones.NZBSORG or headphones.NEWZBIN) and (headphones.SAB_HOST or headphones.BLACKHOLE): + if (headphones.NZBMATRIX or headphones.NEWZNAB or headphones.NZBSORG or headphones.NEWZBIN or headphones.NZBX or headphones.NZBSRUS) and (headphones.SAB_HOST or headphones.BLACKHOLE): foundNZB = searchNZB(albumid, new, lossless) if (headphones.KAT or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD) and foundNZB == "none": @@ -845,6 +845,12 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): else: term = cleanartist + ' ' + cleanalbum + # Save user search term + if albums[4]: + usersearchterm = term + else: + usersearchterm = '' + semi_clean_artist_term = re.sub('[\.\-\/]', ' ', semi_cleanartist).encode('utf-8', 'replace') semi_clean_album_term = re.sub('[\.\-\/]', ' ', semi_cleanalbum).encode('utf-8', 'replace') # Replace bad characters in the term and unicode it @@ -946,11 +952,17 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): format = "MP3" maxsize = 300000000 - query_items = ['artist:"%s"' % artistterm, - 'album:"%s"' % albumterm, - 'format:(%s)' % format, - 'size:[0 TO %d]' % maxsize, - '-seeders:0'] # cut out dead torrents + if not usersearchterm: + query_items = ['artist:"%s"' % artistterm, + 'album:"%s"' % albumterm, + 'year:(%s)' % year] + else: + query_items = [usersearchterm] + + query_items.extend(['format:(%s)' % format, + 'size:[0 TO %d]' % maxsize, + '-seeders:0']) # cut out dead torrents + if bitrate: query_items.append('bitrate:"%s"' % bitrate) @@ -1005,7 +1017,7 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): # Ignore if release date not specified, results too unpredictable - if not year: + if not year and not usersearchterm: logger.info(u'Release date not specified, ignoring for rutracker.org') else: @@ -1024,8 +1036,12 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): bitrate = True # build search url based on above - - searchURL = rutracker.searchurl(artistterm, albumterm, year, format) + + if not usersearchterm: + searchURL = rutracker.searchurl(artistterm, albumterm, year, format) + else: + searchURL = rutracker.searchurl(usersearchterm, ' ', ' ', format) + logger.info(u'Parsing results from rutracker.org' % searchURL) # parse results and get best match