.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
artic.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""The Art Institute of Chicago
3
4Explore thousands of artworks from The Art Institute of Chicago.
5
6* https://artic.edu
7
8"""
9
10from json import loads
11from urllib.parse import urlencode
12
13about = {
14 "website": 'https://www.artic.edu',
15 "wikidata_id": 'Q239303',
16 "official_api_documentation": 'http://api.artic.edu/docs/',
17 "use_official_api": True,
18 "require_api_key": False,
19 "results": 'JSON',
20}
21
22categories = ['images']
23paging = True
24nb_per_page = 20
25
26search_api = 'https://api.artic.edu/api/v1/artworks/search?'
27image_api = 'https://www.artic.edu/iiif/2/'
28
29
30def request(query, params):
31
32 args = urlencode(
33 {
34 'q': query,
35 'page': params['pageno'],
36 'fields': 'id,title,artist_display,medium_display,image_id,date_display,dimensions,artist_titles',
37 'limit': nb_per_page,
38 }
39 )
40 params['url'] = search_api + args
41
42 logger.debug("query_url --> %s", params['url'])
43 return params
44
45
46def response(resp):
47
48 results = []
49 json_data = loads(resp.text)
50
51 for result in json_data['data']:
52
53 if not result['image_id']:
54 continue
55
56 results.append(
57 {
58 'url': 'https://artic.edu/artworks/%(id)s' % result,
59 'title': result['title'] + " (%(date_display)s) // %(artist_display)s" % result,
60 'content': "%(medium_display)s // %(dimensions)s" % result,
61 'author': ', '.join(result['artist_titles']),
62 'img_src': image_api + '/%(image_id)s/full/843,/0/default.jpg' % result,
63 'template': 'images.html',
64 }
65 )
66
67 return results
request(query, params)
Definition artic.py:30