forked from Ponysearch/Ponysearch
[fix] real support of non wikipedia style mediawikis
This commit is contained in:
parent
250777e8a7
commit
909424e1e5
1 changed files with 11 additions and 8 deletions
|
@ -24,13 +24,13 @@ number_of_results = 1
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
base_url = 'https://{language}.wikipedia.org/'
|
base_url = 'https://{language}.wikipedia.org/'
|
||||||
search_url = base_url + 'w/api.php?action=query'\
|
search_postfix = 'w/api.php?action=query'\
|
||||||
'&list=search'\
|
'&list=search'\
|
||||||
'&{query}'\
|
'&{query}'\
|
||||||
'&srprop=timestamp'\
|
'&srprop=timestamp'\
|
||||||
'&format=json'\
|
'&format=json'\
|
||||||
'&sroffset={offset}'\
|
'&sroffset={offset}'\
|
||||||
'&srlimit={limit}' # noqa
|
'&srlimit={limit}'
|
||||||
|
|
||||||
|
|
||||||
# do search-request
|
# do search-request
|
||||||
|
@ -48,12 +48,15 @@ def request(query, params):
|
||||||
else:
|
else:
|
||||||
language = params['language'].split('_')[0]
|
language = params['language'].split('_')[0]
|
||||||
|
|
||||||
if len(format_strings) > 1:
|
# format_string [('https://', 'language', '', None), ('.wikipedia.org/', None, None, None)]
|
||||||
|
if any(x[1] == 'language' for x in format_strings):
|
||||||
string_args['language'] = language
|
string_args['language'] = language
|
||||||
|
|
||||||
# write search-language back to params, required in response
|
# write search-language back to params, required in response
|
||||||
params['language'] = language
|
params['language'] = language
|
||||||
|
|
||||||
|
search_url = base_url + search_postfix
|
||||||
|
|
||||||
params['url'] = search_url.format(**string_args)
|
params['url'] = search_url.format(**string_args)
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
Loading…
Reference in a new issue