mirror of https://github.com/searxng/searxng.git
Compare commits
6 Commits
494792ff25
...
1b40f118a6
Author | SHA1 | Date |
---|---|---|
Allen | 1b40f118a6 | |
Bnyro | b07c0ae39f | |
Markus Heiser | 56e3d72a76 | |
searxng-bot | cc148a76b0 | |
Markus Heiser | 21dd524a12 | |
Allen | 0476de443e |
|
@ -45,14 +45,6 @@ jobs:
|
|||
make V=1 gecko.driver
|
||||
- name: Run tests
|
||||
run: make V=1 ci.test
|
||||
- name: Test coverage
|
||||
run: make V=1 test.coverage
|
||||
- name: Store coverage result
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-${{ matrix.python-version }}
|
||||
path: coverage/
|
||||
retention-days: 60
|
||||
|
||||
themes:
|
||||
name: Themes
|
||||
|
|
|
@ -34,10 +34,10 @@ Implementations
|
|||
"""
|
||||
|
||||
from typing import List, Dict, Any, Optional
|
||||
from urllib.parse import quote
|
||||
from urllib.parse import urlencode
|
||||
from lxml import html
|
||||
|
||||
from searx.utils import extract_text, eval_xpath, eval_xpath_list
|
||||
from searx.utils import extract_text, eval_xpath, eval_xpath_getindex, eval_xpath_list
|
||||
from searx.enginelib.traits import EngineTraits
|
||||
from searx.data import ENGINE_TRAITS
|
||||
|
||||
|
@ -53,7 +53,7 @@ about: Dict[str, Any] = {
|
|||
|
||||
# engine dependent config
|
||||
categories: List[str] = ["files"]
|
||||
paging: bool = False
|
||||
paging: bool = True
|
||||
|
||||
# search-url
|
||||
base_url: str = "https://annas-archive.org"
|
||||
|
@ -99,9 +99,18 @@ def init(engine_settings=None): # pylint: disable=unused-argument
|
|||
|
||||
|
||||
def request(query, params: Dict[str, Any]) -> Dict[str, Any]:
|
||||
q = quote(query)
|
||||
lang = traits.get_language(params["language"], traits.all_locale) # type: ignore
|
||||
params["url"] = base_url + f"/search?lang={lang or ''}&content={aa_content}&ext={aa_ext}&sort={aa_sort}&q={q}"
|
||||
args = {
|
||||
'lang': lang,
|
||||
'content': aa_content,
|
||||
'ext': aa_ext,
|
||||
'sort': aa_sort,
|
||||
'q': query,
|
||||
'page': params['pageno'],
|
||||
}
|
||||
# filter out None and empty values
|
||||
filtered_args = dict((k, v) for k, v in args.items() if v)
|
||||
params["url"] = f"{base_url}/search?{urlencode(filtered_args)}"
|
||||
return params
|
||||
|
||||
|
||||
|
@ -128,12 +137,12 @@ def response(resp) -> List[Dict[str, Optional[str]]]:
|
|||
def _get_result(item):
|
||||
return {
|
||||
'template': 'paper.html',
|
||||
'url': base_url + item.xpath('./@href')[0],
|
||||
'url': base_url + extract_text(eval_xpath_getindex(item, './@href', 0)),
|
||||
'title': extract_text(eval_xpath(item, './/h3/text()[1]')),
|
||||
'publisher': extract_text(eval_xpath(item, './/div[contains(@class, "text-sm")]')),
|
||||
'authors': [extract_text(eval_xpath(item, './/div[contains(@class, "italic")]'))],
|
||||
'content': extract_text(eval_xpath(item, './/div[contains(@class, "text-xs")]')),
|
||||
'thumbnail': item.xpath('.//img/@src')[0],
|
||||
'thumbnail': extract_text(eval_xpath_getindex(item, './/img/@src', 0, default=None), allow_none=True),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ from searx import logger
|
|||
from searx.engines import engines
|
||||
from searx.metrics import histogram_observe, counter_add, count_error
|
||||
|
||||
|
||||
CONTENT_LEN_IGNORED_CHARS_REGEX = re.compile(r'[,;:!?\./\\\\ ()-_]', re.M | re.U)
|
||||
WHITESPACE_REGEX = re.compile('( |\t|\n)+', re.M | re.U)
|
||||
|
||||
|
@ -133,7 +132,7 @@ def result_score(result, priority):
|
|||
weight = 1.0
|
||||
|
||||
for result_engine in result['engines']:
|
||||
if hasattr(engines[result_engine], 'weight'):
|
||||
if hasattr(engines.get(result_engine), 'weight'):
|
||||
weight *= float(engines[result_engine].weight)
|
||||
|
||||
weight *= len(result['positions'])
|
||||
|
@ -332,10 +331,14 @@ class ResultContainer:
|
|||
return None
|
||||
|
||||
def __merge_duplicated_http_result(self, duplicated, result, position):
|
||||
# using content with more text
|
||||
# use content with more text
|
||||
if result_content_len(result.get('content', '')) > result_content_len(duplicated.get('content', '')):
|
||||
duplicated['content'] = result['content']
|
||||
|
||||
# use title with more text
|
||||
if result_content_len(result.get('title', '')) > len(duplicated.get('title', '')):
|
||||
duplicated['title'] = result['title']
|
||||
|
||||
# merge all result's parameters not found in duplicate
|
||||
for key in result.keys():
|
||||
if not duplicated.get(key):
|
||||
|
@ -347,7 +350,7 @@ class ResultContainer:
|
|||
# add engine to list of result-engines
|
||||
duplicated['engines'].add(result['engine'])
|
||||
|
||||
# using https if possible
|
||||
# use https if possible
|
||||
if duplicated['parsed_url'].scheme != 'https' and result['parsed_url'].scheme == 'https':
|
||||
duplicated['url'] = result['parsed_url'].geturl()
|
||||
duplicated['parsed_url'] = result['parsed_url']
|
||||
|
|
Binary file not shown.
|
@ -39,7 +39,7 @@ msgstr ""
|
|||
"Project-Id-Version: searx\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||
"PO-Revision-Date: 2024-10-06 14:31+0000\n"
|
||||
"PO-Revision-Date: 2024-10-26 21:13+0000\n"
|
||||
"Last-Translator: Atul_Eterno <Atul_Eterno@users.noreply.translate.codeberg."
|
||||
"org>\n"
|
||||
"Language-Team: Spanish <https://translate.codeberg.org/projects/searxng/"
|
||||
|
@ -49,7 +49,7 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 5.7.2\n"
|
||||
"X-Generator: Weblate 5.8.1\n"
|
||||
"Generated-By: Babel 2.16.0\n"
|
||||
|
||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||
|
@ -155,7 +155,7 @@ msgstr "preguntas y respuestas"
|
|||
#. CATEGORY_GROUPS['REPOS']
|
||||
#: searx/searxng.msg
|
||||
msgid "repos"
|
||||
msgstr "repos"
|
||||
msgstr "repositorios"
|
||||
|
||||
#. CATEGORY_GROUPS['SOFTWARE_WIKIS']
|
||||
#: searx/searxng.msg
|
||||
|
|
Binary file not shown.
|
@ -22,13 +22,14 @@
|
|||
# MVDW-Java <MVDW-Java@users.noreply.translate.codeberg.org>, 2024.
|
||||
# notlmutsaers <notlmutsaers@users.noreply.translate.codeberg.org>, 2024.
|
||||
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
|
||||
# ljansen <ljansen@users.noreply.translate.codeberg.org>, 2024.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: searx\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||
"PO-Revision-Date: 2024-10-15 12:18+0000\n"
|
||||
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
|
||||
"PO-Revision-Date: 2024-10-28 21:07+0000\n"
|
||||
"Last-Translator: ljansen <ljansen@users.noreply.translate.codeberg.org>\n"
|
||||
"Language-Team: Dutch <https://translate.codeberg.org/projects/searxng/"
|
||||
"searxng/nl/>\n"
|
||||
"Language: nl\n"
|
||||
|
@ -36,7 +37,7 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 5.7.2\n"
|
||||
"X-Generator: Weblate 5.8.1\n"
|
||||
"Generated-By: Babel 2.16.0\n"
|
||||
|
||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||
|
@ -464,7 +465,7 @@ msgstr "Bereken {functions} van de opties"
|
|||
|
||||
#: searx/engines/mozhi.py:57
|
||||
msgid "Synonyms"
|
||||
msgstr ""
|
||||
msgstr "Synoniemen"
|
||||
|
||||
#: searx/engines/openstreetmap.py:159
|
||||
msgid "Get directions"
|
||||
|
@ -1234,12 +1235,13 @@ msgid "Max time"
|
|||
msgstr "Max. duur"
|
||||
|
||||
#: searx/templates/simple/preferences/favicon.html:2
|
||||
#, fuzzy
|
||||
msgid "Favicon Resolver"
|
||||
msgstr ""
|
||||
msgstr "favicon-resolver"
|
||||
|
||||
#: searx/templates/simple/preferences/favicon.html:15
|
||||
msgid "Display favicons near search results"
|
||||
msgstr ""
|
||||
msgstr "Vertoon zoekresultaten naast favicons"
|
||||
|
||||
#: searx/templates/simple/preferences/footer.html:2
|
||||
msgid ""
|
||||
|
|
Binary file not shown.
|
@ -23,8 +23,8 @@ msgstr ""
|
|||
"Project-Id-Version: searx\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||
"PO-Revision-Date: 2024-10-15 12:18+0000\n"
|
||||
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
|
||||
"PO-Revision-Date: 2024-10-28 21:07+0000\n"
|
||||
"Last-Translator: Eryk Michalak <gnu.ewm@protonmail.com>\n"
|
||||
"Language-Team: Polish <https://translate.codeberg.org/projects/searxng/"
|
||||
"searxng/pl/>\n"
|
||||
"Language: pl\n"
|
||||
|
@ -34,7 +34,7 @@ msgstr ""
|
|||
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && ("
|
||||
"n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && "
|
||||
"n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n"
|
||||
"X-Generator: Weblate 5.7.2\n"
|
||||
"X-Generator: Weblate 5.8.1\n"
|
||||
"Generated-By: Babel 2.16.0\n"
|
||||
|
||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||
|
@ -1230,7 +1230,7 @@ msgstr "Maksymalny czas"
|
|||
|
||||
#: searx/templates/simple/preferences/favicon.html:2
|
||||
msgid "Favicon Resolver"
|
||||
msgstr ""
|
||||
msgstr "Pobieranie favikony"
|
||||
|
||||
#: searx/templates/simple/preferences/favicon.html:15
|
||||
msgid "Display favicons near search results"
|
||||
|
|
Binary file not shown.
|
@ -19,13 +19,14 @@
|
|||
# gvlx <gvlx@users.noreply.translate.codeberg.org>, 2024.
|
||||
# ds451 <ds451@users.noreply.translate.codeberg.org>, 2024.
|
||||
# Pedro_Tresp <Pedro_Tresp@users.noreply.translate.codeberg.org>, 2024.
|
||||
# saltsnorter <saltsnorter@users.noreply.translate.codeberg.org>, 2024.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: searx\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||
"PO-Revision-Date: 2024-10-13 23:26+0000\n"
|
||||
"Last-Translator: Pedro_Tresp <Pedro_Tresp@users.noreply.translate.codeberg."
|
||||
"PO-Revision-Date: 2024-10-29 05:54+0000\n"
|
||||
"Last-Translator: saltsnorter <saltsnorter@users.noreply.translate.codeberg."
|
||||
"org>\n"
|
||||
"Language-Team: Portuguese <https://translate.codeberg.org/projects/searxng/"
|
||||
"searxng/pt/>\n"
|
||||
|
@ -34,7 +35,7 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Weblate 5.7.2\n"
|
||||
"X-Generator: Weblate 5.8.1\n"
|
||||
"Generated-By: Babel 2.16.0\n"
|
||||
|
||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||
|
@ -175,7 +176,7 @@ msgstr "escuro"
|
|||
#. STYLE_NAMES['BLACK']
|
||||
#: searx/searxng.msg
|
||||
msgid "black"
|
||||
msgstr ""
|
||||
msgstr "preto"
|
||||
|
||||
#. BRAND_CUSTOM_LINKS['UPTIME']
|
||||
#: searx/searxng.msg
|
||||
|
@ -1228,11 +1229,11 @@ msgstr "Tempo máximo"
|
|||
|
||||
#: searx/templates/simple/preferences/favicon.html:2
|
||||
msgid "Favicon Resolver"
|
||||
msgstr ""
|
||||
msgstr "Solucionador do Favicon"
|
||||
|
||||
#: searx/templates/simple/preferences/favicon.html:15
|
||||
msgid "Display favicons near search results"
|
||||
msgstr ""
|
||||
msgstr "Monstra os favicons nos proximos os resultados"
|
||||
|
||||
#: searx/templates/simple/preferences/footer.html:2
|
||||
msgid ""
|
||||
|
|
Binary file not shown.
|
@ -30,13 +30,14 @@
|
|||
# Pyrbor <Pyrbor@users.noreply.translate.codeberg.org>, 2024.
|
||||
# rodgui <rodgui@users.noreply.translate.codeberg.org>, 2024.
|
||||
# rafablog77 <rafablog77@users.noreply.translate.codeberg.org>, 2024.
|
||||
# Juno Takano <jutty@users.noreply.translate.codeberg.org>, 2024.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: searx\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||
"PO-Revision-Date: 2024-10-15 12:18+0000\n"
|
||||
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
|
||||
"PO-Revision-Date: 2024-10-31 12:16+0000\n"
|
||||
"Last-Translator: Juno Takano <jutty@users.noreply.translate.codeberg.org>\n"
|
||||
"Language-Team: Portuguese (Brazil) <https://translate.codeberg.org/projects/"
|
||||
"searxng/searxng/pt_BR/>\n"
|
||||
"Language: pt_BR\n"
|
||||
|
@ -44,7 +45,7 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Generator: Weblate 5.7.2\n"
|
||||
"X-Generator: Weblate 5.8.1\n"
|
||||
"Generated-By: Babel 2.16.0\n"
|
||||
|
||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||
|
@ -185,7 +186,7 @@ msgstr "escuro"
|
|||
#. STYLE_NAMES['BLACK']
|
||||
#: searx/searxng.msg
|
||||
msgid "black"
|
||||
msgstr ""
|
||||
msgstr "preto"
|
||||
|
||||
#. BRAND_CUSTOM_LINKS['UPTIME']
|
||||
#: searx/searxng.msg
|
||||
|
@ -472,7 +473,7 @@ msgstr "Computar {functions} dos argumentos"
|
|||
|
||||
#: searx/engines/mozhi.py:57
|
||||
msgid "Synonyms"
|
||||
msgstr ""
|
||||
msgstr "Sinônimos"
|
||||
|
||||
#: searx/engines/openstreetmap.py:159
|
||||
msgid "Get directions"
|
||||
|
@ -1243,7 +1244,7 @@ msgstr "Tempo máximo"
|
|||
|
||||
#: searx/templates/simple/preferences/favicon.html:2
|
||||
msgid "Favicon Resolver"
|
||||
msgstr ""
|
||||
msgstr "Resolvedor de Favicons"
|
||||
|
||||
#: searx/templates/simple/preferences/favicon.html:15
|
||||
msgid "Display favicons near search results"
|
||||
|
|
Binary file not shown.
|
@ -12,19 +12,19 @@
|
|||
# tvminh19 <tvminh19@users.noreply.translate.codeberg.org>, 2024.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: searx\n"
|
||||
"Project-Id-Version: searx\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||
"PO-Revision-Date: 2024-08-07 01:02+0000\n"
|
||||
"Last-Translator: tvminh19 <tvminh19@users.noreply.translate.codeberg.org>"
|
||||
"\n"
|
||||
"PO-Revision-Date: 2024-10-26 21:13+0000\n"
|
||||
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
|
||||
"Language-Team: Vietnamese <https://translate.codeberg.org/projects/searxng/"
|
||||
"searxng/vi/>\n"
|
||||
"Language: vi\n"
|
||||
"Language-Team: Vietnamese "
|
||||
"<https://translate.codeberg.org/projects/searxng/searxng/vi/>\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Weblate 5.8.1\n"
|
||||
"Generated-By: Babel 2.16.0\n"
|
||||
|
||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||
|
@ -186,7 +186,7 @@ msgstr "Nhiệt độ trung bình."
|
|||
#. WEATHER_TERMS['CLOUD COVER']
|
||||
#: searx/engines/open_meteo.py:91 searx/searxng.msg
|
||||
msgid "Cloud cover"
|
||||
msgstr ""
|
||||
msgstr "Mây che phủ"
|
||||
|
||||
#. WEATHER_TERMS['CONDITION']
|
||||
#: searx/engines/duckduckgo_weather.py:45 searx/engines/wttr.py:51
|
||||
|
@ -283,7 +283,7 @@ msgstr ""
|
|||
#: searx/engines/duckduckgo_weather.py:58 searx/engines/open_meteo.py:86
|
||||
#: searx/engines/wttr.py:62 searx/searxng.msg
|
||||
msgid "Wind"
|
||||
msgstr ""
|
||||
msgstr "Gió"
|
||||
|
||||
#. SOCIAL_MEDIA_TERMS['SUBSCRIBERS']
|
||||
#: searx/engines/lemmy.py:85 searx/searxng.msg
|
||||
|
@ -1990,4 +1990,3 @@ msgstr "ẩn phim"
|
|||
|
||||
#~ msgid "Engines cannot retrieve results"
|
||||
#~ msgstr "Các trình tìm kiếm không nhận được kết quả"
|
||||
|
||||
|
|
Binary file not shown.
|
@ -28,18 +28,19 @@
|
|||
# hugoalh <hugoalh@users.noreply.translate.codeberg.org>, 2024.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: searx\n"
|
||||
"Project-Id-Version: searx\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||
"PO-Revision-Date: 2024-08-12 04:00+0000\n"
|
||||
"Last-Translator: hugoalh <hugoalh@users.noreply.translate.codeberg.org>\n"
|
||||
"PO-Revision-Date: 2024-10-26 21:13+0000\n"
|
||||
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
|
||||
"Language-Team: Chinese (Traditional Han script) <https://translate.codeberg."
|
||||
"org/projects/searxng/searxng/zh_Hant/>\n"
|
||||
"Language: zh_Hant_TW\n"
|
||||
"Language-Team: Chinese (Traditional) "
|
||||
"<https://translate.codeberg.org/projects/searxng/searxng/zh_Hant/>\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Weblate 5.8.1\n"
|
||||
"Generated-By: Babel 2.16.0\n"
|
||||
|
||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||
|
@ -180,7 +181,7 @@ msgstr "黑暗"
|
|||
#. STYLE_NAMES['BLACK']
|
||||
#: searx/searxng.msg
|
||||
msgid "black"
|
||||
msgstr ""
|
||||
msgstr "黑色"
|
||||
|
||||
#. BRAND_CUSTOM_LINKS['UPTIME']
|
||||
#: searx/searxng.msg
|
||||
|
@ -467,7 +468,7 @@ msgstr "計算 {functions} 參數"
|
|||
|
||||
#: searx/engines/mozhi.py:57
|
||||
msgid "Synonyms"
|
||||
msgstr ""
|
||||
msgstr "同義詞"
|
||||
|
||||
#: searx/engines/openstreetmap.py:159
|
||||
msgid "Get directions"
|
||||
|
@ -942,7 +943,7 @@ msgstr "來自搜尋引擎的訊息"
|
|||
|
||||
#: searx/templates/simple/elements/engines_msg.html:7
|
||||
msgid "seconds"
|
||||
msgstr ""
|
||||
msgstr "秒"
|
||||
|
||||
#: searx/templates/simple/elements/search_url.html:3
|
||||
msgid "Search URL"
|
||||
|
@ -1206,11 +1207,11 @@ msgstr "最大時間"
|
|||
|
||||
#: searx/templates/simple/preferences/favicon.html:2
|
||||
msgid "Favicon Resolver"
|
||||
msgstr ""
|
||||
msgstr "網站圖標搜索器"
|
||||
|
||||
#: searx/templates/simple/preferences/favicon.html:15
|
||||
msgid "Display favicons near search results"
|
||||
msgstr ""
|
||||
msgstr "在搜尋結果旁顯示網站圖標"
|
||||
|
||||
#: searx/templates/simple/preferences/footer.html:2
|
||||
msgid ""
|
||||
|
@ -1911,4 +1912,3 @@ msgstr "隱藏影片"
|
|||
|
||||
#~ msgid "Engines cannot retrieve results"
|
||||
#~ msgstr "引擎無法擷取結果"
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
from searx.search import SearchQuery, EngineRef
|
||||
from searx.search.processors import online
|
||||
from searx.engines import load_engines
|
||||
import searx.search
|
||||
from searx import engines
|
||||
|
||||
from tests import SearxTestCase
|
||||
|
@ -22,10 +22,10 @@ TEST_ENGINE = {
|
|||
class TestOnlineProcessor(SearxTestCase): # pylint: disable=missing-class-docstring
|
||||
|
||||
def setUp(self):
|
||||
load_engines([TEST_ENGINE])
|
||||
searx.search.initialize([TEST_ENGINE])
|
||||
|
||||
def tearDown(self):
|
||||
load_engines([])
|
||||
searx.search.load_engines([])
|
||||
|
||||
def _get_params(self, online_processor, search_query, engine_category):
|
||||
params = online_processor.get_params(search_query, engine_category)
|
||||
|
|
|
@ -2,26 +2,11 @@
|
|||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from unittest.mock import MagicMock, Mock
|
||||
from searx.engines import load_engines, mariadb_server
|
||||
from searx.engines import mariadb_server
|
||||
from tests import SearxTestCase
|
||||
|
||||
|
||||
class MariadbServerTests(SearxTestCase): # pylint: disable=missing-class-docstring
|
||||
def setUp(self):
|
||||
load_engines(
|
||||
[
|
||||
{
|
||||
'name': 'mariadb server',
|
||||
'engine': 'mariadb_server',
|
||||
'shortcut': 'mdb',
|
||||
'timeout': 9.0,
|
||||
'disabled': True,
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
load_engines([])
|
||||
|
||||
def test_init_no_query_str_raises(self):
|
||||
self.assertRaises(ValueError, lambda: mariadb_server.init({}))
|
||||
|
|
|
@ -1,28 +1,34 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# pylint: disable=missing-module-docstring
|
||||
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from unittest.mock import Mock
|
||||
from requests import HTTPError
|
||||
from parameterized import parameterized
|
||||
from searx.engines import load_engines, tineye
|
||||
import searx.search
|
||||
import searx.engines
|
||||
from tests import SearxTestCase
|
||||
|
||||
|
||||
class TinEyeTests(SearxTestCase): # pylint: disable=missing-class-docstring
|
||||
|
||||
def setUp(self):
|
||||
load_engines([{'name': 'tineye', 'engine': 'tineye', 'shortcut': 'tin', 'timeout': 9.0, 'disabled': True}])
|
||||
searx.search.initialize(
|
||||
[{'name': 'tineye', 'engine': 'tineye', 'shortcut': 'tin', 'timeout': 9.0, 'disabled': True}]
|
||||
)
|
||||
|
||||
self.tineye = searx.engines.engines['tineye']
|
||||
self.tineye.logger.setLevel(logging.CRITICAL)
|
||||
|
||||
def tearDown(self):
|
||||
load_engines([])
|
||||
searx.search.load_engines([])
|
||||
|
||||
def test_status_code_raises(self):
|
||||
response = Mock()
|
||||
response.status_code = 401
|
||||
response.raise_for_status.side_effect = HTTPError()
|
||||
self.assertRaises(HTTPError, lambda: tineye.response(response))
|
||||
self.assertRaises(HTTPError, lambda: self.tineye.response(response))
|
||||
|
||||
@parameterized.expand([(400), (422)])
|
||||
def test_returns_empty_list(self, status_code):
|
||||
|
@ -30,7 +36,7 @@ class TinEyeTests(SearxTestCase): # pylint: disable=missing-class-docstring
|
|||
response.json.return_value = {}
|
||||
response.status_code = status_code
|
||||
response.raise_for_status.side_effect = HTTPError()
|
||||
results = tineye.response(response)
|
||||
results = self.tineye.response(response)
|
||||
self.assertEqual(0, len(results))
|
||||
|
||||
def test_logs_format_for_422(self):
|
||||
|
@ -39,9 +45,9 @@ class TinEyeTests(SearxTestCase): # pylint: disable=missing-class-docstring
|
|||
response.status_code = 422
|
||||
response.raise_for_status.side_effect = HTTPError()
|
||||
|
||||
with self.assertLogs(tineye.logger) as assert_logs_context:
|
||||
tineye.response(response)
|
||||
self.assertIn(tineye.FORMAT_NOT_SUPPORTED, ','.join(assert_logs_context.output))
|
||||
with self.assertLogs(self.tineye.logger) as assert_logs_context:
|
||||
self.tineye.response(response)
|
||||
self.assertIn(self.tineye.FORMAT_NOT_SUPPORTED, ','.join(assert_logs_context.output))
|
||||
|
||||
def test_logs_signature_for_422(self):
|
||||
response = Mock()
|
||||
|
@ -49,9 +55,9 @@ class TinEyeTests(SearxTestCase): # pylint: disable=missing-class-docstring
|
|||
response.status_code = 422
|
||||
response.raise_for_status.side_effect = HTTPError()
|
||||
|
||||
with self.assertLogs(tineye.logger) as assert_logs_context:
|
||||
tineye.response(response)
|
||||
self.assertIn(tineye.NO_SIGNATURE_ERROR, ','.join(assert_logs_context.output))
|
||||
with self.assertLogs(self.tineye.logger) as assert_logs_context:
|
||||
self.tineye.response(response)
|
||||
self.assertIn(self.tineye.NO_SIGNATURE_ERROR, ','.join(assert_logs_context.output))
|
||||
|
||||
def test_logs_download_for_422(self):
|
||||
response = Mock()
|
||||
|
@ -59,9 +65,9 @@ class TinEyeTests(SearxTestCase): # pylint: disable=missing-class-docstring
|
|||
response.status_code = 422
|
||||
response.raise_for_status.side_effect = HTTPError()
|
||||
|
||||
with self.assertLogs(tineye.logger) as assert_logs_context:
|
||||
tineye.response(response)
|
||||
self.assertIn(tineye.DOWNLOAD_ERROR, ','.join(assert_logs_context.output))
|
||||
with self.assertLogs(self.tineye.logger) as assert_logs_context:
|
||||
self.tineye.response(response)
|
||||
self.assertIn(self.tineye.DOWNLOAD_ERROR, ','.join(assert_logs_context.output))
|
||||
|
||||
def test_logs_description_for_400(self):
|
||||
description = 'There was a problem with that request. Error ID: ad5fc955-a934-43c1-8187-f9a61d301645'
|
||||
|
@ -70,8 +76,8 @@ class TinEyeTests(SearxTestCase): # pylint: disable=missing-class-docstring
|
|||
response.status_code = 400
|
||||
response.raise_for_status.side_effect = HTTPError()
|
||||
|
||||
with self.assertLogs(tineye.logger) as assert_logs_context:
|
||||
tineye.response(response)
|
||||
with self.assertLogs(self.tineye.logger) as assert_logs_context:
|
||||
self.tineye.response(response)
|
||||
self.assertIn(description, ','.join(assert_logs_context.output))
|
||||
|
||||
def test_crawl_date_parses(self):
|
||||
|
@ -90,5 +96,5 @@ class TinEyeTests(SearxTestCase): # pylint: disable=missing-class-docstring
|
|||
]
|
||||
}
|
||||
response.status_code = 200
|
||||
results = tineye.response(response)
|
||||
results = self.tineye.response(response)
|
||||
self.assertEqual(date, results[0]['publishedDate'])
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from parameterized.parameterized import parameterized
|
||||
from searx.engines import load_engines
|
||||
import searx.search
|
||||
from searx.query import RawTextQuery
|
||||
from tests import SearxTestCase
|
||||
|
||||
|
@ -218,10 +218,10 @@ class TestBang(SearxTestCase): # pylint:disable=missing-class-docstring
|
|||
THE_QUERY = 'the query'
|
||||
|
||||
def setUp(self):
|
||||
load_engines(TEST_ENGINES)
|
||||
searx.search.initialize(TEST_ENGINES)
|
||||
|
||||
def tearDown(self):
|
||||
load_engines([])
|
||||
searx.search.load_engines([])
|
||||
|
||||
@parameterized.expand(SPECIFIC_BANGS)
|
||||
def test_bang(self, bang: str):
|
||||
|
|
|
@ -2,9 +2,26 @@
|
|||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from searx.results import ResultContainer
|
||||
import searx.search
|
||||
from tests import SearxTestCase
|
||||
|
||||
|
||||
def make_test_engine_dict(**kwargs) -> dict:
|
||||
test_engine = {
|
||||
# fmt: off
|
||||
'name': None,
|
||||
'engine': None,
|
||||
'categories': 'general',
|
||||
'shortcut': 'dummy',
|
||||
'timeout': 3.0,
|
||||
'tokens': [],
|
||||
# fmt: on
|
||||
}
|
||||
|
||||
test_engine.update(**kwargs)
|
||||
return test_engine
|
||||
|
||||
|
||||
def fake_result(url='https://aa.bb/cc?dd=ee#ff', title='aaa', content='bbb', engine='wikipedia', **kwargs):
|
||||
result = {
|
||||
# fmt: off
|
||||
|
@ -19,23 +36,40 @@ def fake_result(url='https://aa.bb/cc?dd=ee#ff', title='aaa', content='bbb', eng
|
|||
|
||||
|
||||
class ResultContainerTestCase(SearxTestCase): # pylint: disable=missing-class-docstring
|
||||
|
||||
def setUp(self) -> None:
|
||||
stract_engine = make_test_engine_dict(name="stract", engine="stract", shortcut="stra")
|
||||
duckduckgo_engine = make_test_engine_dict(name="duckduckgo", engine="duckduckgo", shortcut="ddg")
|
||||
mojeek_engine = make_test_engine_dict(name="mojeek", engine="mojeek", shortcut="mjk")
|
||||
searx.search.initialize([stract_engine, duckduckgo_engine, mojeek_engine])
|
||||
self.container = ResultContainer()
|
||||
|
||||
def tearDown(self):
|
||||
searx.search.load_engines([])
|
||||
|
||||
def test_empty(self):
|
||||
c = ResultContainer()
|
||||
self.assertEqual(c.get_ordered_results(), [])
|
||||
self.assertEqual(self.container.get_ordered_results(), [])
|
||||
|
||||
def test_one_result(self):
|
||||
c = ResultContainer()
|
||||
c.extend('wikipedia', [fake_result()])
|
||||
self.assertEqual(c.results_length(), 1)
|
||||
self.container.extend('wikipedia', [fake_result()])
|
||||
|
||||
self.assertEqual(self.container.results_length(), 1)
|
||||
|
||||
def test_one_suggestion(self):
|
||||
c = ResultContainer()
|
||||
c.extend('wikipedia', [fake_result(suggestion=True)])
|
||||
self.assertEqual(len(c.suggestions), 1)
|
||||
self.assertEqual(c.results_length(), 0)
|
||||
self.container.extend('wikipedia', [fake_result(suggestion=True)])
|
||||
|
||||
self.assertEqual(len(self.container.suggestions), 1)
|
||||
self.assertEqual(self.container.results_length(), 0)
|
||||
|
||||
def test_result_merge(self):
|
||||
c = ResultContainer()
|
||||
c.extend('wikipedia', [fake_result()])
|
||||
c.extend('wikidata', [fake_result(), fake_result(url='https://example.com/')])
|
||||
self.assertEqual(c.results_length(), 2)
|
||||
self.container.extend('wikipedia', [fake_result()])
|
||||
self.container.extend('wikidata', [fake_result(), fake_result(url='https://example.com/')])
|
||||
|
||||
self.assertEqual(self.container.results_length(), 2)
|
||||
|
||||
def test_result_merge_by_title(self):
|
||||
self.container.extend('stract', [fake_result(engine='stract', title='short title')])
|
||||
self.container.extend('duckduckgo', [fake_result(engine='duckduckgo', title='normal title')])
|
||||
self.container.extend('mojeek', [fake_result(engine='mojeek', title='this long long title')])
|
||||
|
||||
self.assertEqual(self.container.get_ordered_results()[0].get('title', ''), 'this long long title')
|
||||
|
|
Loading…
Reference in New Issue