Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
searx-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
searx-engine
Commits
b63d645a
Commit
b63d645a
authored
Jan 06, 2019
by
Noémi Ványi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "remove 'all' option from search languages"
This reverts commit
4d177039
.
parent
491792c1
Changes
51
Hide whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
245 additions
and
70 deletions
+245
-70
archlinux.py
searx/engines/archlinux.py
+2
-2
bing.py
searx/engines/bing.py
+4
-1
bing_news.py
searx/engines/bing_news.py
+4
-1
dailymotion.py
searx/engines/dailymotion.py
+4
-1
duckduckgo.py
searx/engines/duckduckgo.py
+9
-3
duckduckgo_images.py
searx/engines/duckduckgo_images.py
+6
-2
faroo.py
searx/engines/faroo.py
+4
-1
gigablast.py
searx/engines/gigablast.py
+6
-3
google.py
searx/engines/google.py
+5
-1
google_news.py
searx/engines/google_news.py
+4
-3
mediawiki.py
searx/engines/mediawiki.py
+4
-1
photon.py
searx/engines/photon.py
+4
-3
qwant.py
searx/engines/qwant.py
+3
-2
startpage.py
searx/engines/startpage.py
+3
-2
subtitleseeker.py
searx/engines/subtitleseeker.py
+1
-1
swisscows.py
searx/engines/swisscows.py
+6
-2
twitter.py
searx/engines/twitter.py
+6
-1
wikidata.py
searx/engines/wikidata.py
+4
-1
wikipedia.py
searx/engines/wikipedia.py
+3
-0
yacy.py
searx/engines/yacy.py
+3
-1
yahoo.py
searx/engines/yahoo.py
+13
-4
yahoo_news.py
searx/engines/yahoo_news.py
+4
-1
youtube_api.py
searx/engines/youtube_api.py
+3
-1
preferences.py
searx/preferences.py
+1
-0
search.py
searx/search.py
+1
-5
settings_robot.yml
searx/settings_robot.yml
+1
-1
preferences.html
searx/templates/courgette/preferences.html
+1
-0
preferences.html
searx/templates/legacy/preferences.html
+1
-0
languages.html
searx/templates/oscar/languages.html
+6
-5
preferences.html
searx/templates/pix-art/preferences.html
+1
-0
webapp.py
searx/webapp.py
+11
-6
test_archlinux.py
tests/unit/engines/test_archlinux.py
+1
-1
test_bing.py
tests/unit/engines/test_bing.py
+4
-0
test_bing_news.py
tests/unit/engines/test_bing_news.py
+4
-0
test_dailymotion.py
tests/unit/engines/test_dailymotion.py
+4
-0
test_duckduckgo_images.py
tests/unit/engines/test_duckduckgo_images.py
+1
-1
test_faroo.py
tests/unit/engines/test_faroo.py
+4
-0
test_gigablast.py
tests/unit/engines/test_gigablast.py
+6
-1
test_google_news.py
tests/unit/engines/test_google_news.py
+5
-0
test_mediawiki.py
tests/unit/engines/test_mediawiki.py
+4
-0
test_qwant.py
tests/unit/engines/test_qwant.py
+1
-2
test_startpage.py
tests/unit/engines/test_startpage.py
+4
-0
test_subtitleseeker.py
tests/unit/engines/test_subtitleseeker.py
+36
-0
test_swisscows.py
tests/unit/engines/test_swisscows.py
+5
-0
test_twitter.py
tests/unit/engines/test_twitter.py
+6
-0
test_wikidata.py
tests/unit/engines/test_wikidata.py
+2
-0
test_wikipedia.py
tests/unit/engines/test_wikipedia.py
+6
-0
test_yacy.py
tests/unit/engines/test_yacy.py
+5
-0
test_yahoo.py
tests/unit/engines/test_yahoo.py
+7
-0
test_yahoo_news.py
tests/unit/engines/test_yahoo_news.py
+7
-0
test_preferences.py
tests/unit/test_preferences.py
+5
-10
No files found.
searx/engines/archlinux.py
View file @
b63d645a
...
@@ -36,7 +36,7 @@ def locale_to_lang_code(locale):
...
@@ -36,7 +36,7 @@ def locale_to_lang_code(locale):
# wikis for some languages were moved off from the main site, we need to make
# wikis for some languages were moved off from the main site, we need to make
# requests to correct URLs to be able to get results in those languages
# requests to correct URLs to be able to get results in those languages
lang_urls
=
{
lang_urls
=
{
'
en
'
:
{
'
all
'
:
{
'base'
:
'https://wiki.archlinux.org'
,
'base'
:
'https://wiki.archlinux.org'
,
'search'
:
'/index.php?title=Special:Search&offset={offset}&{query}'
'search'
:
'/index.php?title=Special:Search&offset={offset}&{query}'
},
},
...
@@ -67,7 +67,7 @@ lang_urls = {
...
@@ -67,7 +67,7 @@ lang_urls = {
def
get_lang_urls
(
language
):
def
get_lang_urls
(
language
):
if
language
in
lang_urls
:
if
language
in
lang_urls
:
return
lang_urls
[
language
]
return
lang_urls
[
language
]
return
lang_urls
[
'
en
'
]
return
lang_urls
[
'
all
'
]
# Language names to build search requests for
# Language names to build search requests for
...
...
searx/engines/bing.py
View file @
b63d645a
...
@@ -34,7 +34,10 @@ search_string = 'search?{query}&first={offset}'
...
@@ -34,7 +34,10 @@ search_string = 'search?{query}&first={offset}'
def
request
(
query
,
params
):
def
request
(
query
,
params
):
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
+
1
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
+
1
lang
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
if
params
[
'language'
]
==
'all'
:
lang
=
'EN'
else
:
lang
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
query
=
u'language:{} {}'
.
format
(
lang
.
split
(
'-'
)[
0
]
.
upper
(),
query
.
decode
(
'utf-8'
))
.
encode
(
'utf-8'
)
query
=
u'language:{} {}'
.
format
(
lang
.
split
(
'-'
)[
0
]
.
upper
(),
query
.
decode
(
'utf-8'
))
.
encode
(
'utf-8'
)
...
...
searx/engines/bing_news.py
View file @
b63d645a
...
@@ -71,7 +71,10 @@ def request(query, params):
...
@@ -71,7 +71,10 @@ def request(query, params):
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
+
1
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
+
1
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
if
params
[
'language'
]
==
'all'
:
language
=
'en-US'
else
:
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
params
[
'url'
]
=
_get_url
(
query
,
language
,
offset
,
params
[
'time_range'
])
params
[
'url'
]
=
_get_url
(
query
,
language
,
offset
,
params
[
'time_range'
])
...
...
searx/engines/dailymotion.py
View file @
b63d645a
...
@@ -33,7 +33,10 @@ supported_languages_url = 'https://api.dailymotion.com/languages'
...
@@ -33,7 +33,10 @@ supported_languages_url = 'https://api.dailymotion.com/languages'
# do search-request
# do search-request
def
request
(
query
,
params
):
def
request
(
query
,
params
):
locale
=
match_language
(
params
[
'language'
],
supported_languages
)
if
params
[
'language'
]
==
'all'
:
locale
=
'en-US'
else
:
locale
=
match_language
(
params
[
'language'
],
supported_languages
)
params
[
'url'
]
=
search_url
.
format
(
params
[
'url'
]
=
search_url
.
format
(
query
=
urlencode
({
'search'
:
query
,
'localization'
:
locale
}),
query
=
urlencode
({
'search'
:
query
,
'localization'
:
locale
}),
...
...
searx/engines/duckduckgo.py
View file @
b63d645a
...
@@ -54,6 +54,9 @@ content_xpath = './/a[@class="result__snippet"]'
...
@@ -54,6 +54,9 @@ content_xpath = './/a[@class="result__snippet"]'
# match query's language to a region code that duckduckgo will accept
# match query's language to a region code that duckduckgo will accept
def
get_region_code
(
lang
,
lang_list
=
[]):
def
get_region_code
(
lang
,
lang_list
=
[]):
if
lang
==
'all'
:
return
None
lang_code
=
match_language
(
lang
,
lang_list
,
language_aliases
,
'wt-WT'
)
lang_code
=
match_language
(
lang
,
lang_list
,
language_aliases
,
'wt-WT'
)
lang_parts
=
lang_code
.
split
(
'-'
)
lang_parts
=
lang_code
.
split
(
'-'
)
...
@@ -61,7 +64,6 @@ def get_region_code(lang, lang_list=[]):
...
@@ -61,7 +64,6 @@ def get_region_code(lang, lang_list=[]):
return
lang_parts
[
1
]
.
lower
()
+
'-'
+
lang_parts
[
0
]
.
lower
()
return
lang_parts
[
1
]
.
lower
()
+
'-'
+
lang_parts
[
0
]
.
lower
()
# do search-request
def
request
(
query
,
params
):
def
request
(
query
,
params
):
if
params
[
'time_range'
]
and
params
[
'time_range'
]
not
in
time_range_dict
:
if
params
[
'time_range'
]
and
params
[
'time_range'
]
not
in
time_range_dict
:
return
params
return
params
...
@@ -69,8 +71,12 @@ def request(query, params):
...
@@ -69,8 +71,12 @@ def request(query, params):
offset
=
(
params
[
'pageno'
]
-
1
)
*
30
offset
=
(
params
[
'pageno'
]
-
1
)
*
30
region_code
=
get_region_code
(
params
[
'language'
],
supported_languages
)
region_code
=
get_region_code
(
params
[
'language'
],
supported_languages
)
params
[
'url'
]
=
url
.
format
(
if
region_code
:
query
=
urlencode
({
'q'
:
query
,
'kl'
:
region_code
}),
offset
=
offset
,
dc_param
=
offset
)
params
[
'url'
]
=
url
.
format
(
query
=
urlencode
({
'q'
:
query
,
'kl'
:
region_code
}),
offset
=
offset
,
dc_param
=
offset
)
else
:
params
[
'url'
]
=
url
.
format
(
query
=
urlencode
({
'q'
:
query
}),
offset
=
offset
,
dc_param
=
offset
)
if
params
[
'time_range'
]
in
time_range_dict
:
if
params
[
'time_range'
]
in
time_range_dict
:
params
[
'url'
]
+=
time_range_url
.
format
(
range
=
time_range_dict
[
params
[
'time_range'
]])
params
[
'url'
]
+=
time_range_url
.
format
(
range
=
time_range_dict
[
params
[
'time_range'
]])
...
...
searx/engines/duckduckgo_images.py
View file @
b63d645a
...
@@ -56,8 +56,12 @@ def request(query, params):
...
@@ -56,8 +56,12 @@ def request(query, params):
safesearch
=
params
[
'safesearch'
]
-
1
safesearch
=
params
[
'safesearch'
]
-
1
region_code
=
get_region_code
(
params
[
'language'
],
lang_list
=
supported_languages
)
region_code
=
get_region_code
(
params
[
'language'
],
lang_list
=
supported_languages
)
params
[
'url'
]
=
images_url
.
format
(
if
region_code
:
query
=
urlencode
({
'q'
:
query
,
'l'
:
region_code
}),
offset
=
offset
,
safesearch
=
safesearch
,
vqd
=
vqd
)
params
[
'url'
]
=
images_url
.
format
(
query
=
urlencode
({
'q'
:
query
,
'l'
:
region_code
}),
offset
=
offset
,
safesearch
=
safesearch
,
vqd
=
vqd
)
else
:
params
[
'url'
]
=
images_url
.
format
(
query
=
urlencode
({
'q'
:
query
}),
offset
=
offset
,
safesearch
=
safesearch
,
vqd
=
vqd
)
return
params
return
params
...
...
searx/engines/faroo.py
View file @
b63d645a
...
@@ -40,7 +40,10 @@ def request(query, params):
...
@@ -40,7 +40,10 @@ def request(query, params):
offset
=
(
params
[
'pageno'
]
-
1
)
*
number_of_results
+
1
offset
=
(
params
[
'pageno'
]
-
1
)
*
number_of_results
+
1
categorie
=
search_category
.
get
(
params
[
'category'
],
'web'
)
categorie
=
search_category
.
get
(
params
[
'category'
],
'web'
)
language
=
params
[
'language'
]
.
split
(
'-'
)[
0
]
if
params
[
'language'
]
==
'all'
:
language
=
'en'
else
:
language
=
params
[
'language'
]
.
split
(
'-'
)[
0
]
# if language is not supported, put it in english
# if language is not supported, put it in english
if
language
!=
'en'
and
\
if
language
!=
'en'
and
\
...
...
searx/engines/gigablast.py
View file @
b63d645a
...
@@ -50,9 +50,12 @@ supported_languages_url = 'https://gigablast.com/search?&rxikd=1'
...
@@ -50,9 +50,12 @@ supported_languages_url = 'https://gigablast.com/search?&rxikd=1'
def
request
(
query
,
params
):
def
request
(
query
,
params
):
offset
=
(
params
[
'pageno'
]
-
1
)
*
number_of_results
offset
=
(
params
[
'pageno'
]
-
1
)
*
number_of_results
language
=
params
[
'language'
]
.
replace
(
'-'
,
'_'
)
.
lower
()
if
params
[
'language'
]
==
'all'
:
if
language
.
split
(
'-'
)[
0
]
!=
'zh'
:
language
=
'xx'
language
=
language
.
split
(
'-'
)[
0
]
else
:
language
=
params
[
'language'
]
.
replace
(
'-'
,
'_'
)
.
lower
()
if
language
.
split
(
'-'
)[
0
]
!=
'zh'
:
language
=
language
.
split
(
'-'
)[
0
]
if
params
[
'safesearch'
]
>=
1
:
if
params
[
'safesearch'
]
>=
1
:
safesearch
=
1
safesearch
=
1
...
...
searx/engines/google.py
View file @
b63d645a
...
@@ -166,7 +166,11 @@ def extract_text_from_dom(result, xpath):
...
@@ -166,7 +166,11 @@ def extract_text_from_dom(result, xpath):
def
request
(
query
,
params
):
def
request
(
query
,
params
):
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
if
params
[
'language'
]
==
'all'
or
params
[
'language'
]
==
'en-US'
:
language
=
'en-GB'
else
:
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
language_array
=
language
.
split
(
'-'
)
language_array
=
language
.
split
(
'-'
)
if
params
[
'language'
]
.
find
(
'-'
)
>
0
:
if
params
[
'language'
]
.
find
(
'-'
)
>
0
:
country
=
params
[
'language'
]
.
split
(
'-'
)[
1
]
country
=
params
[
'language'
]
.
split
(
'-'
)[
1
]
...
...
searx/engines/google_news.py
View file @
b63d645a
...
@@ -51,9 +51,10 @@ def request(query, params):
...
@@ -51,9 +51,10 @@ def request(query, params):
params
[
'url'
]
=
search_url
.
format
(
query
=
urlencode
({
'q'
:
query
}),
params
[
'url'
]
=
search_url
.
format
(
query
=
urlencode
({
'q'
:
query
}),
search_options
=
urlencode
(
search_options
))
search_options
=
urlencode
(
search_options
))
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
.
split
(
'-'
)[
0
]
if
params
[
'language'
]
!=
'all'
:
if
language
:
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
.
split
(
'-'
)[
0
]
params
[
'url'
]
+=
'&lr=lang_'
+
language
if
language
:
params
[
'url'
]
+=
'&lr=lang_'
+
language
return
params
return
params
...
...
searx/engines/mediawiki.py
View file @
b63d645a
...
@@ -45,7 +45,10 @@ def request(query, params):
...
@@ -45,7 +45,10 @@ def request(query, params):
format_strings
=
list
(
Formatter
()
.
parse
(
base_url
))
format_strings
=
list
(
Formatter
()
.
parse
(
base_url
))
language
=
params
[
'language'
]
.
split
(
'-'
)[
0
]
if
params
[
'language'
]
==
'all'
:
language
=
'en'
else
:
language
=
params
[
'language'
]
.
split
(
'-'
)[
0
]
# format_string [('https://', 'language', '', None), ('.wikipedia.org/', None, None, None)]
# format_string [('https://', 'language', '', None), ('.wikipedia.org/', None, None, None)]
if
any
(
x
[
1
]
==
'language'
for
x
in
format_strings
):
if
any
(
x
[
1
]
==
'language'
for
x
in
format_strings
):
...
...
searx/engines/photon.py
View file @
b63d645a
...
@@ -35,9 +35,10 @@ def request(query, params):
...
@@ -35,9 +35,10 @@ def request(query, params):
search_string
.
format
(
query
=
urlencode
({
'q'
:
query
}),
search_string
.
format
(
query
=
urlencode
({
'q'
:
query
}),
limit
=
number_of_results
)
limit
=
number_of_results
)
language
=
params
[
'language'
]
.
split
(
'-'
)[
0
]
if
params
[
'language'
]
!=
'all'
:
if
language
in
supported_languages
:
language
=
params
[
'language'
]
.
split
(
'_'
)[
0
]
params
[
'url'
]
=
params
[
'url'
]
+
"&lang="
+
language
if
language
in
supported_languages
:
params
[
'url'
]
=
params
[
'url'
]
+
"&lang="
+
language
# using searx User-Agent
# using searx User-Agent
params
[
'headers'
][
'User-Agent'
]
=
searx_useragent
()
params
[
'headers'
][
'User-Agent'
]
=
searx_useragent
()
...
...
searx/engines/qwant.py
View file @
b63d645a
...
@@ -46,8 +46,9 @@ def request(query, params):
...
@@ -46,8 +46,9 @@ def request(query, params):
offset
=
offset
)
offset
=
offset
)
# add language tag
# add language tag
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
if
params
[
'language'
]
!=
'all'
:
params
[
'url'
]
+=
'&locale='
+
language
.
replace
(
'-'
,
'_'
)
.
lower
()
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
params
[
'url'
]
+=
'&locale='
+
language
.
replace
(
'-'
,
'_'
)
.
lower
()
return
params
return
params
...
...
searx/engines/startpage.py
View file @
b63d645a
...
@@ -46,8 +46,9 @@ def request(query, params):
...
@@ -46,8 +46,9 @@ def request(query, params):
params
[
'data'
]
=
{
'query'
:
query
,
params
[
'data'
]
=
{
'query'
:
query
,
'startat'
:
offset
}
'startat'
:
offset
}
# set language
# set language if specified
params
[
'data'
][
'with_language'
]
=
(
'lang_'
+
params
[
'language'
]
.
split
(
'-'
)[
0
])
if
params
[
'language'
]
!=
'all'
:
params
[
'data'
][
'with_language'
]
=
(
'lang_'
+
params
[
'language'
]
.
split
(
'-'
)[
0
])
return
params
return
params
...
...
searx/engines/subtitleseeker.py
View file @
b63d645a
...
@@ -48,7 +48,7 @@ def response(resp):
...
@@ -48,7 +48,7 @@ def response(resp):
search_lang
=
'Farsi'
search_lang
=
'Farsi'
elif
resp
.
search_params
[
'language'
]
==
'pt-BR'
:
elif
resp
.
search_params
[
'language'
]
==
'pt-BR'
:
search_lang
=
'Brazilian'
search_lang
=
'Brazilian'
el
se
:
el
if
resp
.
search_params
[
'language'
]
!=
'all'
:
search_lang
=
[
lc
[
3
]
search_lang
=
[
lc
[
3
]
for
lc
in
language_codes
for
lc
in
language_codes
if
lc
[
0
]
.
split
(
'-'
)[
0
]
==
resp
.
search_params
[
'language'
]
.
split
(
'-'
)[
0
]]
if
lc
[
0
]
.
split
(
'-'
)[
0
]
==
resp
.
search_params
[
'language'
]
.
split
(
'-'
)[
0
]]
...
...
searx/engines/swisscows.py
View file @
b63d645a
...
@@ -36,8 +36,12 @@ regex_img_url_remove_start = re.compile(b'^https?://i\.swisscows\.ch/\?link=')
...
@@ -36,8 +36,12 @@ regex_img_url_remove_start = re.compile(b'^https?://i\.swisscows\.ch/\?link=')
# do search-request
# do search-request
def
request
(
query
,
params
):
def
request
(
query
,
params
):
region
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
if
params
[
'language'
]
==
'all'
:
ui_language
=
region
.
split
(
'-'
)[
0
]
ui_language
=
'browser'
region
=
'browser'
else
:
region
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
ui_language
=
region
.
split
(
'-'
)[
0
]
search_path
=
search_string
.
format
(
search_path
=
search_string
.
format
(
query
=
urlencode
({
'query'
:
query
,
'uiLanguage'
:
ui_language
,
'region'
:
region
}),
query
=
urlencode
({
'query'
:
query
,
'uiLanguage'
:
ui_language
,
'region'
:
region
}),
...
...
searx/engines/twitter.py
View file @
b63d645a
...
@@ -37,7 +37,12 @@ timestamp_xpath = './/span[contains(@class,"_timestamp")]'
...
@@ -37,7 +37,12 @@ timestamp_xpath = './/span[contains(@class,"_timestamp")]'
# do search-request
# do search-request
def
request
(
query
,
params
):
def
request
(
query
,
params
):
params
[
'url'
]
=
search_url
+
urlencode
({
'q'
:
query
})
params
[
'url'
]
=
search_url
+
urlencode
({
'q'
:
query
})
params
[
'cookies'
][
'lang'
]
=
params
[
'language'
]
.
split
(
'-'
)[
0
]
# set language if specified
if
params
[
'language'
]
!=
'all'
:
params
[
'cookies'
][
'lang'
]
=
params
[
'language'
]
.
split
(
'-'
)[
0
]
else
:
params
[
'cookies'
][
'lang'
]
=
'en'
return
params
return
params
...
...
searx/engines/wikidata.py
View file @
b63d645a
...
@@ -68,7 +68,10 @@ def response(resp):
...
@@ -68,7 +68,10 @@ def response(resp):
html
=
fromstring
(
resp
.
text
)
html
=
fromstring
(
resp
.
text
)
search_results
=
html
.
xpath
(
wikidata_ids_xpath
)
search_results
=
html
.
xpath
(
wikidata_ids_xpath
)
language
=
match_language
(
resp
.
search_params
[
'language'
],
supported_languages
,
language_aliases
)
.
split
(
'-'
)[
0
]
if
resp
.
search_params
[
'language'
]
.
split
(
'-'
)[
0
]
==
'all'
:
language
=
'en'
else
:
language
=
match_language
(
resp
.
search_params
[
'language'
],
supported_languages
,
language_aliases
)
.
split
(
'-'
)[
0
]
# TODO: make requests asynchronous to avoid timeout when result_count > 1
# TODO: make requests asynchronous to avoid timeout when result_count > 1
for
search_result
in
search_results
[:
result_count
]:
for
search_result
in
search_results
[:
result_count
]:
...
...
searx/engines/wikipedia.py
View file @
b63d645a
...
@@ -31,6 +31,9 @@ supported_languages_url = 'https://meta.wikimedia.org/wiki/List_of_Wikipedias'
...
@@ -31,6 +31,9 @@ supported_languages_url = 'https://meta.wikimedia.org/wiki/List_of_Wikipedias'
# set language in base_url
# set language in base_url
def
url_lang
(
lang
):
def
url_lang
(
lang
):
lang_pre
=
lang
.
split
(
'-'
)[
0
]
if
lang_pre
==
'all'
or
lang_pre
not
in
supported_languages
:
return
'en'
return
match_language
(
lang
,
supported_languages
,
language_aliases
)
.
split
(
'-'
)[
0
]
return
match_language
(
lang
,
supported_languages
,
language_aliases
)
.
split
(
'-'
)[
0
]
...
...
searx/engines/yacy.py
View file @
b63d645a
...
@@ -51,7 +51,9 @@ def request(query, params):
...
@@ -51,7 +51,9 @@ def request(query, params):
limit
=
number_of_results
,
limit
=
number_of_results
,
search_type
=
search_type
)
search_type
=
search_type
)
params
[
'url'
]
+=
'&lr=lang_'
+
params
[
'language'
]
.
split
(
'-'
)[
0
]
# add language tag if specified
if
params
[
'language'
]
!=
'all'
:
params
[
'url'
]
+=
'&lr=lang_'
+
params
[
'language'
]
.
split
(
'-'
)[
0
]
return
params
return
params
...
...
searx/engines/yahoo.py
View file @
b63d645a
...
@@ -73,16 +73,25 @@ def _get_url(query, offset, language, time_range):
...
@@ -73,16 +73,25 @@ def _get_url(query, offset, language, time_range):
lang
=
language
)
lang
=
language
)
def
_get_language
(
params
):
if
params
[
'language'
]
==
'all'
:
return
'en'
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
if
language
not
in
language_aliases
.
values
():
language
=
language
.
split
(
'-'
)[
0
]
language
=
language
.
replace
(
'-'
,
'_'
)
.
lower
()
return
language
# do search-request
# do search-request
def
request
(
query
,
params
):
def
request
(
query
,
params
):
if
params
[
'time_range'
]
and
params
[
'time_range'
]
not
in
time_range_dict
:
if
params
[
'time_range'
]
and
params
[
'time_range'
]
not
in
time_range_dict
:
return
params
return
params
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
+
1
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
+
1
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
language
=
_get_language
(
params
)
if
language
not
in
language_aliases
.
values
():
language
=
language
.
split
(
'-'
)[
0
]
language
=
language
.
replace
(
'-'
,
'_'
)
.
lower
()
params
[
'url'
]
=
_get_url
(
query
,
offset
,
language
,
params
[
'time_range'
])
params
[
'url'
]
=
_get_url
(
query
,
offset
,
language
,
params
[
'time_range'
])
...
...
searx/engines/yahoo_news.py
View file @
b63d645a
...
@@ -41,7 +41,10 @@ suggestion_xpath = '//div[contains(@class,"VerALSOTRY")]//a'
...
@@ -41,7 +41,10 @@ suggestion_xpath = '//div[contains(@class,"VerALSOTRY")]//a'
def
request
(
query
,
params
):
def
request
(
query
,
params
):
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
+
1
offset
=
(
params
[
'pageno'
]
-
1
)
*
10
+
1
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
.
split
(
'-'
)[
0
]
if
params
[
'language'
]
==
'all'
:
language
=
'en'
else
:
language
=
match_language
(
params
[
'language'
],
supported_languages
,
language_aliases
)
.
split
(
'-'
)[
0
]
params
[
'url'
]
=
search_url
.
format
(
offset
=
offset
,
params
[
'url'
]
=
search_url
.
format
(
offset
=
offset
,
query
=
urlencode
({
'p'
:
query
}),
query
=
urlencode
({
'p'
:
query
}),
...
...
searx/engines/youtube_api.py
View file @
b63d645a
...
@@ -34,7 +34,9 @@ def request(query, params):
...
@@ -34,7 +34,9 @@ def request(query, params):
params
[
'url'
]
=
search_url
.
format
(
query
=
urlencode
({
'q'
:
query
}),
params
[
'url'
]
=
search_url
.
format
(
query
=
urlencode
({
'q'
:
query
}),
api_key
=
api_key
)
api_key
=
api_key
)
params
[
'url'
]
+=
'&relevanceLanguage='
+
params
[
'language'
]
.
split
(
'-'
)[
0
]
# add language tag if specified
if
params
[
'language'
]
!=
'all'
:
params
[
'url'
]
+=
'&relevanceLanguage='
+
params
[
'language'
]
.
split
(
'-'
)[
0
]
return
params
return
params
...
...
searx/preferences.py
View file @
b63d645a
...
@@ -12,6 +12,7 @@ if version[0] == '3':
...
@@ -12,6 +12,7 @@ if version[0] == '3':
COOKIE_MAX_AGE
=
60
*
60
*
24
*
365
*
5
# 5 years
COOKIE_MAX_AGE
=
60
*
60
*
24
*
365
*
5
# 5 years
LANGUAGE_CODES
=
[
l
[
0
]
for
l
in
languages
]
LANGUAGE_CODES
=
[
l
[
0
]
for
l
in
languages
]
LANGUAGE_CODES
.
append
(
'all'
)
DISABLED
=
0
DISABLED
=
0
ENABLED
=
1
ENABLED
=
1
DOI_RESOLVERS
=
list
(
settings
[
'doi_resolvers'
])
DOI_RESOLVERS
=
list
(
settings
[
'doi_resolvers'
])
...
...
searx/search.py
View file @
b63d645a
...
@@ -24,7 +24,7 @@ from flask_babel import gettext
...
@@ -24,7 +24,7 @@ from flask_babel import gettext
import
requests.exceptions
import
requests.exceptions
import
searx.poolrequests
as
requests_lib
import
searx.poolrequests
as
requests_lib
from
searx.engines
import
(
from
searx.engines
import
(
categories
,
engines
,
settings
categories
,
engines
)
)
from
searx.answerers
import
ask
from
searx.answerers
import
ask
from
searx.utils
import
gen_useragent
from
searx.utils
import
gen_useragent
...
@@ -221,10 +221,6 @@ def get_search_query_from_webapp(preferences, form):
...
@@ -221,10 +221,6 @@ def get_search_query_from_webapp(preferences, form):
else
:
else
:
query_lang
=
preferences
.
get_value
(
'language'
)
query_lang
=
preferences
.
get_value
(
'language'
)
# provides backwards compatibility for requests using old language default
if
query_lang
==
'all'
:
query_lang
=
settings
[
'search'
][
'language'
]
# check language
# check language
if
not
VALID_LANGUAGE_CODE
.
match
(
query_lang
):
if
not
VALID_LANGUAGE_CODE
.
match
(
query_lang
):
raise
SearxParameterException
(
'language'
,
query_lang
)
raise
SearxParameterException
(
'language'
,
query_lang
)
...
...
searx/settings_robot.yml
View file @
b63d645a
...
@@ -5,7 +5,7 @@ general:
...
@@ -5,7 +5,7 @@ general:
search
:
search
:
safe_search
:
0
safe_search
:
0
autocomplete
:
"
"
autocomplete
:
"
"
language
:
"
en-US
"
language
:
"
all
"
server
:
server
:
port
:
11111
port
:
11111
...
...
searx/templates/courgette/preferences.html
View file @
b63d645a
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
<legend>
{{ _('Search language') }}
</legend>
<legend>
{{ _('Search language') }}
</legend>
<p>
<p>
<select
name=
'language'
>
<select
name=
'language'
>
<option
value=
"all"
{%
if
current_language =
=
'
all
'
%}
selected=
"selected"
{%
endif
%}
>
{{ _('Default language') }}
</option>
{% for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) %}
{% for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) %}
<option
value=
"{{ lang_id }}"
{%
if
lang_id =
=
current_language
%}
selected=
"selected"
{%
endif
%}
>
{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}
</option>
<option
value=
"{{ lang_id }}"
{%
if
lang_id =
=
current_language
%}
selected=
"selected"
{%
endif
%}
>
{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}
</option>
{% endfor %}
{% endfor %}
...
...
searx/templates/legacy/preferences.html
View file @
b63d645a
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
<legend>
{{ _('Search language') }}
</legend>
<legend>
{{ _('Search language') }}
</legend>
<p>
<p>
<select
name=
'language'
>
<select
name=
'language'
>
<option
value=
"all"
{%
if
current_language =
=
'
all
'
%}
selected=
"selected"
{%
endif
%}
>
{{ _('Default language') }}
</option>
{% for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) %}
{% for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) %}
<option
value=
"{{ lang_id }}"
{%
if
lang_id =
=
current_language
%}
selected=
"selected"
{%
endif
%}
>
{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}
</option>
<option
value=
"{{ lang_id }}"
{%
if
lang_id =
=
current_language
%}
selected=
"selected"
{%
endif
%}
>
{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}
</option>
{% endfor %}
{% endfor %}
...
...
searx/templates/oscar/languages.html
View file @
b63d645a
...
@@ -3,9 +3,10 @@
...
@@ -3,9 +3,10 @@
{% else %}
{% else %}
<select
class=
"time_range custom-select form-control"
id=
'language'
name=
'language'
>
<select
class=
"time_range custom-select form-control"
id=
'language'
name=
'language'
>
{% endif %}
{% endif %}
{% for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) %}
<option
value=
"all"
{%
if
current_language =
=
'
all
'
%}
selected=
"selected"
{%
endif
%}
>
{{ _('Default language') }}
</option>
<option
value=
"{{ lang_id }}"
{%
if
lang_id =
=
current_language
%}
selected=
"selected"
{%
endif
%}
>
{% for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) %}
{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}
<option
value=
"{{ lang_id }}"
{%
if
lang_id =
=
current_language
%}
selected=
"selected"
{%
endif
%}
>
</option>
{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}
{% endfor %}
</option>
{% endfor %}
</select>
</select>
searx/templates/pix-art/preferences.html
View file @
b63d645a
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<legend>
{{ _('Search language') }}
</legend>
<legend>
{{ _('Search language') }}
</legend>
<p>
<p>
<select
name=
'language'
>
<select
name=
'language'
>
<option
value=
"all"
{%
if
current_language =
=
'
all
'
%}
selected=
"selected"
{%
endif
%}
>
{{ _('Default language') }}
</option>
{% for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) %}
{% for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) %}
<option
value=
"{{ lang_id }}"
{%
if
lang_id =
=
current_language
%}
selected=
"selected"
{%
endif
%}
>
{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}
</option>
<option
value=
"{{ lang_id }}"
{%
if
lang_id =
=
current_language
%}
selected=
"selected"
{%
endif
%}
>
{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}
</option>
{% endfor %}
{% endfor %}
...
...
searx/webapp.py
View file @
b63d645a
...
@@ -637,8 +637,8 @@ def autocompleter():
...
@@ -637,8 +637,8 @@ def autocompleter():
if
len
(
raw_results
)
<=
3
and
completer
:
if
len
(
raw_results
)
<=
3
and
completer
:
# get language from cookie
# get language from cookie
language
=
request
.
preferences
.
get_value
(
'language'
)
language
=
request
.
preferences
.
get_value
(
'language'
)
if
not
language
:
if
not
language
or
language
==
'all'
:
language
=
settings
[
'search'
][
'language'
]
language
=
'en'
else
:
else
:
language
=
language
.
split
(
'-'
)[
0
]
language
=
language
.
split
(
'-'
)[
0
]
# run autocompletion
# run autocompletion
...
@@ -691,10 +691,7 @@ def preferences():
...
@@ -691,10 +691,7 @@ def preferences():
'warn_time'
:
False
}
'warn_time'
:
False
}
if
e
.
timeout
>
settings
[
'outgoing'
][
'request_timeout'
]:
if
e
.
timeout
>
settings
[
'outgoing'
][
'request_timeout'
]:
stats
[
e
.
name
][
'warn_timeout'
]
=
True
stats
[
e
.
name
][
'warn_timeout'
]
=
True
if
match_language
(
request
.
preferences
.
get_value
(
'language'
),
stats
[
e
.
name
][
'supports_selected_language'
]
=
_is_selected_language_supported
(
e
,
request
.
preferences
)
getattr
(
e
,
'supported_languages'
,
[]),
getattr
(
e
,
'language_aliases'
,
{}),
None
):
stats
[
e
.
name
][
'supports_selected_language'
]
=
True
# get first element [0], the engine time,
# get first element [0], the engine time,
# and then the second element [1] : the time (the first one is the label)
# and then the second element [1] : the time (the first one is the label)
...
@@ -725,6 +722,14 @@ def preferences():
...
@@ -725,6 +722,14 @@ def preferences():
preferences
=
True
)
preferences
=
True
)
def
_is_selected_language_supported
(
engine
,
preferences
):
language
=
preferences
.
get_value
(
'language'
)
return
(
language
==
'all'
or
match_language
(
language
,
getattr
(
engine
,
'supported_languages'
,
[]),
getattr
(
engine
,
'language_aliases'
,
{}),
None
))
@
app
.
route
(
'/image_proxy'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/image_proxy'
,
methods
=
[
'GET'
])
def
image_proxy
():
def
image_proxy
():
url
=
request
.
args
.
get
(
'url'
)
.
encode
(
'utf-8'
)
url
=
request
.
args
.
get
(
'url'
)
.
encode
(
'utf-8'
)
...
...
tests/unit/engines/test_archlinux.py
View file @
b63d645a
...
@@ -4,7 +4,7 @@ from searx.engines import archlinux
...
@@ -4,7 +4,7 @@ from searx.engines import archlinux
from
searx.testing
import
SearxTestCase
from
searx.testing
import
SearxTestCase
domains
=
{
domains
=
{
'
en
'
:
'https://wiki.archlinux.org'
,
'
all
'
:
'https://wiki.archlinux.org'
,
'de'
:
'https://wiki.archlinux.de'
,
'de'
:
'https://wiki.archlinux.de'
,
'fr'
:
'https://wiki.archlinux.fr'
,
'fr'
:
'https://wiki.archlinux.fr'
,
'ja'
:
'https://wiki.archlinuxjp.org'
,
'ja'
:
'https://wiki.archlinuxjp.org'
,
...
...
tests/unit/engines/test_bing.py
View file @
b63d645a
...
@@ -18,6 +18,10 @@ class TestBingEngine(SearxTestCase):
...
@@ -18,6 +18,10 @@ class TestBingEngine(SearxTestCase):
self
.
assertTrue
(
'language
%3
AFR'
in
params
[
'url'
])
self
.
assertTrue
(
'language
%3
AFR'
in
params
[
'url'
])
self
.
assertTrue
(
'bing.com'
in
params
[
'url'
])
self
.
assertTrue
(
'bing.com'
in
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
bing
.
request
(
query
.
encode
(
'utf-8'
),
dicto
)
self
.
assertTrue
(
'language'
in
params
[
'url'
])
def
test_response
(
self
):
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
bing
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
bing
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
bing
.
response
,
[])
self
.
assertRaises
(
AttributeError
,
bing
.
response
,
[])
...
...
tests/unit/engines/test_bing_news.py
View file @
b63d645a
...
@@ -20,6 +20,10 @@ class TestBingNewsEngine(SearxTestCase):
...
@@ -20,6 +20,10 @@ class TestBingNewsEngine(SearxTestCase):
self
.
assertIn
(
'bing.com'
,
params
[
'url'
])
self
.
assertIn
(
'bing.com'
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
bing_news
.
request
(
query
,
dicto
)
self
.
assertIn
(
'en'
,
params
[
'url'
])
def
test_no_url_in_request_year_time_range
(
self
):
def
test_no_url_in_request_year_time_range
(
self
):
dicto
=
defaultdict
(
dict
)
dicto
=
defaultdict
(
dict
)
query
=
'test_query'
query
=
'test_query'
...
...
tests/unit/engines/test_dailymotion.py
View file @
b63d645a
...
@@ -19,6 +19,10 @@ class TestDailymotionEngine(SearxTestCase):
...
@@ -19,6 +19,10 @@ class TestDailymotionEngine(SearxTestCase):
self
.
assertTrue
(
'dailymotion.com'
in
params
[
'url'
])
self
.
assertTrue
(
'dailymotion.com'
in
params
[
'url'
])
self
.
assertTrue
(
'fr'
in
params
[
'url'
])
self
.
assertTrue
(
'fr'
in
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
dailymotion
.
request
(
query
,
dicto
)
self
.
assertTrue
(
'en'
in
params
[
'url'
])
def
test_response
(
self
):
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
dailymotion
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
dailymotion
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
dailymotion
.
response
,
[])
self
.
assertRaises
(
AttributeError
,
dailymotion
.
response
,
[])
...
...
tests/unit/engines/test_duckduckgo_images.py
View file @
b63d645a
...
@@ -14,7 +14,7 @@ class TestDuckduckgoImagesEngine(SearxTestCase):
...
@@ -14,7 +14,7 @@ class TestDuckduckgoImagesEngine(SearxTestCase):
dicto
[
'is_test'
]
=
True
dicto
[
'is_test'
]
=
True
dicto
[
'pageno'
]
=
1
dicto
[
'pageno'
]
=
1
dicto
[
'safesearch'
]
=
0
dicto
[
'safesearch'
]
=
0
dicto
[
'language'
]
=
'
en-US
'
dicto
[
'language'
]
=
'
all
'
params
=
duckduckgo_images
.
request
(
query
,
dicto
)
params
=
duckduckgo_images
.
request
(
query
,
dicto
)
self
.
assertIn
(
'url'
,
params
)
self
.
assertIn
(
'url'
,
params
)
self
.
assertIn
(
query
,
params
[
'url'
])
self
.
assertIn
(
query
,
params
[
'url'
])
...
...
tests/unit/engines/test_faroo.py
View file @
b63d645a
...
@@ -20,6 +20,10 @@ class TestFarooEngine(SearxTestCase):
...
@@ -20,6 +20,10 @@ class TestFarooEngine(SearxTestCase):
self
.
assertIn
(
'en'
,
params
[
'url'
])
self
.
assertIn
(
'en'
,
params
[
'url'
])
self
.
assertIn
(
'web'
,
params
[
'url'
])
self
.
assertIn
(
'web'
,
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
faroo
.
request
(
query
,
dicto
)
self
.
assertIn
(
'en'
,
params
[
'url'
])
dicto
[
'language'
]
=
'de-DE'
dicto
[
'language'
]
=
'de-DE'
params
=
faroo
.
request
(
query
,
dicto
)
params
=
faroo
.
request
(
query
,
dicto
)
self
.
assertIn
(
'de'
,
params
[
'url'
])
self
.
assertIn
(
'de'
,
params
[
'url'
])
...
...
tests/unit/engines/test_gigablast.py
View file @
b63d645a
...
@@ -11,11 +11,16 @@ class TestGigablastEngine(SearxTestCase):
...
@@ -11,11 +11,16 @@ class TestGigablastEngine(SearxTestCase):
dicto
=
defaultdict
(
dict
)
dicto
=
defaultdict
(
dict
)
dicto
[
'pageno'
]
=
0
dicto
[
'pageno'
]
=
0
dicto
[
'safesearch'
]
=
0
dicto
[
'safesearch'
]
=
0
dicto
[
'language'
]
=
'
en-US
'
dicto
[
'language'
]
=
'
all
'
params
=
gigablast
.
request
(
query
,
dicto
)
params
=
gigablast
.
request
(
query
,
dicto
)
self
.
assertTrue
(
'url'
in
params
)
self
.
assertTrue
(
'url'
in
params
)
self
.
assertTrue
(
query
in
params
[
'url'
])
self
.
assertTrue
(
query
in
params
[
'url'
])
self
.
assertTrue
(
'gigablast.com'
in
params
[
'url'
])
self
.
assertTrue
(
'gigablast.com'
in
params
[
'url'
])
self
.
assertTrue
(
'xx'
in
params
[
'url'
])
dicto
[
'language'
]
=
'en-US'
params
=
gigablast
.
request
(
query
,
dicto
)
self
.
assertTrue
(
'en'
in
params
[
'url'
])
self
.
assertFalse
(
'en-US'
in
params
[
'url'
])
self
.
assertFalse
(
'en-US'
in
params
[
'url'
])
def
test_response
(
self
):
def
test_response
(
self
):
...
...
tests/unit/engines/test_google_news.py
View file @
b63d645a
...
@@ -21,6 +21,11 @@ class TestGoogleNewsEngine(SearxTestCase):
...
@@ -21,6 +21,11 @@ class TestGoogleNewsEngine(SearxTestCase):
self
.
assertIn
(
query
,
params
[
'url'
])
self
.
assertIn
(
query
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
google_news
.
request
(
query
,
dicto
)
self
.
assertIn
(
'url'
,
params
)
self
.
assertNotIn
(
'fr'
,
params
[
'url'
])
def
test_response
(
self
):
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
google_news
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
google_news
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
google_news
.
response
,
[])
self
.
assertRaises
(
AttributeError
,
google_news
.
response
,
[])
...
...
tests/unit/engines/test_mediawiki.py
View file @
b63d645a
...
@@ -18,6 +18,10 @@ class TestMediawikiEngine(SearxTestCase):
...
@@ -18,6 +18,10 @@ class TestMediawikiEngine(SearxTestCase):
self
.
assertIn
(
'wikipedia.org'
,
params
[
'url'
])
self
.
assertIn
(
'wikipedia.org'
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
mediawiki
.
request
(
query
,
dicto
)
self
.
assertIn
(
'en'
,
params
[
'url'
])
mediawiki
.
base_url
=
"http://test.url/"
mediawiki
.
base_url
=
"http://test.url/"
mediawiki
.
search_url
=
mediawiki
.
base_url
+
\
mediawiki
.
search_url
=
mediawiki
.
base_url
+
\
'w/api.php?action=query'
\
'w/api.php?action=query'
\
...
...
tests/unit/engines/test_qwant.py
View file @
b63d645a
...
@@ -21,11 +21,10 @@ class TestQwantEngine(SearxTestCase):
...
@@ -21,11 +21,10 @@ class TestQwantEngine(SearxTestCase):
self
.
assertIn
(
'qwant.com'
,
params
[
'url'
])
self
.
assertIn
(
'qwant.com'
,
params
[
'url'
])
self
.
assertIn
(
'fr_fr'
,
params
[
'url'
])
self
.
assertIn
(
'fr_fr'
,
params
[
'url'
])
dicto
[
'language'
]
=
'
en-US
'
dicto
[
'language'
]
=
'
all
'
qwant
.
categories
=
[
'news'
]
qwant
.
categories
=
[
'news'
]
params
=
qwant
.
request
(
query
,
dicto
)
params
=
qwant
.
request
(
query
,
dicto
)
self
.
assertFalse
(
'fr'
in
params
[
'url'
])
self
.
assertFalse
(
'fr'
in
params
[
'url'
])
self
.
assertIn
(
'en_us'
,
params
[
'url'
])
self
.
assertIn
(
'news'
,
params
[
'url'
])
self
.
assertIn
(
'news'
,
params
[
'url'
])
dicto
[
'language'
]
=
'fr'
dicto
[
'language'
]
=
'fr'
...
...
tests/unit/engines/test_startpage.py
View file @
b63d645a
...
@@ -21,6 +21,10 @@ class TestStartpageEngine(SearxTestCase):
...
@@ -21,6 +21,10 @@ class TestStartpageEngine(SearxTestCase):
self
.
assertIn
(
'with_language'
,
params
[
'data'
])
self
.
assertIn
(
'with_language'
,
params
[
'data'
])
self
.
assertIn
(
'lang_fr'
,
params
[
'data'
][
'with_language'
])
self
.
assertIn
(
'lang_fr'
,
params
[
'data'
][
'with_language'
])
dicto
[
'language'
]
=
'all'
params
=
startpage
.
request
(
query
,
dicto
)
self
.
assertNotIn
(
'with_language'
,
params
[
'data'
])
def
test_response
(
self
):
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
startpage
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
startpage
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
startpage
.
response
,
[])
self
.
assertRaises
(
AttributeError
,
startpage
.
response
,
[])
...
...
tests/unit/engines/test_subtitleseeker.py
View file @
b63d645a
...
@@ -73,6 +73,42 @@ class TestSubtitleseekerEngine(SearxTestCase):
...
@@ -73,6 +73,42 @@ class TestSubtitleseekerEngine(SearxTestCase):
results
=
subtitleseeker
.
response
(
response
)
results
=
subtitleseeker
.
response
(
response
)
self
.
assertEqual
(
results
[
0
][
'url'
],
'http://this.is.the.url/Brazilian/'
)
self
.
assertEqual
(
results
[
0
][
'url'
],
'http://this.is.the.url/Brazilian/'
)
html
=
"""
<div class="boxRows">
<div class="boxRowsInner" style="width:600px;">
<img src="http://static.subtitleseeker.com/images/movie.gif"
style="width:16px; height:16px;" class="icon">
<a href="http://this.is.the.url/"
class="blue" title="Title subtitle" >
This is the Title
</a>
</div>
<div class="boxRowsInner f12b red" style="width:70px;">
1998
</div>
<div class="boxRowsInner grey-web f12" style="width:120px;">
<img src="http://static.subtitleseeker.com/images/basket_put.png"
style="width:16px; height:16px;" class="icon">
1039 Subs
</div>
<div class="boxRowsInner grey-web f10" style="width:130px;">
<img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
style="width:16px; height:16px;" class="icon">
1 hours ago
</div>
<div class="clear"></div>
</div>
"""
dicto
[
'language'
]
=
'all'
response
=
mock
.
Mock
(
text
=
html
,
search_params
=
dicto
)
results
=
subtitleseeker
.
response
(
response
)
self
.
assertEqual
(
type
(
results
),
list
)
self
.
assertEqual
(
len
(
results
),
1
)
self
.
assertEqual
(
results
[
0
][
'title'
],
'This is the Title'
)
self
.
assertEqual
(
results
[
0
][
'url'
],
'http://this.is.the.url/'
)
self
.
assertIn
(
'1998'
,
results
[
0
][
'content'
])
self
.
assertIn
(
'1039 Subs'
,
results
[
0
][
'content'
])
html
=
"""
html
=
"""
<div class="boxRows">
<div class="boxRows">
<div class="boxRowsInner" style="width:600px;">
<div class="boxRowsInner" style="width:600px;">
...
...
tests/unit/engines/test_swisscows.py
View file @
b63d645a
...
@@ -20,6 +20,11 @@ class TestSwisscowsEngine(SearxTestCase):
...
@@ -20,6 +20,11 @@ class TestSwisscowsEngine(SearxTestCase):
self
.
assertTrue
(
'uiLanguage=de'
in
params
[
'url'
])
self
.
assertTrue
(
'uiLanguage=de'
in
params
[
'url'
])
self
.
assertTrue
(
'region=de-DE'
in
params
[
'url'
])
self
.
assertTrue
(
'region=de-DE'
in
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
swisscows
.
request
(
query
,
dicto
)
self
.
assertTrue
(
'uiLanguage=browser'
in
params
[
'url'
])
self
.
assertTrue
(
'region=browser'
in
params
[
'url'
])
dicto
[
'category'
]
=
'images'
dicto
[
'category'
]
=
'images'
params
=
swisscows
.
request
(
query
,
dicto
)
params
=
swisscows
.
request
(
query
,
dicto
)
self
.
assertIn
(
'image'
,
params
[
'url'
])
self
.
assertIn
(
'image'
,
params
[
'url'
])
...
...
tests/unit/engines/test_twitter.py
View file @
b63d645a
...
@@ -20,6 +20,12 @@ class TestTwitterEngine(SearxTestCase):
...
@@ -20,6 +20,12 @@ class TestTwitterEngine(SearxTestCase):
self
.
assertIn
(
'lang'
,
params
[
'cookies'
])
self
.
assertIn
(
'lang'
,
params
[
'cookies'
])
self
.
assertIn
(
'fr'
,
params
[
'cookies'
][
'lang'
])
self
.
assertIn
(
'fr'
,
params
[
'cookies'
][
'lang'
])
dicto
[
'language'
]
=
'all'
params
=
twitter
.
request
(
query
,
dicto
)
self
.
assertIn
(
'cookies'
,
params
)
self
.
assertIn
(
'lang'
,
params
[
'cookies'
])
self
.
assertIn
(
'en'
,
params
[
'cookies'
][
'lang'
])
def
test_response
(
self
):
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
twitter
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
twitter
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
twitter
.
response
,
[])
self
.
assertRaises
(
AttributeError
,
twitter
.
response
,
[])
...
...
tests/unit/engines/test_wikidata.py
View file @
b63d645a
...
@@ -11,11 +11,13 @@ class TestWikidataEngine(SearxTestCase):
...
@@ -11,11 +11,13 @@ class TestWikidataEngine(SearxTestCase):
def
test_request
(
self
):
def
test_request
(
self
):
query
=
'test_query'
query
=
'test_query'
dicto
=
defaultdict
(
dict
)
dicto
=
defaultdict
(
dict
)
dicto
[
'language'
]
=
'all'
params
=
wikidata
.
request
(
query
,
dicto
)
params
=
wikidata
.
request
(
query
,
dicto
)
self
.
assertIn
(
'url'
,
params
)
self
.
assertIn
(
'url'
,
params
)
self
.
assertIn
(
query
,
params
[
'url'
])
self
.
assertIn
(
query
,
params
[
'url'
])
self
.
assertIn
(
'wikidata.org'
,
params
[
'url'
])
self
.
assertIn
(
'wikidata.org'
,
params
[
'url'
])
dicto
[
'language'
]
=
'es_ES'
params
=
wikidata
.
request
(
query
,
dicto
)
params
=
wikidata
.
request
(
query
,
dicto
)
self
.
assertIn
(
query
,
params
[
'url'
])
self
.
assertIn
(
query
,
params
[
'url'
])
...
...
tests/unit/engines/test_wikipedia.py
View file @
b63d645a
...
@@ -26,9 +26,15 @@ class TestWikipediaEngine(SearxTestCase):
...
@@ -26,9 +26,15 @@ class TestWikipediaEngine(SearxTestCase):
self
.
assertIn
(
'Test_Query'
,
params
[
'url'
])
self
.
assertIn
(
'Test_Query'
,
params
[
'url'
])
self
.
assertNotIn
(
'test_query'
,
params
[
'url'
])
self
.
assertNotIn
(
'test_query'
,
params
[
'url'
])
<<<<<<<
HEAD
dicto
[
'language'
]
=
'nb'
dicto
[
'language'
]
=
'nb'
params
=
wikipedia
.
request
(
query
,
dicto
)
params
=
wikipedia
.
request
(
query
,
dicto
)
self
.
assertIn
(
'no.wikipedia.org'
,
params
[
'url'
])
self
.
assertIn
(
'no.wikipedia.org'
,
params
[
'url'
])
=======
dicto
[
'language'
]
=
'all'
params
=
wikipedia
.
request
(
query
,
dicto
)
self
.
assertIn
(
'en'
,
params
[
'url'
])
>>>>>>>
Revert
"remove 'all' option from search languages"
dicto
[
'language'
]
=
'xx'
dicto
[
'language'
]
=
'xx'
params
=
wikipedia
.
request
(
query
,
dicto
)
params
=
wikipedia
.
request
(
query
,
dicto
)
...
...
tests/unit/engines/test_yacy.py
View file @
b63d645a
...
@@ -17,6 +17,11 @@ class TestYacyEngine(SearxTestCase):
...
@@ -17,6 +17,11 @@ class TestYacyEngine(SearxTestCase):
self
.
assertIn
(
'localhost'
,
params
[
'url'
])
self
.
assertIn
(
'localhost'
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
yacy
.
request
(
query
,
dicto
)
self
.
assertIn
(
'url'
,
params
)
self
.
assertNotIn
(
'lr=lang_'
,
params
[
'url'
])
def
test_response
(
self
):
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
yacy
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
yacy
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
yacy
.
response
,
[])
self
.
assertRaises
(
AttributeError
,
yacy
.
response
,
[])
...
...
tests/unit/engines/test_yahoo.py
View file @
b63d645a
...
@@ -50,6 +50,13 @@ class TestYahooEngine(SearxTestCase):
...
@@ -50,6 +50,13 @@ class TestYahooEngine(SearxTestCase):
self
.
assertIn
(
'zh_cht'
,
params
[
'url'
])
self
.
assertIn
(
'zh_cht'
,
params
[
'url'
])
self
.
assertIn
(
'zh_cht'
,
params
[
'cookies'
][
'sB'
])
self
.
assertIn
(
'zh_cht'
,
params
[
'cookies'
][
'sB'
])
dicto
[
'language'
]
=
'all'
params
=
yahoo
.
request
(
query
,
dicto
)
self
.
assertIn
(
'cookies'
,
params
)
self
.
assertIn
(
'sB'
,
params
[
'cookies'
])
self
.
assertIn
(
'en'
,
params
[
'cookies'
][
'sB'
])
self
.
assertIn
(
'en'
,
params
[
'url'
])
def
test_no_url_in_request_year_time_range
(
self
):
def
test_no_url_in_request_year_time_range
(
self
):
dicto
=
defaultdict
(
dict
)
dicto
=
defaultdict
(
dict
)
query
=
'test_query'
query
=
'test_query'
...
...
tests/unit/engines/test_yahoo_news.py
View file @
b63d645a
...
@@ -23,6 +23,13 @@ class TestYahooNewsEngine(SearxTestCase):
...
@@ -23,6 +23,13 @@ class TestYahooNewsEngine(SearxTestCase):
self
.
assertIn
(
'sB'
,
params
[
'cookies'
])
self
.
assertIn
(
'sB'
,
params
[
'cookies'
])
self
.
assertIn
(
'fr'
,
params
[
'cookies'
][
'sB'
])
self
.
assertIn
(
'fr'
,
params
[
'cookies'
][
'sB'
])
dicto
[
'language'
]
=
'all'
params
=
yahoo_news
.
request
(
query
,
dicto
)
self
.
assertIn
(
'cookies'
,
params
)
self
.
assertIn
(
'sB'
,
params
[
'cookies'
])
self
.
assertIn
(
'en'
,
params
[
'cookies'
][
'sB'
])
self
.
assertIn
(
'en'
,
params
[
'url'
])
def
test_sanitize_url
(
self
):
def
test_sanitize_url
(
self
):
url
=
"test.url"
url
=
"test.url"
self
.
assertEqual
(
url
,
yahoo_news
.
sanitize_url
(
url
))
self
.
assertEqual
(
url
,
yahoo_news
.
sanitize_url
(
url
))
...
...
tests/unit/test_preferences.py
View file @
b63d645a
...
@@ -90,30 +90,25 @@ class TestSettings(SearxTestCase):
...
@@ -90,30 +90,25 @@ class TestSettings(SearxTestCase):
# search language settings
# search language settings
def
test_lang_setting_valid_choice
(
self
):
def
test_lang_setting_valid_choice
(
self
):
setting
=
SearchLanguageSetting
(
'
en'
,
choices
=
[
'de'
,
'en'
])
setting
=
SearchLanguageSetting
(
'
all'
,
choices
=
[
'all'
,
'de'
,
'en'
])
setting
.
parse
(
'de'
)
setting
.
parse
(
'de'
)
self
.
assertEquals
(
setting
.
get_value
(),
'de'
)
self
.
assertEquals
(
setting
.
get_value
(),
'de'
)
def
test_lang_setting_invalid_choice
(
self
):
def
test_lang_setting_invalid_choice
(
self
):
setting
=
SearchLanguageSetting
(
'
en'
,
choices
=
[
'de'
,
'en'
])
setting
=
SearchLanguageSetting
(
'
all'
,
choices
=
[
'all'
,
'de'
,
'en'
])
setting
.
parse
(
'xx'
)
setting
.
parse
(
'xx'
)
self
.
assertEquals
(
setting
.
get_value
(),
'
en
'
)
self
.
assertEquals
(
setting
.
get_value
(),
'
all
'
)
def
test_lang_setting_old_cookie_choice
(
self
):
def
test_lang_setting_old_cookie_choice
(
self
):
setting
=
SearchLanguageSetting
(
'
en'
,
choices
=
[
'en
'
,
'es'
,
'es-ES'
])
setting
=
SearchLanguageSetting
(
'
all'
,
choices
=
[
'all
'
,
'es'
,
'es-ES'
])
setting
.
parse
(
'es_XA'
)
setting
.
parse
(
'es_XA'
)
self
.
assertEquals
(
setting
.
get_value
(),
'es'
)
self
.
assertEquals
(
setting
.
get_value
(),
'es'
)
def
test_lang_setting_old_cookie_format
(
self
):
def
test_lang_setting_old_cookie_format
(
self
):
setting
=
SearchLanguageSetting
(
'
en'
,
choices
=
[
'en
'
,
'es'
,
'es-ES'
])
setting
=
SearchLanguageSetting
(
'
all'
,
choices
=
[
'all
'
,
'es'
,
'es-ES'
])
setting
.
parse
(
'es_ES'
)
setting
.
parse
(
'es_ES'
)
self
.
assertEquals
(
setting
.
get_value
(),
'es-ES'
)
self
.
assertEquals
(
setting
.
get_value
(),
'es-ES'
)
def
test_lang_setting_old_default
(
self
):
setting
=
SearchLanguageSetting
(
'en'
,
choices
=
[
'en'
,
'es'
,
'de'
])
setting
.
parse
(
'all'
)
self
.
assertEquals
(
setting
.
get_value
(),
'en'
)
# plugins settings
# plugins settings
def
test_plugins_setting_all_default_enabled
(
self
):
def
test_plugins_setting_all_default_enabled
(
self
):
plugin1
=
PluginStub
(
'plugin1'
,
True
)
plugin1
=
PluginStub
(
'plugin1'
,
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment