diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2022-02-04 14:41:53 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-02-04 14:55:21 +0100 |
commit | ddc2102a075d9690b9e98e16cef2ae3c1e5268f3 (patch) | |
tree | 3cbd5b1076a67291ef009a40bf054e562ca0a7c8 /searx/engines/solidtorrents.py | |
parent | d6061b7c8a9607d13bd1569fd409a4f0167afd42 (diff) | |
download | searxng-ddc2102a075d9690b9e98e16cef2ae3c1e5268f3.tar.gz searxng-ddc2102a075d9690b9e98e16cef2ae3c1e5268f3.zip |
[fix] solidtorrents engine: store random bas_url in param
Two different threads ( = two different user queries) can call the request
function in a row and then the response function. The namespace will be same
since this is the same engine.
To keep exactly the same value ``base_url`` must be stored in params and then
retrieve using ``resp.search_params["base_url"]``.
Suggested-by: @dalf https://github.com/searxng/searxng/pull/862#discussion_r799324861
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/solidtorrents.py')
-rw-r--r-- | searx/engines/solidtorrents.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/searx/engines/solidtorrents.py b/searx/engines/solidtorrents.py index 1e58996e5..9b5d543d8 100644 --- a/searx/engines/solidtorrents.py +++ b/searx/engines/solidtorrents.py @@ -29,17 +29,16 @@ about = { categories = ['files'] paging = True -base_url = '' -base_url_rand = '' +# base_url can be overwritten by a list of URLs in the settings.yml +base_url = 'https://solidtorrents.net' def request(query, params): - global base_url_rand # pylint: disable=global-statement if isinstance(base_url, list): - base_url_rand = random.choice(base_url) + params['base_url'] = random.choice(base_url) else: - base_url_rand = base_url - search_url = base_url_rand + '/search?{query}' + params['base_url'] = base_url + search_url = params['base_url'] + '/search?{query}' page = (params['pageno'] - 1) * 20 query = urlencode({'q': query, 'page': page}) params['url'] = search_url.format(query=query) @@ -70,7 +69,7 @@ def response(resp): 'seed': seed, 'leech': leech, 'title': title, - 'url': base_url_rand + url, + 'url': resp.search_params['base_url'] + url, 'filesize': filesize, 'magnetlink': magnet, 'torrentfile': torrentfile, |