.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
apple_app_store.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""Apple App Store
3
4"""
5
6from json import loads
7from urllib.parse import urlencode
8from dateutil.parser import parse
9
10about = {
11 "website": 'https://www.apple.com/app-store/',
12 "wikidata_id": 'Q368215',
13 "official_api_documentation": (
14 'https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/'
15 'iTuneSearchAPI/UnderstandingSearchResults.html#//apple_ref/doc/uid/TP40017632-CH8-SW1'
16 ),
17 "use_official_api": True,
18 "require_api_key": False,
19 "results": 'JSON',
20}
21
22categories = ['files', 'apps']
23safesearch = True
24
25search_url = 'https://itunes.apple.com/search?{query}'
26
27
28def request(query, params):
29 explicit = "Yes"
30
31 if params['safesearch'] > 0:
32 explicit = "No"
33
34 params['url'] = search_url.format(query=urlencode({'term': query, 'media': 'software', 'explicit': explicit}))
35
36 return params
37
38
39def response(resp):
40 results = []
41
42 json_result = loads(resp.text)
43
44 for result in json_result['results']:
45 results.append(
46 {
47 'url': result['trackViewUrl'],
48 'title': result['trackName'],
49 'content': result['description'],
50 'img_src': result['artworkUrl100'],
51 'publishedDate': parse(result['currentVersionReleaseDate']),
52 'author': result['sellerName'],
53 }
54 )
55
56 return results