Browse Source

Fix duplicate results in piratebay results

adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
b71570bdf7
  1. 10
      src/searchengine/nova/engines/piratebay.py
  2. 10
      src/searchengine/nova3/engines/piratebay.py

10
src/searchengine/nova/engines/piratebay.py

@ -1,4 +1,4 @@ @@ -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 @@ -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): @@ -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): @@ -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 = []

10
src/searchengine/nova3/engines/piratebay.py

@ -1,4 +1,4 @@ @@ -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 @@ -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): @@ -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): @@ -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 = []

Loading…
Cancel
Save