mirror of
https://github.com/searxng/searxng.git
synced 2026-07-25 01:11:24 +00:00
Compare commits
2 Commits
cce0957f54
...
952896d29e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
952896d29e | ||
|
|
4cc32b2457 |
@@ -14,6 +14,7 @@ template.
|
||||
# pylint: disable=too-few-public-methods
|
||||
__all__ = ["Image", "ImageRef"]
|
||||
|
||||
import mimetypes
|
||||
import types
|
||||
import typing as t
|
||||
from collections.abc import Callable
|
||||
@@ -71,7 +72,7 @@ class Image(MainResult, kw_only=True):
|
||||
"""The resolution of the image (e.g. ``1920 x 1080`` pixel)"""
|
||||
|
||||
img_format: str = ""
|
||||
"""The format of the image (e.g. ``png``)."""
|
||||
"""The format of the image :py:obj:`.MainResult.img_src` (e.g. ``png``)."""
|
||||
|
||||
source: str = ""
|
||||
"""Source of the image."""
|
||||
@@ -83,6 +84,19 @@ class Image(MainResult, kw_only=True):
|
||||
formats: list[ImageRef] = []
|
||||
"""List of links to alternative image formats."""
|
||||
|
||||
def __post_init__(self):
|
||||
super().__post_init__()
|
||||
|
||||
if not self.img_format:
|
||||
# automatically guess the image format based on the path of the image
|
||||
mimetype = mimetypes.guess_type(self.img_src)[0]
|
||||
if mimetype:
|
||||
subtype = mimetype.split("/")[-1]
|
||||
if subtype in MIMESUB:
|
||||
self.img_format = MIMESUB[subtype]
|
||||
else:
|
||||
self.img_format = subtype.upper()
|
||||
|
||||
def filter_urls(self, filter_func: "Callable[[Result | LegacyResult, str, str], str | bool ]"):
|
||||
|
||||
for _ref in self.formats[:]:
|
||||
|
||||
@@ -1424,12 +1424,10 @@ engines:
|
||||
|
||||
- name: kozmonavt
|
||||
engine: xpath
|
||||
paging: true
|
||||
# pageno query param key is U+1D5D1 (looks like an "x")
|
||||
search_url: https://kozmonavt.su/s?q={query}&%F0%9D%97%91={pageno}
|
||||
search_url: https://kozmonavt.su/s?q={query}
|
||||
shortcut: koz
|
||||
disabled: true
|
||||
# inactive: true
|
||||
inactive: true
|
||||
results_xpath: //div[contains(@class, 'list')]/section
|
||||
url_xpath: concat('https://', substring-after(.//a/@href, '?q='))
|
||||
title_xpath: .//a
|
||||
|
||||
Reference in New Issue
Block a user