forked from MapComplete/MapComplete
Scripts(imagurToPanoramax): delete 404-images automatically
This commit is contained in:
parent
c0b11a81e9
commit
8eb59383d6
1 changed files with 28 additions and 12 deletions
|
@ -40,9 +40,9 @@ export class ImgurToPanoramax extends Script {
|
|||
|
||||
private readonly sequenceIds = {
|
||||
test: "7f34cf53-27ff-46c9-ac22-78511fa8457a",
|
||||
cc0: "1de6f4a1-73ac-4c75-ab7f-2a2aabddf50a", // "f0d6f78a-ff95-4db1-8494-6eb44a17bb37",
|
||||
cc0: "e9bcb8c0-8ade-4ac9-bc9f-cfa464221fd6", // "1de6f4a1-73ac-4c75-ab7f-2a2aabddf50a", // "f0d6f78a-ff95-4db1-8494-6eb44a17bb37",
|
||||
ccby: "288a8052-b475-422c-811a-4f6f1a00015e",
|
||||
ccbysa: "f3d02893-b4c1-4cd6-8b27-e27ab57eb59a",
|
||||
ccbysa: "f3d02893-b4c1-4cd6-8b27-e27ab57eb59a"
|
||||
} as const
|
||||
|
||||
constructor() {
|
||||
|
@ -145,7 +145,7 @@ export class ImgurToPanoramax extends Script {
|
|||
console.log("Already uploaded", panohash)
|
||||
return new And([
|
||||
new Tag(key.replace("image", "panoramax"), panohash),
|
||||
new Tag(key, ""),
|
||||
new Tag(key, "")
|
||||
])
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,17 @@ export class ImgurToPanoramax extends Script {
|
|||
if (!path) {
|
||||
return undefined
|
||||
}
|
||||
const license: LicenseInfo = await this.getLicenseFor(v)
|
||||
let license: LicenseInfo
|
||||
try {
|
||||
license = await this.getLicenseFor(v)
|
||||
} catch (e) {
|
||||
console.error("Could not fetch license due to", e)
|
||||
if(e === 404){
|
||||
console.log("NOT FOUND")
|
||||
return new Tag(key, "")
|
||||
}
|
||||
throw e
|
||||
}
|
||||
if (license === undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
@ -176,7 +186,7 @@ export class ImgurToPanoramax extends Script {
|
|||
|
||||
const file = new MyFile([], path)
|
||||
|
||||
file.stream = function () {
|
||||
file.stream = function() {
|
||||
return handle.readableWebStream()
|
||||
}
|
||||
|
||||
|
@ -213,7 +223,7 @@ export class ImgurToPanoramax extends Script {
|
|||
const license = await this.getRawInfo("https://i.imgur.com/" + imgurkey + ".jpg")
|
||||
const date = new Date(license.datetime * 1000)
|
||||
const panolicense = await this.panoramax.panoramax.search({
|
||||
ids: [panokey],
|
||||
ids: [panokey]
|
||||
})
|
||||
const panodata = panolicense[0]
|
||||
const collection: string = panodata.collection
|
||||
|
@ -224,13 +234,13 @@ export class ImgurToPanoramax extends Script {
|
|||
method: "PATCH",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
ts: date.getTime(),
|
||||
}),
|
||||
ts: date.getTime()
|
||||
})
|
||||
})
|
||||
console.log(
|
||||
"Patched date of ",
|
||||
p.createViewLink({
|
||||
imageId: panokey,
|
||||
imageId: panokey
|
||||
}),
|
||||
url,
|
||||
"result is",
|
||||
|
@ -251,8 +261,14 @@ export class ImgurToPanoramax extends Script {
|
|||
}*/
|
||||
|
||||
const bounds = new BBox([
|
||||
[4.025057189545606, 49.588777455920024],
|
||||
[-16.063346185815476, 61.187350355346894],
|
||||
[
|
||||
5.051208080670676,
|
||||
45.55085138791583
|
||||
],
|
||||
[
|
||||
14.998934008628453,
|
||||
55.163232765096495
|
||||
]
|
||||
])
|
||||
const maxcount = 10000
|
||||
const overpassfilters: RegexTag[] = []
|
||||
|
@ -308,7 +324,7 @@ export class ImgurToPanoramax extends Script {
|
|||
f.properties,
|
||||
{
|
||||
theme: "image-mover",
|
||||
changeType: "link-image",
|
||||
changeType: "link-image"
|
||||
}
|
||||
)
|
||||
changes.push(...(await action.CreateChangeDescriptions()))
|
||||
|
|
Loading…
Reference in a new issue