mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 04:01:40 +01:00
[fix] solidtorrents
This commit is contained in:
parent
74600c028d
commit
8172f89075
@ -49,38 +49,30 @@ def response(resp):
|
|||||||
results = []
|
results = []
|
||||||
dom = html.fromstring(resp.text)
|
dom = html.fromstring(resp.text)
|
||||||
|
|
||||||
for result in eval_xpath(dom, '//div[contains(@class, "search-result")]'):
|
for result in eval_xpath(dom, '//li[contains(@class, "search-result")]'):
|
||||||
a = eval_xpath_getindex(result, './div/h5/a', 0, None)
|
torrentfile = eval_xpath_getindex(result, './/a[contains(@class, "dl-torrent")]/@href', 0, None)
|
||||||
if a is None:
|
magnet = eval_xpath_getindex(result, './/a[contains(@class, "dl-magnet")]/@href', 0, None)
|
||||||
continue
|
if torrentfile is None or magnet is None:
|
||||||
title = extract_text(a)
|
continue # ignore anime results that which aren't actually torrents
|
||||||
url = eval_xpath_getindex(a, '@href', 0, None)
|
title = eval_xpath_getindex(result, './/h5[contains(@class, "title")]', 0, None)
|
||||||
categ = eval_xpath(result, './div//a[contains(@class, "category")]')
|
url = eval_xpath_getindex(result, './/h5[contains(@class, "title")]/a/@href', 0, None)
|
||||||
metadata = extract_text(categ)
|
categ = eval_xpath(result, './/a[contains(@class, "category")]')
|
||||||
stats = eval_xpath_list(result, './div//div[contains(@class, "stats")]/div', min_len=5)
|
stats = eval_xpath_list(result, './/div[contains(@class, "stats")]/div', min_len=5)
|
||||||
n, u = extract_text(stats[1]).split()
|
|
||||||
filesize = get_torrent_size(n, u)
|
|
||||||
leech = extract_text(stats[2])
|
|
||||||
seed = extract_text(stats[3])
|
|
||||||
torrentfile = eval_xpath_getindex(result, './div//a[contains(@class, "dl-torrent")]/@href', 0, None)
|
|
||||||
magnet = eval_xpath_getindex(result, './div//a[contains(@class, "dl-magnet")]/@href', 0, None)
|
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'seed': seed,
|
'seed': extract_text(stats[3]),
|
||||||
'leech': leech,
|
'leech': extract_text(stats[2]),
|
||||||
'title': title,
|
'title': extract_text(title),
|
||||||
'url': resp.search_params['base_url'] + url,
|
'url': resp.search_params['base_url'] + url,
|
||||||
'filesize': filesize,
|
'filesize': get_torrent_size(*extract_text(stats[1]).split()),
|
||||||
'magnetlink': magnet,
|
'magnetlink': magnet,
|
||||||
'torrentfile': torrentfile,
|
'torrentfile': torrentfile,
|
||||||
'metadata': metadata,
|
'metadata': extract_text(categ),
|
||||||
'template': "torrent.html",
|
'template': "torrent.html",
|
||||||
}
|
}
|
||||||
|
|
||||||
date_str = extract_text(stats[4])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
params['publishedDate'] = datetime.strptime(date_str, '%b %d, %Y')
|
params['publishedDate'] = datetime.strptime(extract_text(stats[4]), '%b %d, %Y')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user