Scripts: robustify image downloader

This commit is contained in:
Pieter Vander Vennet 2023-06-04 22:14:23 +02:00
parent 3f4410ff19
commit e4b3ee0ce1

View file

@ -10,6 +10,7 @@ import { Imgur } from "../Logic/ImageProviders/Imgur"
import { LicenseInfo } from "../Logic/ImageProviders/LicenseInfo"
import { Utils } from "../Utils"
import Constants from "../Models/Constants"
import {concat} from "svelte-preprocess/dist/modules/utils";
export default class GenerateImageAnalysis extends Script {
constructor() {
@ -213,8 +214,9 @@ export default class GenerateImageAnalysis extends Script {
const speed = handled / runningTime
const timeLeft = Math.round(itemsLeft * speed)
try {
const urls = url.split(/[;,]/)
const downloadedStatus = await Promise.all(
url.split(";").map((url) => this.downloadImage(url.trim(), imagePath))
urls.map((url) => this.downloadImage(url.trim(), imagePath))
)
for (const b of downloadedStatus) {