mirror of
https://github.com/searxng/searxng.git
synced 2026-05-23 19:34:31 +02:00
[fix] engine wikidata - fails to initialize with HTTP 403 (#6081)
In order not to be further blocked, the WIKIDATA_PROPERTIES are cached, which drastically reduces the WD-SQL request. BTW: improve type hints Closes: https://github.com/searxng/searxng/issues/6051 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
@@ -16,12 +16,12 @@ IMDB_PREFIX_TO_URL_ID = {
|
||||
HTTP_WIKIMEDIA_IMAGE = 'http://commons.wikimedia.org/wiki/Special:FilePath/'
|
||||
|
||||
|
||||
def get_imdb_url_id(imdb_item_id):
|
||||
def get_imdb_url_id(imdb_item_id: str):
|
||||
id_prefix = imdb_item_id[:2]
|
||||
return IMDB_PREFIX_TO_URL_ID.get(id_prefix)
|
||||
|
||||
|
||||
def get_wikimedia_image_id(url):
|
||||
def get_wikimedia_image_id(url: str):
|
||||
if url.startswith(HTTP_WIKIMEDIA_IMAGE):
|
||||
return url[len(HTTP_WIKIMEDIA_IMAGE) :]
|
||||
if url.startswith('File:'):
|
||||
@@ -29,7 +29,7 @@ def get_wikimedia_image_id(url):
|
||||
return url
|
||||
|
||||
|
||||
def get_external_url(url_id, item_id, alternative="default"):
|
||||
def get_external_url(url_id: str, item_id: str | None, alternative: str = "default") -> str | None:
|
||||
"""Return an external URL or None if url_id is not found.
|
||||
|
||||
url_id can take value from data/external_urls.json
|
||||
|
||||
Reference in New Issue
Block a user