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

Functions

 init (_)
 
 request (query, params)
 
 parse_image_item (item)
 
 parse_video_item (item)
 
 parse_audio_item (item)
 
 response (resp)
 

Variables

logging logger .Logger
 
dict about
 
list categories = []
 
bool paging = True
 
bool send_accept_language_header = True
 
int results_per_page = 10
 
str base_url = "https://stock.adobe.com"
 
str adobe_order = ""
 
list ADOBE_VALID_TYPES = ["photo", "illustration", "zip_vector", "video", "template", "3d", "audio", "image"]
 
list adobe_content_types = []
 

Detailed Description

`Adobe Stock`_ is a service that gives access to millions of royalty-free
assets. Assets types include photos, vectors, illustrations, templates, 3D
assets, videos, motion graphics templates and audio tracks.

.. Adobe Stock: https://stock.adobe.com/

Configuration
=============

The engine has the following mandatory setting:

- SearXNG's :ref:`engine categories`
- Adobe-Stock's :py:obj:`adobe_order`
- Adobe-Stock's :py:obj:`adobe_content_types`

.. code:: yaml

  - name: adobe stock
    engine: adobe_stock
    shortcut: asi
    categories: [images]
    adobe_order: relevance
    adobe_content_types: ["photo", "illustration", "zip_vector", "template", "3d", "image"]

  - name: adobe stock video
    engine: adobe_stock
    network: adobe stock
    shortcut: asi
    categories: [videos]
    adobe_order: relevance
    adobe_content_types: ["video"]

Implementation
==============

Function Documentation

◆ init()

searx.engines.adobe_stock.init ( _)

Definition at line 96 of file adobe_stock.py.

96def init(_):
97 if not categories:
98 raise ValueError("adobe_stock engine: categories is unset")
99
100 # adobe_order
101 if not adobe_order:
102 raise ValueError("adobe_stock engine: adobe_order is unset")
103 if adobe_order not in ["relevance", "featured", "creation", "nb_downloads"]:
104 raise ValueError(f"unsupported adobe_order: {adobe_order}")
105
106 # adobe_content_types
107 if not adobe_content_types:
108 raise ValueError("adobe_stock engine: adobe_content_types is unset")
109
110 if isinstance(adobe_content_types, list):
111 for t in adobe_content_types:
112 if t not in ADOBE_VALID_TYPES:
113 raise ValueError("adobe_stock engine: adobe_content_types: '%s' is invalid" % t)
114 else:
115 raise ValueError(
116 "adobe_stock engine: adobe_content_types must be a list of strings not %s" % type(adobe_content_types)
117 )
118
119

◆ parse_audio_item()

searx.engines.adobe_stock.parse_audio_item ( item)

Definition at line 192 of file adobe_stock.py.

192def parse_audio_item(item):
193 audio_data = item["audio_data"]
194 content = audio_data.get("description") or ""
195 if audio_data.get("album"):
196 content = audio_data["album"] + " - " + content
197
198 return {
199 "url": item["content_url"],
200 "title": item["title"],
201 "content": content,
202 # "thumbnail": base_url + item["thumbnail_url"],
203 "iframe_src": audio_data["preview"]["url"],
204 "publishedDate": datetime.fromisoformat(audio_data["release_date"]) if audio_data["release_date"] else None,
205 "length": timedelta(seconds=round(audio_data["duration"] / 1000)) if audio_data["duration"] else None,
206 "author": item.get("artist_name"),
207 }
208
209

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

+ Here is the caller graph for this function:

◆ parse_image_item()

searx.engines.adobe_stock.parse_image_item ( item)

Definition at line 142 of file adobe_stock.py.

142def parse_image_item(item):
143 return {
144 "template": "images.html",
145 "url": item["content_url"],
146 "title": item["title"],
147 "content": item["asset_type"],
148 "img_src": item["content_thumb_extra_large_url"],
149 "thumbnail_src": item["thumbnail_url"],
150 "resolution": f"{item['content_original_width']}x{item['content_original_height']}",
151 "img_format": item["format"],
152 "author": item["author"],
153 }
154
155

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

+ Here is the caller graph for this function:

◆ parse_video_item()

searx.engines.adobe_stock.parse_video_item ( item)

