Browse Source

[mod] odysee: time range support

Bnyro 1 year ago
parent
commit
09c61dabc9
1 changed files with 11 additions and 0 deletions
  1. 11 0
      searx/engines/odysee.py

+ 11 - 0
searx/engines/odysee.py

@@ -21,6 +21,7 @@ about = {
 
 
 # Engine configuration
 # Engine configuration
 paging = True
 paging = True
+time_range_support = True
 results_per_page = 20
 results_per_page = 20
 categories = ['videos']
 categories = ['videos']
 
 
@@ -29,6 +30,13 @@ base_url = "https://lighthouse.odysee.tv/search"
 
 
 
 
 def request(query, params):
 def request(query, params):
+    time_range_dict = {
+        "day": "today",
+        "week": "thisweek",
+        "month": "thismonth",
+        "year": "thisyear",
+    }
+
     start_index = (params["pageno"] - 1) * results_per_page
     start_index = (params["pageno"] - 1) * results_per_page
     query_params = {
     query_params = {
         "s": query,
         "s": query,
@@ -38,6 +46,9 @@ def request(query, params):
         "mediaType": "video",
         "mediaType": "video",
     }
     }
 
 
+    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)}"
     params["url"] = f"{base_url}?{urlencode(query_params)}"
     return params
     return params