diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2022-02-04 14:30:00 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-02-04 14:53:42 +0100 |
commit | d6061b7c8a9607d13bd1569fd409a4f0167afd42 (patch) | |
tree | 144be17a42afd8e0a7268e2f53dfa72356788755 | |
parent | f9c486814203f25b35903880dd038b35ed0580a2 (diff) | |
download | searxng-d6061b7c8a9607d13bd1569fd409a4f0167afd42.tar.gz searxng-d6061b7c8a9607d13bd1569fd409a4f0167afd42.zip |
[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>
-rw-r--r-- | searx/engines/solidtorrents.py | 8 |
1 files changed, 7 insertions, 1 deletions
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", } |