Definition at line 156 of file adobe_stock.py.

156def parse_video_item(item):
157
158 # in video items, the title is more or less a "content description", we try
159 # to reduce the lenght of the title ..
160
161 title = item["title"]
162 content = ""
163 if "." in title.strip()[:-1]:
164 content = title
165 title = title.split(".", 1)[0]
166 elif "," in title:
167 content = title
168 title = title.split(",", 1)[0]
169 elif len(title) > 50:
170 content = title
171 title = ""
172 for w in content.split(" "):
173 title += f" {w}"
174 if len(title) > 50:
175 title = title.strip() + "\u2026"
176 break
177
178 return {
179 "template": "videos.html",
180 "url": item["content_url"],
181 "title": title,
182 "content": content,
183 # https://en.wikipedia.org/wiki/ISO_8601#Durations
184 "length": isodate.parse_duration(item["time_duration"]),
185 "publishedDate": datetime.strptime(item["creation_date"], "%Y-%m-%d"),
186 "thumbnail": item["thumbnail_url"],
187 "iframe_src": item["video_small_preview_url"],
188 "metadata": item["asset_type"],
189 }
190
191

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

+ Here is the caller graph for this function:

◆ request()

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

Definition at line 120 of file adobe_stock.py.

120def request(query, params):
121
122 args = {
123 "k": query,
124 "limit": results_per_page,
125 "order": adobe_order,
126 "search_page": params["pageno"],
127 "search_type": "pagination",
128 }
129
130 for content_type in ADOBE_VALID_TYPES:
131 args[f"filters[content_type:{content_type}]"] = 1 if content_type in adobe_content_types else 0
132
133 params["url"] = f"{base_url}/de/Ajax/Search?{urlencode(args)}"
134
135 # headers required to bypass bot-detection
136 if params["searxng_locale"] == "all":
137 params["headers"]["Accept-Language"] = "en-US,en;q=0.5"
138
139 return params
140
141

◆ response()

searx.engines.adobe_stock.response ( resp)

Definition at line 210 of file adobe_stock.py.

210def response(resp):
211 results = []
212
213 json_resp = resp.json()
214
215 if isinstance(json_resp["items"], list):
216 return None
217 for item in json_resp["items"].values():
218 if item["asset_type"].lower() in ["image", "premium-image", "illustration", "vector"]:
219 result = parse_image_item(item)
220 elif item["asset_type"].lower() == "video":
221 result = parse_video_item(item)
222 elif item["asset_type"].lower() == "audio":
223 result = parse_audio_item(item)
224 else:
225 logger.error("no handle for %s --> %s", item["asset_type"], item)
226 continue
227 results.append(result)
228
229 return results

References searx.engines.adobe_stock.parse_audio_item(), searx.engines.adobe_stock.parse_image_item(), and searx.engines.adobe_stock.parse_video_item().

+ Here is the call graph for this function:

Variable Documentation

◆ about

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

Definition at line 51 of file adobe_stock.py.

◆ adobe_content_types

list searx.engines.adobe_stock.adobe_content_types = []

Definition at line 77 of file adobe_stock.py.

◆ adobe_order

str searx.engines.adobe_stock.adobe_order = ""

Definition at line 67 of file adobe_stock.py.

◆ ADOBE_VALID_TYPES

list searx.engines.adobe_stock.ADOBE_VALID_TYPES = ["photo", "illustration", "zip_vector", "video", "template", "3d", "audio", "image"]

Definition at line 76 of file adobe_stock.py.

◆ base_url

str searx.engines.adobe_stock.base_url = "https://stock.adobe.com"

Definition at line 65 of file adobe_stock.py.

◆ categories

list searx.engines.adobe_stock.categories = []

Definition at line 60 of file adobe_stock.py.

◆ logger

logging searx.engines.adobe_stock.logger .Logger

Definition at line 49 of file adobe_stock.py.

◆ paging

bool searx.engines.adobe_stock.paging = True

Definition at line 61 of file adobe_stock.py.

◆ results_per_page

int searx.engines.adobe_stock.results_per_page = 10

Definition at line 63 of file adobe_stock.py.

◆ send_accept_language_header

bool searx.engines.adobe_stock.send_accept_language_header = True

Definition at line 62 of file adobe_stock.py.