forked from MapComplete/MapComplete
Fix #1863
This commit is contained in:
parent
a79675c879
commit
940f187041
8 changed files with 37 additions and 22 deletions
|
@ -40,7 +40,7 @@ export default class GenericImageProvider extends ImageProvider {
|
|||
return undefined
|
||||
}
|
||||
|
||||
public DownloadAttribution(url: string) {
|
||||
public DownloadAttribution(_) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ export default abstract class ImageProvider {
|
|||
|
||||
public abstract ExtractUrls(key: string, value: string): Promise<Promise<ProvidedImage>[]>
|
||||
|
||||
public abstract DownloadAttribution(url: string): Promise<LicenseInfo>
|
||||
public abstract DownloadAttribution(providedImage: ProvidedImage): Promise<LicenseInfo>
|
||||
|
||||
public abstract apiUrls(): string[]
|
||||
|
||||
|
|
|
@ -92,8 +92,9 @@ export class Imgur extends ImageProvider implements ImageUploader {
|
|||
*
|
||||
*
|
||||
*/
|
||||
public async DownloadAttribution(url: string): Promise<LicenseInfo> {
|
||||
const hash = url.substr("https://i.imgur.com/".length).split(/\.jpe?g/i)[0]
|
||||
public async DownloadAttribution(providedImage: {url: string}): Promise<LicenseInfo> {
|
||||
const url = providedImage.url
|
||||
const hash = url.substr("https://i.imgur.com/".length).split(/\.jpe?g/i)[0]
|
||||
|
||||
const apiUrl = "https://api.imgur.com/3/image/" + hash
|
||||
const response = await Utils.downloadJsonCached(apiUrl, 365 * 24 * 60 * 60, {
|
||||
|
|
|
@ -133,12 +133,21 @@ export class Mapillary extends ImageProvider {
|
|||
return [this.PrepareUrlAsync(key, value)]
|
||||
}
|
||||
|
||||
public async DownloadAttribution(_: string): Promise<LicenseInfo> {
|
||||
public async DownloadAttribution(providedImage: ProvidedImage): Promise<LicenseInfo> {
|
||||
const mapillaryId = providedImage.id
|
||||
const metadataUrl =
|
||||
"https://graph.mapillary.com/" +
|
||||
mapillaryId +
|
||||
"?fields=thumb_1024_url,thumb_original_url,captured_at,creator&access_token=" +
|
||||
Constants.mapillary_client_token_v4
|
||||
const response = await Utils.downloadJsonCached(metadataUrl, 60 * 60)
|
||||
|
||||
const license = new LicenseInfo()
|
||||
license.artist = undefined
|
||||
license.artist = response["creator"]["username"]
|
||||
license.license = "CC BY-SA 4.0"
|
||||
// license.license = "Creative Commons Attribution-ShareAlike 4.0 International License";
|
||||
license.attributionRequired = true
|
||||
license.date = new Date(response["captured_at"])
|
||||
return license
|
||||
}
|
||||
|
||||
|
@ -151,16 +160,19 @@ export class Mapillary extends ImageProvider {
|
|||
const metadataUrl =
|
||||
"https://graph.mapillary.com/" +
|
||||
mapillaryId +
|
||||
"?fields=thumb_1024_url,thumb_original_url&access_token=" +
|
||||
"?fields=thumb_1024_url,thumb_original_url,captured_at,creator&access_token=" +
|
||||
Constants.mapillary_client_token_v4
|
||||
const response = await Utils.downloadJsonCached(metadataUrl, 60 * 60)
|
||||
const url = <string>response["thumb_1024_url"]
|
||||
const url_hd = <string>response["thumb_original_url"]
|
||||
return {
|
||||
const date = new Date()
|
||||
date.setTime(response["captured_at"])
|
||||
return <ProvidedImage> {
|
||||
id: "" + mapillaryId,
|
||||
url,
|
||||
url_hd,
|
||||
provider: this,
|
||||
date,
|
||||
key,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ export class WikidataImageProvider extends ImageProvider {
|
|||
return allImages
|
||||
}
|
||||
|
||||
public DownloadAttribution(_: string): Promise<any> {
|
||||
public DownloadAttribution(_): Promise<any> {
|
||||
throw new Error("Method not implemented; shouldn't be needed!")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,8 @@ export class WikimediaImageProvider extends ImageProvider {
|
|||
return [Promise.resolve(this.UrlForImage("File:" + value))]
|
||||
}
|
||||
|
||||
public async DownloadAttribution(filename: string): Promise<LicenseInfo> {
|
||||
filename = WikimediaImageProvider.ExtractFileName(filename)
|
||||
public async DownloadAttribution(img: ProvidedImage): Promise<LicenseInfo> {
|
||||
const filename = WikimediaImageProvider.ExtractFileName(img.url)
|
||||
|
||||
if (filename === "") {
|
||||
return undefined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue