From d6061b7c8a9607d13bd1569fd409a4f0167afd42 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 4 Feb 2022 14:30:00 +0100 Subject: [PATCH] [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 --- searx/engines/solidtorrents.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/searx/engines/solidtorrents.py b/searx/engines/solidtorrents.py index 7f005c4a3..1e58996e5 100644 --- a/searx/engines/solidtorrents.py +++ b/searx/engines/solidtorrents.py @@ -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", }