Load nearby image and image:* images from server for the nearby images

This commit is contained in:
Pieter Vander Vennet 2024-07-27 12:59:38 +02:00
parent 9a4572cdfa
commit caa2e18a03
10 changed files with 206 additions and 72 deletions

View file

@ -18,6 +18,7 @@ export class WikimediaImageProvider extends ImageProvider {
public static readonly commonsPrefixes = [...WikimediaImageProvider.apiUrls, "File:"]
private readonly commons_key = "wikimedia_commons"
public readonly defaultKeyPrefixes = [this.commons_key, "image"]
public readonly name = "Wikimedia"
private constructor() {
super()
@ -133,9 +134,9 @@ export class WikimediaImageProvider extends ImageProvider {
"titles=" +
filename +
"&format=json&origin=*"
const data = await Utils.downloadJsonCached(url, 365 * 24 * 60 * 60)
const data = await Utils.downloadJsonCached<{query: {pages: {title: string, imageinfo: { extmetadata} []}[]}}>(url, 365 * 24 * 60 * 60)
const licenseInfo = new LicenseInfo()
const pageInfo = data.query.pages[-1]
const pageInfo = data.query.pages.at(-1)
if (pageInfo === undefined) {
return undefined
}