From 1084c11866df66e650203b06f2b1fe932b9f402a Mon Sep 17 00:00:00 2001 From: coolbombom Date: Tue, 6 Aug 2013 12:08:26 +0200 Subject: [PATCH] Update searcher.py --- headphones/searcher.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index 8e9c2869..4b114962 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -1073,9 +1073,7 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): provider)) # Pirate Bay - if headphones.PIRATEBAY and headphones.TORRENT_DOWNLOADER == 0: - logger.warn("Cannot search Pirate Bay with Blackhole option set") - if headphones.PIRATEBAY and headphones.TORRENT_DOWNLOADER != 0: + if headphones.PIRATEBAY: provider = "The Pirate Bay" providerurl = url_fix("http://thepiratebay.sx/search/" + term + "/0/99/") if headphones.PREFERRED_QUALITY == 3 or losslessOnly: @@ -1117,9 +1115,15 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): title = ''.join(item.find("a", {"class" : "detLink"})) seeds = int(''.join(item.find("td", {"align" : "right"}))) url = item.findAll("a")[3]['href'] + if headphones.TORRENT_DOWNLOADER == 0: + tor_hash = re.findall("urn:btih:(.*?)&", url) + if len(tor_hash) > 0: + url = "http://torrage.com/torrent/"+str(tor_hash[0]).upper()+".torrent" + else: + url = None formatted_size = re.search('Size (.*),', unicode(item)).group(1).replace(u'\xa0', ' ') size = helpers.piratesize(formatted_size) - if size < maxsize and minimumseeders < seeds: + if size < maxsize and minimumseeders < seeds and url != None: resultlist.append((title, size, url, provider)) logger.info('Found %s. Size: %s' % (title, formatted_size)) else: @@ -1193,6 +1197,9 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): rightformat = False except Exception, e: rightformat = False + for findterm in term.split(" "): + if not findterm in title: + rightformat = False if rightformat == True and size < maxsize and minimumseeders < seeds: resultlist.append((title, size, url, provider)) logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size))) @@ -1449,7 +1456,7 @@ def preprocesstorrent(resultlist, pre_sorted_list=False): for result in resultlist: # get outta here if rutracker or piratebay - if result[3] == 'rutracker.org' or result[3] == 'The Pirate Bay': + if result[3] == 'rutracker.org': return True, result try: