Align search engine url getting mechanism. Closes #4778

1. Switch to retrieve_url instead of low-level HTTPConnection module usage
This commit is contained in:
Douman
2016-02-10 16:02:50 +03:00
parent f37aed868e
commit d5209d7ddf
10 changed files with 64 additions and 132 deletions

View File

@@ -1,4 +1,4 @@
#VERSION: 2.02
#VERSION: 2.03
#AUTHORS: Christophe Dumez (chris@qbittorrent.org)
#CONTRIBUTORS: Diego de las Heras (ngosang@hotmail.es)
@@ -27,10 +27,9 @@
# POSSIBILITY OF SUCH DAMAGE.
from HTMLParser import HTMLParser
from httplib import HTTPConnection as http
#qBt
from novaprinter import prettyPrinter
from helpers import download_file
from helpers import download_file, retrieve_url
class extratorrent(object):
""" Search engine class """
@@ -140,25 +139,18 @@ class extratorrent(object):
def search(self, what, cat="all"):
""" Performs search """
connection = http("extratorrent.cc")
query = "".join((self.url, "/advanced_search/?with=", what, "&s_cat=", self.supported_categories[cat]))
query = "".join(("/advanced_search/?with=", what, "&s_cat=", self.supported_categories[cat]))
connection.request("GET", query)
response = connection.getresponse()
if response.status != 200:
return
response = retrieve_url(query)
list_searches = []
parser = self.MyHtmlParseWithBlackJack(list_searches, self.url)
parser.feed(response.read().decode('utf-8'))
parser.feed(response)
parser.close()
for search_query in list_searches:
connection.request("GET", search_query)
response = connection.getresponse()
parser.feed(response.read().decode('utf-8'))
response = retrieve_url(self.url + search_query)
parser.feed(response)
parser.close()
connection.close()
return