mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 02:40:11 +01:00
[mod] solidtorrents engine: add metadata & torrentfile
BTW: define min_len in eval_xpath_list of 'stats' list Suggested-by: @dalf https://github.com/searxng/searxng/pull/862#pullrequestreview-872910744 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
f9c4868142
commit
d6061b7c8a
@ -13,6 +13,7 @@ from searx.utils import (
|
||||
extract_text,
|
||||
eval_xpath,
|
||||
eval_xpath_getindex,
|
||||
eval_xpath_list,
|
||||
get_torrent_size,
|
||||
)
|
||||
|
||||
@ -55,11 +56,14 @@ def response(resp):
|
||||
continue
|
||||
title = extract_text(a)
|
||||
url = eval_xpath_getindex(a, '@href', 0, None)
|
||||
stats = eval_xpath(result, './div//div[contains(@class, "stats")]/div')
|
||||
categ = eval_xpath(result, './div//a[contains(@class, "category")]')
|
||||
metadata = extract_text(categ)
|
||||
stats = eval_xpath_list(result, './div//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 = {
|
||||
@ -69,6 +73,8 @@ def response(resp):
|
||||
'url': base_url_rand + url,
|
||||
'filesize': filesize,
|
||||
'magnetlink': magnet,
|
||||
'torrentfile': torrentfile,
|
||||
'metadata': metadata,
|
||||
'template': "torrent.html",
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user