forked from zaclys/searxng
Merge branch 'master' into patch-2
This commit is contained in:
commit
8f744ddfb2
|
@ -1,4 +1,4 @@
|
|||
FROM alpine:3.7
|
||||
FROM alpine:3.8
|
||||
LABEL maintainer="searx <https://github.com/asciimoo/searx>"
|
||||
LABEL description="A privacy-respecting, hackable metasearch engine."
|
||||
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
"""
|
||||
500px (Images)
|
||||
|
||||
@website https://500px.com
|
||||
@provide-api yes (https://developers.500px.com/)
|
||||
|
||||
@using-api no
|
||||
@results HTML
|
||||
@stable no (HTML can change)
|
||||
@parse url, title, thumbnail, img_src, content
|
||||
|
||||
@todo rewrite to api
|
||||
"""
|
||||
|
||||
from json import loads
|
||||
from searx.url_utils import urlencode, urljoin
|
||||
|
||||
# engine dependent config
|
||||
categories = ['images']
|
||||
paging = True
|
||||
|
||||
# search-url
|
||||
base_url = 'https://500px.com'
|
||||
search_url = 'https://api.500px.com/v1/photos/search?type=photos'\
|
||||
'&{query}'\
|
||||
'&image_size%5B%5D=4'\
|
||||
'&image_size%5B%5D=20'\
|
||||
'&image_size%5B%5D=21'\
|
||||
'&image_size%5B%5D=1080'\
|
||||
'&image_size%5B%5D=1600'\
|
||||
'&image_size%5B%5D=2048'\
|
||||
'&include_states=true'\
|
||||
'&formats=jpeg%2Clytro'\
|
||||
'&include_tags=true'\
|
||||
'&exclude_nude=true'\
|
||||
'&page={pageno}'\
|
||||
'&rpp=50'\
|
||||
'&sdk_key=b68e60cff4c929bedea36ca978830c5caca790c3'
|
||||
|
||||
|
||||
# do search-request
|
||||
def request(query, params):
|
||||
params['url'] = search_url.format(pageno=params['pageno'],
|
||||
query=urlencode({'term': query}))
|
||||
|
||||
return params
|
||||
|
||||
|
||||
# get response from search-request
|
||||
def response(resp):
|
||||
results = []
|
||||
|
||||
response_json = loads(resp.text)
|
||||
|
||||
# parse results
|
||||
for result in response_json['photos']:
|
||||
url = urljoin(base_url, result['url'])
|
||||
title = result['name']
|
||||
# last index is the biggest resolution
|
||||
img_src = result['image_url'][-1]
|
||||
thumbnail_src = result['image_url'][0]
|
||||
content = result['description'] or ''
|
||||
|
||||
# append result
|
||||
results.append({'url': url,
|
||||
'title': title,
|
||||
'img_src': img_src,
|
||||
'content': content,
|
||||
'thumbnail_src': thumbnail_src,
|
||||
'template': 'images.html'})
|
||||
|
||||
# return results
|
||||
return results
|
|
@ -264,6 +264,9 @@ class Preferences(object):
|
|||
'False': False,
|
||||
'True': True}),
|
||||
'doi_resolver': MultipleChoiceSetting(['oadoi.org'], choices=DOI_RESOLVERS),
|
||||
'oscar-style': EnumStringSetting(
|
||||
settings['ui'].get('theme_args', {}).get('oscar_style', 'logicodev'),
|
||||
choices=['', 'logicodev', 'logicodev-dark', 'pointhi']),
|
||||
}
|
||||
|
||||
self.engines = EnginesSetting('engines', choices=engines)
|
||||
|
|
|
@ -147,7 +147,8 @@ def search_one_request_safe(engine_name, query, request_params, result_container
|
|||
if requests_exception:
|
||||
# update continuous_errors / suspend_end_time
|
||||
engine.continuous_errors += 1
|
||||
engine.suspend_end_time = time() + min(60, engine.continuous_errors)
|
||||
engine.suspend_end_time = time() + min(settings['search']['max_ban_time_on_fail'],
|
||||
engine.continuous_errors * settings['search']['ban_time_on_fail'])
|
||||
else:
|
||||
# no HTTP error (perhaps an engine error)
|
||||
# anyway, reset the suspend variables
|
||||
|
|
|
@ -6,6 +6,8 @@ search:
|
|||
safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict
|
||||
autocomplete : "" # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "startpage", "wikipedia" - leave blank to turn it off by default
|
||||
language : "en-US"
|
||||
ban_time_on_fail : 5 # ban time in seconds after engine errors
|
||||
max_ban_time_on_fail : 120 # max ban time in seconds after engine errors
|
||||
|
||||
server:
|
||||
port : 8888
|
||||
|
@ -20,6 +22,8 @@ ui:
|
|||
templates_path : "" # Custom templates path - leave it blank if you didn't change
|
||||
default_theme : oscar # ui theme
|
||||
default_locale : "" # Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section
|
||||
theme_args :
|
||||
oscar_style : logicodev # default style of oscar
|
||||
|
||||
# searx supports result proxification using an external service: https://github.com/asciimoo/morty
|
||||
# uncomment below section if you have running morty proxy
|
||||
|
@ -204,10 +208,6 @@ engines:
|
|||
shortcut : fa
|
||||
disabled : True
|
||||
|
||||
- name : 500px
|
||||
engine : www500px
|
||||
shortcut : px
|
||||
|
||||
- name : 1x
|
||||
engine : www1x
|
||||
shortcut : 1x
|
||||
|
|
|
@ -60,3 +60,4 @@ Searx can be added to your browser's search bar; moreover, it can be set as the
|
|||
<p><a href="{{ url_for('stats') }}">Stats page</a> contains some useful data about the engines used.</p>
|
||||
|
||||
</div>
|
||||
{% include "__common__/aboutextend.html" ignore missing %}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue