.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

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 113 of file odysee.py.

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

◆ format_duration()

searx.engines.odysee.format_duration ( duration)

Definition at line 66 of file odysee.py.

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

Referenced by response().

Here is the caller graph for this function:

◆ request()

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

Definition at line 37 of file odysee.py.

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

◆ response()

searx.engines.odysee.response ( resp)

Definition at line 74 of file odysee.py.

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

References 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 18 of file odysee.py.

◆ base_url

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

Definition at line 34 of file odysee.py.

◆ categories

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

Definition at line 31 of file odysee.py.

◆ paging

bool searx.engines.odysee.paging = True

Definition at line 28 of file odysee.py.

◆ results_per_page

int searx.engines.odysee.results_per_page = 20

Definition at line 30 of file odysee.py.

◆ time_range_support

bool searx.engines.odysee.time_range_support = True

Definition at line 29 of file odysee.py.