Feat: initial support for the ipfs-search engine

This commit is contained in:
Jonathan Poelman 2022-04-22 11:09:54 +02:00
parent f522f92250
commit 2e36cc1778
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,27 @@
from urllib.parse import urlencode
import json
import re
categories = ['general'] # optional
base_url = 'https://api.ipfs-search.com/v1/'
search_string = 'search?{query}&page={page}'
ipfs_url = 'https://gateway.ipfs.io/ipfs/{hash}'
def request(query, params):
search_path = search_string.format(
query=urlencode({'q': query}),
page=params['pageno'])
params['url'] = base_url + search_path
return params
def response(resp):
results = json.loads(resp.text)
return map(lambda hit: {'url': ipfs_url.format(hash=hit['hash']),
'title': re.sub(re.compile('<.*?>'), '', hit['title']), 'content': hit['description']}, results['hits'])

View File

@ -731,6 +731,12 @@ engines:
shortcut: iv
timeout : 5.0
disabled : True
- name: ipfs search
engine: ipfs_search
shortcut: ipfs
timeout: 5.0
disabled: True
- name: kickass
engine : kickass