diff options
author | Noemi Vanyi <sitbackandwait@gmail.com> | 2016-02-04 20:27:36 +0100 |
---|---|---|
committer | Noemi Vanyi <sitbackandwait@gmail.com> | 2016-02-04 20:27:36 +0100 |
commit | 33fa3da2e8c832cce2462e4b3a9a3664072d2ea0 (patch) | |
tree | 72f776e3d3da740e1e2454cd6dc378fc7be04b8d /searx/engines/frinkiac.py | |
parent | 0491b78f7034599a5573cdffaa8acc044d4d8720 (diff) | |
download | searxng-33fa3da2e8c832cce2462e4b3a9a3664072d2ea0.tar.gz searxng-33fa3da2e8c832cce2462e4b3a9a3664072d2ea0.zip |
add Frinkiac engine & tests
Diffstat (limited to 'searx/engines/frinkiac.py')
-rw-r--r-- | searx/engines/frinkiac.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/searx/engines/frinkiac.py b/searx/engines/frinkiac.py new file mode 100644 index 000000000..7edb4a3cb --- /dev/null +++ b/searx/engines/frinkiac.py @@ -0,0 +1,42 @@ +""" +Frinkiac (Images) + +@website https://www.frinkiac.com +@provide-api no +@using-api no +@results JSON +@stable no +@parse url, title, img_src +""" + +from json import loads +from urllib import urlencode + +categories = ['images'] + +BASE = 'https://frinkiac.com/' +SEARCH_URL = '{base}api/search?{query}' +RESULT_URL = '{base}?{query}' +THUMB_URL = '{base}img/{episode}/{timestamp}/medium.jpg' +IMAGE_URL = '{base}img/{episode}/{timestamp}.jpg' + +def request(query, params): + params['url'] = SEARCH_URL.format(base=BASE, query=urlencode({'q': query})) + return params + +def response(resp): + results = [] + response_data = loads(resp.text) + for result in response_data: + episode = result['Episode'] + timestamp = result['Timestamp'] + + results.append({'template': 'images.html', + 'url': RESULT_URL.format(base=BASE, + query=urlencode({'p': 'caption', 'e': episode, 't': timestamp})), + 'title': episode, + 'content': '', + 'thumbnail_src': THUMB_URL.format(base=BASE, episode=episode, timestamp=timestamp), + 'img_src': IMAGE_URL.format(base=BASE, episode=episode, timestamp=timestamp)}) + + return results |