.oO SearXNG Developer Documentation Oo.
|
Functions | |
_load_regular_expressions (settings_key) | |
_matches_parsed_url (result, pattern) | |
on_result (_request, _search, result) | |
Variables | |
name = gettext('Hostnames plugin') | |
description = gettext('Rewrite hostnames, remove results or prioritize them based on the hostname') | |
bool | default_on = False |
str | preference_section = 'general' |
str | plugin_id = 'hostnames' |
logger = logger.getChild(plugin_id) | |
str | parsed = 'parsed_url' |
list | _url_fields = ['iframe_src', 'audio_src'] |
replacements = _load_regular_expressions('replace') | |
removables = _load_regular_expressions('remove') | |
high_priority = _load_regular_expressions('high_priority') | |
low_priority = _load_regular_expressions('low_priority') | |
.. attention:: The **"Hostname replace"** plugin has been replace by **"Hostnames plugin"**, see :pull:`3463` & :pull:`3552`. The **Hostnames plugin** can be enabled by adding it to the ``enabled_plugins`` **list** in the ``setting.yml`` like so. .. code:: yaml enabled_plugins: - 'Hostnames plugin' ... - ``hostnames.replace``: A **mapping** of regular expressions to hostnames to be replaced by other hostnames. .. code:: yaml hostnames: replace: '(.*\\.)?youtube\\.com$': 'invidious.example.com' '(.*\\.)?youtu\\.be$': 'invidious.example.com' ... - ``hostnames.remove``: A **list** of regular expressions of the hostnames whose results should be taken from the results list. .. code:: yaml hostnames: remove: - '(.*\\.)?facebook.com$' - ... - ``hostnames.high_priority``: A **list** of regular expressions for hostnames whose result should be given higher priority. The results from these hosts are arranged higher in the results list. .. code:: yaml hostnames: high_priority: - '(.*\\.)?wikipedia.org$' - ... - ``hostnames.lower_priority``: A **list** of regular expressions for hostnames whose result should be given lower priority. The results from these hosts are arranged lower in the results list. .. code:: yaml hostnames: low_priority: - '(.*\\.)?google(\\..*)?$' - ... If the URL matches the pattern of ``high_priority`` AND ``low_priority``, the higher priority wins over the lower priority. Alternatively, you can also specify a file name for the **mappings** or **lists** to load these from an external file: .. code:: yaml hostnames: replace: 'rewrite-hosts.yml' remove: - '(.*\\.)?facebook.com$' - ... low_priority: - '(.*\\.)?google(\\..*)?$' - ... high_priority: - '(.*\\.)?wikipedia.org$' - ... The ``rewrite-hosts.yml`` from the example above must be in the folder in which the ``settings.yml`` file is already located (``/etc/searxng``). The file then only contains the lists or the mapping tables without further information on the namespaces. In the example above, this would be a mapping table that looks something like this: .. code:: yaml '(.*\\.)?youtube\\.com$': 'invidious.example.com' '(.*\\.)?youtu\\.be$': 'invidious.example.com'
|
protected |
Definition at line 115 of file hostnames.py.
|
protected |
Definition at line 140 of file hostnames.py.
Referenced by searx.plugins.hostnames.on_result().
searx.plugins.hostnames.on_result | ( | _request, | |
_search, | |||
result ) |
Definition at line 144 of file hostnames.py.
References searx.plugins.hostnames._matches_parsed_url().
|
protected |
Definition at line 112 of file hostnames.py.
bool searx.plugins.hostnames.default_on = False |
Definition at line 105 of file hostnames.py.
searx.plugins.hostnames.description = gettext('Rewrite hostnames, remove results or prioritize them based on the hostname') |
Definition at line 104 of file hostnames.py.
searx.plugins.hostnames.high_priority = _load_regular_expressions('high_priority') |
Definition at line 136 of file hostnames.py.
searx.plugins.hostnames.logger = logger.getChild(plugin_id) |
Definition at line 110 of file hostnames.py.
searx.plugins.hostnames.low_priority = _load_regular_expressions('low_priority') |
Definition at line 137 of file hostnames.py.
searx.plugins.hostnames.name = gettext('Hostnames plugin') |
Definition at line 103 of file hostnames.py.
str searx.plugins.hostnames.parsed = 'parsed_url' |
Definition at line 111 of file hostnames.py.
str searx.plugins.hostnames.plugin_id = 'hostnames' |
Definition at line 108 of file hostnames.py.
str searx.plugins.hostnames.preference_section = 'general' |
Definition at line 106 of file hostnames.py.
searx.plugins.hostnames.removables = _load_regular_expressions('remove') |
Definition at line 135 of file hostnames.py.
searx.plugins.hostnames.replacements = _load_regular_expressions('replace') |
Definition at line 134 of file hostnames.py.