From fc3ae5112237ee326591fd7a8cd01888c2bcd674 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 20 Oct 2010 20:27:32 +0000 Subject: [PATCH] Fix isohunt and vertor search plugins --- src/search_engine/engines/isohunt.py | 8 ++++---- src/search_engine/engines/versions.txt | 4 ++-- src/search_engine/engines/vertor.py | 27 +++++++++++++++++++------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/search_engine/engines/isohunt.py b/src/search_engine/engines/isohunt.py index ce6466f7d..ece3178b8 100644 --- a/src/search_engine/engines/isohunt.py +++ b/src/search_engine/engines/isohunt.py @@ -1,4 +1,4 @@ -#VERSION: 1.31 +#VERSION: 1.32 #AUTHORS: Christophe Dumez (chris@qbittorrent.org) # Redistribution and use in source and binary forms, with or without @@ -38,9 +38,9 @@ class isohunt(object): print download_file(info) def search(self, what, cat='all'): - # Remove {} since isohunt does not seem - # to handle those very well - what = what.replace('{', '').replace('}', '') + # Remove {} since isohunt does not seem + # to handle those very well + what = what.replace('{', '').replace('}', '') i = 1 while True and i<11: res = 0 diff --git a/src/search_engine/engines/versions.txt b/src/search_engine/engines/versions.txt index e1744c639..2a9cda511 100644 --- a/src/search_engine/engines/versions.txt +++ b/src/search_engine/engines/versions.txt @@ -1,7 +1,7 @@ -isohunt: 1.31 +isohunt: 1.32 torrentreactor: 1.21 btjunkie: 2.23 mininova: 1.40 piratebay: 1.30 -vertor: 1.0 +vertor: 1.1 torrentdownloads: 1.06 diff --git a/src/search_engine/engines/vertor.py b/src/search_engine/engines/vertor.py index 41086e770..ed6b0cb87 100755 --- a/src/search_engine/engines/vertor.py +++ b/src/search_engine/engines/vertor.py @@ -1,4 +1,4 @@ -#VERSION: 1.0 +#VERSION: 1.1 #AUTHORS: Christophe Dumez (chris@qbittorrent.org) # Redistribution and use in source and binary forms, with or without @@ -50,6 +50,8 @@ class vertor(object): self.td_counter = None self.current_item = None self.results = results + self.in_name = False + self.outside_td = True; def start_a(self, attr): params = dict(attr) @@ -58,29 +60,40 @@ class vertor(object): self.current_item = {} self.td_counter = 0 self.current_item['link']=params['href'].strip() + elif self.td_counter == 0 and params.has_key('href') and params['href'].startswith("/torrents/") \ + and not self.current_item.has_key('name'): + self.in_name = True + + def end_a(self): + if self.in_name: + self.in_name = False def handle_data(self, data): - if self.td_counter == 0: + if self.in_name: if not self.current_item.has_key('name'): self.current_item['name'] = '' self.current_item['name']+= data.strip() - elif self.td_counter == 3: + elif self.td_counter == 2 and not self.outside_td: if not self.current_item.has_key('size'): self.current_item['size'] = '' self.current_item['size']+= data.strip() - elif self.td_counter == 4: + elif self.td_counter == 4 and not self.outside_td: if not self.current_item.has_key('seeds'): self.current_item['seeds'] = '' self.current_item['seeds']+= data.strip() - elif self.td_counter == 5: + elif self.td_counter == 5 and not self.outside_td: if not self.current_item.has_key('leech'): self.current_item['leech'] = '' self.current_item['leech']+= data.strip() + + def end_td(self): + self.outside_td = True def start_td(self,attr): if isinstance(self.td_counter,int): + self.outside_td = False self.td_counter += 1 - if self.td_counter > 6: + if self.td_counter > 5: self.td_counter = None # Display item if self.current_item: @@ -99,7 +112,7 @@ class vertor(object): results = [] parser = self.SimpleSGMLParser(results, self.url) dat = retrieve_url(self.url+'/index.php?mod=search&words=%s&cid=%s&orderby=a.seeds&asc=0&search=&exclude=&p=%d'%(what, self.supported_categories[cat], i)) - results_re = re.compile('(?s)Vertor search results.*') + results_re = re.compile('(?s).*') for match in results_re.finditer(dat): res_tab = match.group(0) parser.feed(res_tab)