forked from zaclys/searxng
[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>
This commit is contained in:
parent
d6061b7c8a
commit
ddc2102a07
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue