.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.odysee Namespace Reference

Functions

 request (query, params)
 
 format_duration (duration)
 
 response (resp)
 
 fetch_traits (EngineTraits engine_traits)
 

Variables

EngineTraits traits
 
dict about
 
bool paging = True
 
bool time_range_support = True
 
int results_per_page = 20
 
list categories = ['videos']
 
str base_url = "https://lighthouse.odysee.tv/search"
 

Detailed Description

Odysee_ is a decentralized video hosting platform.

.. _Odysee: https://github.com/OdyseeTeam/odysee-frontend

Function Documentation

◆ fetch_traits()

searx.engines.odysee.fetch_traits ( EngineTraits engine_traits)
Fetch languages from Odysee's source code.

Definition at line 115 of file odysee.py.

115def fetch_traits(engine_traits: EngineTraits):
116 """
117 Fetch languages from Odysee's source code.
118 """
119
120 resp = get(
121 'https://raw.githubusercontent.com/OdyseeTeam/odysee-frontend/master/ui/constants/supported_browser_languages.js', # pylint: disable=line-too-long
122 timeout=60,
123 )
124
125 if not resp.ok:
126 print("ERROR: can't determine languages from Odysee")
127 return
128
129 for line in resp.text.split("\n")[1:-4]:
130 lang_tag = line.strip().split(": ")[0].replace("'", "")
131
132 try:
133 sxng_tag = language_tag(babel.Locale.parse(lang_tag, sep="-"))
134 except babel.UnknownLocaleError:
135 print("ERROR: %s is unknown by babel" % lang_tag)
136 continue
137
138 conflict = engine_traits.languages.get(sxng_tag)
139 if conflict:
140 if conflict != lang_tag:
141 print("CONFLICT: babel %s --> %s, %s" % (sxng_tag, conflict, lang_tag))
142 continue
143
144 engine_traits.languages[sxng_tag] = lang_tag

◆ format_duration()

searx.engines.odysee.format_duration ( duration)

Definition at line 68 of file odysee.py.

68def format_duration(duration):
69 seconds = int(duration)
70 length = time.gmtime(seconds)
71 if length.tm_hour:
72 return time.strftime("%H:%M:%S", length)
73 return time.strftime("%M:%S", length)
74
75

Referenced by searx.engines.odysee.response().

+ Here is the caller graph for this function:

◆ request()

searx.engines.odysee.request ( query,
params )

Definition at line 39 of file odysee.py.

39def request(query, params):
40 time_range_dict = {
41 "day": "today",
42 "week": "thisweek",
43 "month": "thismonth",
44 "year": "thisyear",
45 }
46
47 start_index = (params["pageno"] - 1) * results_per_page
48 query_params = {
49 "s": query,
50 "size": results_per_page,
51 "from": start_index,
52 "include": "channel,thumbnail_url,title,description,duration,release_time",
53 "mediaType": "video",
54 }
55
56 lang = traits.get_language(params['searxng_locale'], None)
57 if lang is not None:
58 query_params['language'] = lang
59
60 if params['time_range'] in time_range_dict:
61 query_params['time_filter'] = time_range_dict[params['time_range']]
62
63 params["url"] = f"{base_url}?{urlencode(query_params)}"
64 return params
65
66
67# Format the video duration

◆ response()

searx.engines.odysee.response ( resp)

Definition at line 76 of file odysee.py.

76def response(resp):
77 data = resp.json()
78 results = []
79
80 for item in data:
81 name = item["name"]
82 claim_id = item["claimId"]
83 title = item["title"]
84 thumbnail_url = item["thumbnail_url"]
85 description = item["description"] or ""
86 channel = item["channel"]
87 release_time = item["release_time"]
88 duration = item["duration"]
89
90 release_date = datetime.strptime(release_time.split("T")[0], "%Y-%m-%d")
91 formatted_date = datetime.utcfromtimestamp(release_date.timestamp())
92
93 url = f"https://odysee.com/{name}:{claim_id}"
94 iframe_url = f"https://odysee.com/$/embed/{name}:{claim_id}"
95 odysee_thumbnail = f"https://thumbnails.odycdn.com/optimize/s:390:0/quality:85/plain/{thumbnail_url}"
96 formatted_duration = format_duration(duration)
97
98 results.append(
99 {
100 "title": title,
101 "url": url,
102 "content": description,
103 "author": channel,
104 "publishedDate": formatted_date,
105 "length": formatted_duration,
106 "thumbnail": odysee_thumbnail,
107 "iframe_src": iframe_url,
108 "template": "videos.html",
109 }
110 )
111
112 return results
113
114

References searx.engines.odysee.format_duration().

+ Here is the call graph for this function:

Variable Documentation

◆ about

dict searx.engines.odysee.about
Initial value:
1= {
2 "website": "https://odysee.com/",
3 "wikidata_id": "Q102046570",
4 "official_api_documentation": None,
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": "JSON",
8}

Definition at line 20 of file odysee.py.

◆ base_url

str searx.engines.odysee.base_url = "https://lighthouse.odysee.tv/search"

Definition at line 36 of file odysee.py.

◆ categories

list searx.engines.odysee.categories = ['videos']

Definition at line 33 of file odysee.py.

◆ paging

bool searx.engines.odysee.paging = True

Definition at line 30 of file odysee.py.

◆ results_per_page

int searx.engines.odysee.results_per_page = 20

Definition at line 32 of file odysee.py.

◆ time_range_support

bool searx.engines.odysee.time_range_support = True

Definition at line 31 of file odysee.py.

◆ traits

EngineTraits searx.engines.odysee.traits

Definition at line 17 of file odysee.py.