diff options
author | habsinn <habsinn@habsinn.chateau.org> | 2021-03-18 11:46:55 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2021-04-22 12:25:43 +0200 |
commit | 41a2e3785ea3a926cf0d0df89770e908b01566a9 (patch) | |
tree | cd26f55704f5f8826f01f81efebddbd74f3f161a | |
parent | 981cdb7acf4b7d90a596654c3f7c35c4ecec6eb8 (diff) | |
download | searxng-41a2e3785ea3a926cf0d0df89770e908b01566a9.tar.gz searxng-41a2e3785ea3a926cf0d0df89770e908b01566a9.zip |
[enh] add engine using API from "The Art Institute of Chicago"
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | searx/engines/artic.py | 67 | ||||
-rw-r--r-- | searx/settings.yml | 5 |
3 files changed, 73 insertions, 0 deletions
@@ -197,6 +197,7 @@ PYLINT_FILES=\ searx/engines/google_scholar.py \ searx/engines/yahoo_news.py \ searx/engines/apkmirror.py \ + searx/engines/artic.py \ searx_extra/update/update_external_bangs.py test.pylint: pyenvinstall diff --git a/searx/engines/artic.py b/searx/engines/artic.py new file mode 100644 index 000000000..f8e2dced0 --- /dev/null +++ b/searx/engines/artic.py @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""The Art Institute of Chicago + +Explore thousands of artworks from The Art Institute of Chicago. + +* https://artic.edu + +""" + +# pylint: disable=missing-function-docstring + +from json import loads +from urllib.parse import urlencode + +from searx import logger +logger = logger.getChild('APKMirror engine') + +about = { + "website": 'https://www.artic.edu', + "wikidata_id": 'Q239303', + "official_api_documentation": 'http://api.artic.edu/docs/', + "use_official_api": True, + "require_api_key": False, + "results": 'JSON', +} + +categories = ['images'] +paging = True +nb_per_page = 20 + +search_api = 'https://api.artic.edu/api/v1/artworks/search?' +image_api = 'https://www.artic.edu/iiif/2/' + +def request(query, params): + + args = urlencode({ + 'q' : query, + 'page' : params['pageno'], + 'fields' : 'id,title,artist_display,medium_display,image_id,date_display,dimensions,artist_titles', + 'limit' : nb_per_page, + }) + params['url'] = search_api + args + + logger.debug("query_url --> %s", params['url']) + return params + +def response(resp): + + results = [] + json_data = loads(resp.text) + + for result in json_data['data']: + + if not result['image_id']: + continue + + results.append({ + 'url': 'https://artic.edu/artworks/%(id)s' % result, + 'title': result['title'] + " (%(date_display)s) // %(artist_display)s" % result, + 'content': result['medium_display'], + 'author': ', '.join(result['artist_titles']), + 'img_src': image_api + '/%(image_id)s/full/843,/0/default.jpg' % result, + 'img_format': result['dimensions'], + 'template': 'images.html' + }) + + return results diff --git a/searx/settings.yml b/searx/settings.yml index e4c672507..ecbcfb1f0 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -185,6 +185,11 @@ engines: require_api_key: false results: HTML + - name : artic + engine : artic + shortcut : arc + timeout : 4.0 + - name : arxiv engine : arxiv shortcut : arx |