From f20a7632f1421eaea094b630a677f68e7a0808c7 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 9 Nov 2024 17:41:32 +0100 Subject: [PATCH] [feat] engine: add adobe stock photos --- searx/engines/adobe_stock.py | 67 ++++++++++++++++++++++++++++++++++++ searx/settings.yml | 7 ++++ 2 files changed, 74 insertions(+) create mode 100644 searx/engines/adobe_stock.py diff --git a/searx/engines/adobe_stock.py b/searx/engines/adobe_stock.py new file mode 100644 index 000000000..f1b8e13ef --- /dev/null +++ b/searx/engines/adobe_stock.py @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""Adobe Stock (images) +""" + +from urllib.parse import urlencode +from searx.utils import gen_useragent + +about = { + "website": 'https://stock.adobe.com/', + "wikidata_id": 'Q5977430', + "official_api_documentation": None, + "use_official_api": False, + "require_api_key": False, + "results": 'JSON', +} + +categories = ['images'] +paging = True + +base_url = 'https://stock.adobe.com' + +results_per_page = 10 +adobe_order = "relevance" # one of 'relevant', 'featured', 'creation' or 'nb_downloads' + + +def request(query, params): + args = { + 'k': query, + 'limit': results_per_page, + 'order': adobe_order, + 'search_page': params['pageno'], + 'search_type': 'pagination', + 'filters[content_type:video]': 0, + 'filters[content_type:audio]': 0, + } + params['url'] = f"{base_url}/de/Ajax/Search?{urlencode(args)}" + + # headers required to bypass bot-detection + params['headers'] = { + "User-Agent": gen_useragent(), + "Accept-Language": "en-US,en;q=0.5", + } + + return params + + +def response(resp): + results = [] + + json_resp = resp.json() + + for item in json_resp['items'].values(): + results.append( + { + 'template': 'images.html', + 'url': item['content_url'], + 'title': item['title'], + 'content': '', + 'img_src': item['content_thumb_extra_large_url'], + 'thumbnail_src': item['thumbnail_url'], + 'resolution': f"{item['content_original_width']}x{item['content_original_height']}", + 'img_format': item['format'], + 'author': item['author'], + } + ) + + return results diff --git a/searx/settings.yml b/searx/settings.yml index 60d04bb0e..0084db902 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -325,6 +325,13 @@ engines: shortcut: 9g disabled: true + - name: adobe stock + engine: adobe_stock + # available search orders: 'relevant', 'featured', 'creation', 'nb_downloads' + # adobe_order: relevance + shortcut: as + disabled: true + - name: alpine linux packages engine: alpinelinux disabled: true