Repository: searxng/searxng

Issue:
[FEATURE REQUEST] language filtering and safe search with odysee
**Is your feature request related to a problem? Please describe.**
No

**Describe the solution you'd like**
We can use, for example, language=de in the search URL. en, de-DE, and en-US also seem to work. There is no list of supported languages afaik, we just need to try things out one by one.

for safe search Moderate/Strict we should use nsfw=false in the URL

**Additional context**
The information that you need for this is here: https://github.com/searx/searx/issues/2504


----
Related

- https://github.com/searxng/searxng/pull/2656
- https://github.com/searxng/searxng/issues/590
- [lbr command line](https://gitlab.com/gardenappl/lbt/-/blob/main/lbt?ref_type=heads)
- [LBRY SDK ](https://github.com/lbryio/lbry-sdk/)



Discussion:

Resolving patch:
diff --git a/searx/engines/odysee.py b/searx/engines/odysee.py
--- a/searx/engines/odysee.py
+++ b/searx/engines/odysee.py
@@ -9,6 +9,14 @@
 from urllib.parse import urlencode
 from datetime import datetime
 
+import babel
+
+from searx.network import get
+from searx.locales import language_tag
+from searx.enginelib.traits import EngineTraits
+
+traits: EngineTraits
+
 # Engine metadata
 about = {
     "website": "https://odysee.com/",
@@ -21,6 +29,7 @@
 
 # Engine configuration
 paging = True
+time_range_support = True
 results_per_page = 20
 categories = ['videos']
 
@@ -29,6 +38,13 @@
 
 
 def request(query, params):
+    time_range_dict = {
+        "day": "today",
+        "week": "thisweek",
+        "month": "thismonth",
+        "year": "thisyear",
+    }
+
     start_index = (params["pageno"] - 1) * results_per_page
     query_params = {
         "s": query,
@@ -38,6 +54,13 @@ def request(query, params):
         "mediaType": "video",
     }
 
+    lang = traits.get_language(params['searxng_locale'], None)
+    if lang is not None:
+        query_params['language'] = lang
+
+    if params['time_range'] in time_range_dict:
+        query_params['time_filter'] = time_range_dict[params['time_range']]
+
     params["url"] = f"{base_url}?{urlencode(query_params)}"
     return params
 
@@ -88,3 +111,35 @@ def response(resp):
         )
 
     return results
+
+
+def fetch_traits(engine_traits: EngineTraits):
+    """
+    Fetch languages from Odysee's source code.
+    """
+
+    resp = get(
+        'https://raw.githubusercontent.com/OdyseeTeam/odysee-frontend/master/ui/constants/supported_browser_languages.js',  # pylint: disable=line-too-long
+        timeout=60,
+    )
+
+    if not resp.ok:
+        print("ERROR: can't determine languages from Odysee")
+        return
+
+    for line in resp.text.split("\n")[1:-4]:
+        lang_tag = line.strip().split(": ")[0].replace("'", "")
+
+        try:
+            sxng_tag = language_tag(babel.Locale.parse(lang_tag, sep="-"))
+        except babel.UnknownLocaleError:
+            print("ERROR: %s is unknown by babel" % lang_tag)
+            continue
+
+        conflict = engine_traits.languages.get(sxng_tag)
+        if conflict:
+            if conflict != lang_tag:
+                print("CONFLICT: babel %s --> %s, %s" % (sxng_tag, conflict, lang_tag))
+            continue
+
+        engine_traits.languages[sxng_tag] = lang_tag


Test patch: