forked from zaclys/searxng
Hopefully fix code style errors
This commit is contained in:
parent
3ec35a06f7
commit
fb364ffae7
|
@ -28,14 +28,11 @@ xpath_title = './/td[3]/a[last()]'
|
||||||
xpath_torrent_links = './/td[3]/a'
|
xpath_torrent_links = './/td[3]/a'
|
||||||
xpath_filesize = './/td[4]/text()'
|
xpath_filesize = './/td[4]/text()'
|
||||||
|
|
||||||
# do search-request
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
query = urlencode({'keyword': query})
|
query = urlencode({'keyword': query})
|
||||||
params['url'] = search_url.format(query=query, offset=params['pageno'])
|
params['url'] = search_url.format(query=query, offset=params['pageno'])
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
# get response from search-request
|
|
||||||
def response(resp):
|
def response(resp):
|
||||||
results = []
|
results = []
|
||||||
dom = html.fromstring(resp.text)
|
dom = html.fromstring(resp.text)
|
||||||
|
@ -46,23 +43,17 @@ def response(resp):
|
||||||
magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
|
magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
|
||||||
torrent_link = ""
|
torrent_link = ""
|
||||||
|
|
||||||
# category in which our torrent belongs
|
|
||||||
try:
|
try:
|
||||||
category = extract_text(result.xpath(xpath_category)[0])
|
category = extract_text(result.xpath(xpath_category)[0])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# torrent title
|
|
||||||
page_a = result.xpath(xpath_title)[0]
|
page_a = result.xpath(xpath_title)[0]
|
||||||
title = extract_text(page_a)
|
title = extract_text(page_a)
|
||||||
|
|
||||||
# link to the page
|
|
||||||
href = base_url + page_a.attrib.get('href')
|
href = base_url + page_a.attrib.get('href')
|
||||||
|
|
||||||
#magnet link
|
|
||||||
magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
|
magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
|
||||||
|
|
||||||
# let's try to calculate the torrent size
|
|
||||||
try:
|
try:
|
||||||
filesize_info = result.xpath(xpath_filesize)[0]
|
filesize_info = result.xpath(xpath_filesize)[0]
|
||||||
filesize = filesize_info[:-2]
|
filesize = filesize_info[:-2]
|
||||||
|
@ -70,8 +61,7 @@ def response(resp):
|
||||||
filesize = get_torrent_size(filesize, filesize_multiplier)
|
filesize = get_torrent_size(filesize, filesize_multiplier)
|
||||||
except :
|
except :
|
||||||
pass
|
pass
|
||||||
|
#I didn't add download/seed/leech count since as I figured out they are generated randowmly everytime
|
||||||
# content string contains all information not included into template
|
|
||||||
content = 'Category: "{category}".'
|
content = 'Category: "{category}".'
|
||||||
content = content.format(category=category)
|
content = content.format(category=category)
|
||||||
|
|
||||||
|
@ -81,5 +71,4 @@ def response(resp):
|
||||||
'filesize': filesize,
|
'filesize': filesize,
|
||||||
'magnetlink': magnet_link,
|
'magnetlink': magnet_link,
|
||||||
'template': 'torrent.html'})
|
'template': 'torrent.html'})
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
Loading…
Reference in New Issue