From b71570bdf71f69ae6ef39a7de89d3263ded9a55f Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 19 Jan 2013 23:27:51 +0200 Subject: [PATCH] Fix duplicate results in piratebay results --- src/searchengine/nova/engines/piratebay.py | 10 +++++++++- src/searchengine/nova3/engines/piratebay.py | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/searchengine/nova/engines/piratebay.py b/src/searchengine/nova/engines/piratebay.py index baeb082d6..09f2f385d 100644 --- a/src/searchengine/nova/engines/piratebay.py +++ b/src/searchengine/nova/engines/piratebay.py @@ -1,4 +1,4 @@ -#VERSION: 1.51 +#VERSION: 1.52 #AUTHORS: Fabien Devaux (fab@gnux.info) #CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org) @@ -30,6 +30,8 @@ from novaprinter import prettyPrinter import sgmllib from helpers import retrieve_url, download_file +PREVIOUS_IDS = set() + class piratebay(object): url = 'https://thepiratebay.se' name = 'The Pirate Bay' @@ -59,6 +61,7 @@ class piratebay(object): self.td_counter = 0 self.current_item['desc_link'] = self.url + params['href'].strip() self.in_name = True + self.current_item['id'] = params['href'].split('/')[2] elif params['href'].startswith('magnet:'): self.current_item['link']=params['href'].strip() self.in_name = False @@ -90,12 +93,17 @@ class piratebay(object): self.td_counter = None # Display item if self.current_item: + if self.current_item['id'] in PREVIOUS_IDS: + self.results = [] + self.reset() + return self.current_item['engine_url'] = self.url if not self.current_item['seeds'].isdigit(): self.current_item['seeds'] = 0 if not self.current_item['leech'].isdigit(): self.current_item['leech'] = 0 prettyPrinter(self.current_item) + PREVIOUS_IDS.add(self.current_item['id']) self.results.append('a') def search(self, what, cat='all'): ret = [] diff --git a/src/searchengine/nova3/engines/piratebay.py b/src/searchengine/nova3/engines/piratebay.py index 3a73a4508..12dc9b8b6 100644 --- a/src/searchengine/nova3/engines/piratebay.py +++ b/src/searchengine/nova3/engines/piratebay.py @@ -1,4 +1,4 @@ -#VERSION: 1.51 +#VERSION: 1.52 #AUTHORS: Fabien Devaux (fab@gnux.info) #CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org) @@ -30,6 +30,8 @@ from novaprinter import prettyPrinter import sgmllib3 from helpers import retrieve_url, download_file +PREVIOUS_IDS = set() + class piratebay(object): url = 'https://thepiratebay.se' name = 'The Pirate Bay' @@ -59,6 +61,7 @@ class piratebay(object): self.td_counter = 0 self.current_item['desc_link'] = self.url + params['href'].strip() self.in_name = True + self.current_item['id'] = params['href'].split('/')[2] elif params['href'].startswith('magnet:'): self.current_item['link']=params['href'].strip() self.in_name = False @@ -90,12 +93,17 @@ class piratebay(object): self.td_counter = None # Display item if self.current_item: + if self.current_item['id'] in PREVIOUS_IDS: + self.results = [] + self.reset() + return self.current_item['engine_url'] = self.url if not self.current_item['seeds'].isdigit(): self.current_item['seeds'] = 0 if not self.current_item['leech'].isdigit(): self.current_item['leech'] = 0 prettyPrinter(self.current_item) + PREVIOUS_IDS.add(self.current_item['id']) self.results.append('a') def search(self, what, cat='all'): ret = []