SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[feat] engine: add Steam engine
Zhijie He808dcaf1e208
diff --git a/searx/engines/steam.py b/searx/engines/steam.pynew file mode 100644index 000000000..f25516e00--- /dev/null+++ b/searx/engines/steam.py@@ -0,0 +1,51 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+"""Steam (store) for SearXNG."""++from urllib.parse import urlencode++from searx.utils import html_to_text+from searx.result_types import EngineResults, MainResult++about = {+ "website": 'https://store.steampowered.com/',+ "wikidata_id": 'Q337535',+ "use_official_api": False,+ "require_api_key": False,+ "results": 'JSON',+}++categories = []++base_url = "https://store.steampowered.com"+++def request(query, params):+ query_params = {"term": query, "cc": "us", "l": "en"}+ params['url'] = f'{base_url}/api/storesearch/?{urlencode(query_params)}'+ return params+++def response(resp) -> EngineResults:+ results = EngineResults()+ search_results = resp.json()++ for item in search_results.get('items', []):+ app_id = item.get('id')++ currency = item.get('price', {}).get('currency', 'USD')+ price = item.get('price', {}).get('final', 0) / 100++ platforms = ', '.join([platform for platform, supported in item.get('platforms', {}).items() if supported])++ content = [f'Price: {price:.2f} {currency}', f'Platforms: {platforms}']++ results.add(+ MainResult(+ title=item.get('name'),+ content=html_to_text(' | '.join(content)),+ url=f'{base_url}/app/{app_id}',+ thumbnail=item.get('tiny_image', ''),+ )+ )++ return resultsdiff --git a/searx/settings.yml b/searx/settings.ymlindex 714921731..e3201e8ca 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -1971,6 +1971,11 @@ engines:categories: [images, web]shortcut: spi+ - name: steam+ engine: steam+ shortcut: stm+ disabled: true+- name: tokyotoshokanengine: tokyotoshokanshortcut: tt