Chore: script to move images from imgur to panoramax

This commit is contained in:
Pieter Vander Vennet 2024-11-14 02:08:10 +01:00
parent 6e335c91d4
commit dcfa829e1a
3 changed files with 12 additions and 10 deletions

View file

@ -111,9 +111,9 @@ export class ImgurToPanoramax extends Script {
console.log("Writing fallback to", fallbackpath) console.log("Writing fallback to", fallbackpath)
writeFileSync(fallbackpath, JSON.stringify(raw), "utf8") writeFileSync(fallbackpath, JSON.stringify(raw), "utf8")
}) })
console.log("Got license via API:", attr.licenseShortName) console.log("Got license via API:", attr?.licenseShortName)
await ScriptUtils.sleep(500) await ScriptUtils.sleep(500)
if (attr.licenseShortName) { if (attr?.licenseShortName) {
return attr return attr
} }
return undefined return undefined
@ -235,12 +235,12 @@ export class ImgurToPanoramax extends Script {
const bounds = new BBox([ const bounds = new BBox([
[ [
1.7217767788980893, 4.025057189545606,
41.00219164121438 49.588777455920024
], ],
[ [
2.7238939148245436, -16.063346185815476,
41.9258679932085 61.187350355346894
] ]
]) ])
const maxcount = 10000 const maxcount = 10000
@ -270,7 +270,7 @@ export class ImgurToPanoramax extends Script {
} }
let changedTags: (UploadableTag | undefined)[] = [] let changedTags: (UploadableTag | undefined)[] = []
console.log("Handling "+f.properties.id) console.log(converted+"/"+total, " handling "+f.properties.id)
for (const k of ["image", "image:menu", "image:streetsign"]) { for (const k of ["image", "image:menu", "image:streetsign"]) {
changedTags.push(await this.uploadImage(k, f)) changedTags.push(await this.uploadImage(k, f))
for (let i = 0; i < 20; i++) { for (let i = 0; i < 20; i++) {

View file

@ -88,7 +88,7 @@ export default class GenerateImageAnalysis extends Script {
if (image === undefined) { if (image === undefined) {
return false return false
} }
if (!image.match(/https:\/\/i\.imgur\.com\/[a-zA-Z0-9]+\.jpg/)) { if (!image.match(/https:\/\/i\.imgur\.com\/[a-zA-Z0-9]+(\.jpe?g)|(\.png)/)) {
return false return false
} }
const filename = image.replace(/[\/:.\-%]/g, "_") + ".json" const filename = image.replace(/[\/:.\-%]/g, "_") + ".json"

View file

@ -106,8 +106,10 @@ export class Imgur extends ImageProvider {
const imgurData = response.data const imgurData = response.data
const license= Imgur.parseLicense(imgurData.description ?? "") const license= Imgur.parseLicense(imgurData.description ?? "")
license.views = imgurData.views if(license){
license.date = new Date(Number(imgurData.datetime) * 1000) license.views = imgurData.views
license.date = new Date(Number(imgurData.datetime) * 1000)
}
return license return license
} }