mirror of
https://github.com/searxng/searxng.git
synced 2025-11-21 14:03:10 -05:00
[fix] recoll engine: fix media preview
The results from the recoll engine were not displaying the usual toggle for showing media previews. After the changes described bellow, the toggle is displayed and works as expected. In the JSON returned by recoll-webui, the field containing the mimetype is actually `mtype`, not `mime`. Furthermore, according to the documentation for the `File` class in `searx/result_types/file.py`, `embedded` should contain the URL to the media itself. The embedding of the media into the page for preview is done in `searx/templates/simple/result_templates/file.html`.
This commit is contained in:
parent
431bf5d235
commit
af111e413c
@ -38,7 +38,7 @@ Implementations
|
||||
import typing as t
|
||||
|
||||
from datetime import date, timedelta
|
||||
from urllib.parse import urlencode, quote
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from searx.result_types import EngineResults
|
||||
|
||||
@ -122,15 +122,14 @@ def response(resp: "SXNG_Response") -> EngineResults:
|
||||
|
||||
url = result.get("url", "").replace("file://" + mount_prefix, dl_prefix)
|
||||
|
||||
mtype = subtype = result.get("mime", "")
|
||||
mtype = subtype = result.get("mtype", "")
|
||||
if mtype:
|
||||
mtype, subtype = (mtype.split("/", 1) + [""])[:2]
|
||||
|
||||
# facilitate preview support for known mime types
|
||||
thumbnail = embedded = ""
|
||||
if mtype in ["audio", "video"]:
|
||||
embedded_url = '<{ttype} controls height="166px" ' + 'src="{url}" type="{mtype}"></{ttype}>'
|
||||
embedded = embedded_url.format(ttype=mtype, url=quote(url.encode("utf8"), "/:"), mtype=result["mtype"])
|
||||
embedded = url
|
||||
if mtype in ["image"] and subtype in ["bmp", "gif", "jpeg", "png"]:
|
||||
thumbnail = url
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user