From 476b0762d43035253a3929350a23a4f453169df6 Mon Sep 17 00:00:00 2001 From: kSlide Date: Fri, 6 Aug 2021 06:06:50 +0000 Subject: [PATCH] add console.logs for download URLs as configuration option --- src/configuration.json.example | 1 + src/converters/effect/EffectDownloader.ts | 8 ++++++++ src/converters/effectmap/EffectMapDownloader.ts | 4 ++++ src/converters/externaltexts/ExternalTextsDownloader.ts | 4 ++++ src/converters/figure/FigureDownloader.ts | 8 ++++++++ src/converters/figuremap/FigureMapDownloader.ts | 4 ++++ src/converters/furniture/FurnitureDownloader.ts | 8 ++++++++ src/converters/furnituredata/FurnitureDataDownloader.ts | 7 ++++++- src/converters/productdata/ProductDataDownloader.ts | 4 ++++ 9 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/configuration.json.example b/src/configuration.json.example index 8ce9e62..9a43ccc 100644 --- a/src/configuration.json.example +++ b/src/configuration.json.example @@ -18,4 +18,5 @@ "convert.effect": "1", "convert.furniture": "1", "convert.pet": "1" + "misc.log_download_urls": "0" } diff --git a/src/converters/effect/EffectDownloader.ts b/src/converters/effect/EffectDownloader.ts index 3ee92ce..0fa1f79 100644 --- a/src/converters/effect/EffectDownloader.ts +++ b/src/converters/effect/EffectDownloader.ts @@ -63,6 +63,10 @@ export class EffectDownloader if(!url || !url.length) return null; + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading effect map from ${url}`); + const content = await FileUtilities.readFileAsString(url); if(!content || !content.length) return null; @@ -78,6 +82,10 @@ export class EffectDownloader url = url.replace('%className%', className); + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading effect from ${url}`); + const buffer = await FileUtilities.readFileAsBuffer(url); if(!buffer) return; diff --git a/src/converters/effectmap/EffectMapDownloader.ts b/src/converters/effectmap/EffectMapDownloader.ts index 0cbb410..8be56d2 100644 --- a/src/converters/effectmap/EffectMapDownloader.ts +++ b/src/converters/effectmap/EffectMapDownloader.ts @@ -23,6 +23,10 @@ export class EffectMapDownloader if(!url || !url.length) return null; + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading effect map from ${url}`); + const content = await FileUtilities.readFileAsString(url); if(!content || !content.length) return null; diff --git a/src/converters/externaltexts/ExternalTextsDownloader.ts b/src/converters/externaltexts/ExternalTextsDownloader.ts index 709dbb2..0edbc8b 100644 --- a/src/converters/externaltexts/ExternalTextsDownloader.ts +++ b/src/converters/externaltexts/ExternalTextsDownloader.ts @@ -23,6 +23,10 @@ export class ExternalTextsDownloader if(!url || !url.length) return null; + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading external texts from ${url}`); + const content = await FileUtilities.readFileAsString(url); if(!content || !content.length) return null; diff --git a/src/converters/figure/FigureDownloader.ts b/src/converters/figure/FigureDownloader.ts index f7878a7..3ff7e4d 100644 --- a/src/converters/figure/FigureDownloader.ts +++ b/src/converters/figure/FigureDownloader.ts @@ -65,6 +65,10 @@ export class FigureDownloader if(!url || !url.length) return null; + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading figure data from ${url}`); + const content = await FileUtilities.readFileAsString(url); if(!content || !content.length) return null; @@ -80,6 +84,10 @@ export class FigureDownloader url = url.replace('%className%', className); + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading figure from ${url}`); + const buffer = await FileUtilities.readFileAsBuffer(url); if(!buffer) return; diff --git a/src/converters/figuremap/FigureMapDownloader.ts b/src/converters/figuremap/FigureMapDownloader.ts index 179c72a..92e3adf 100644 --- a/src/converters/figuremap/FigureMapDownloader.ts +++ b/src/converters/figuremap/FigureMapDownloader.ts @@ -23,6 +23,10 @@ export class FigureMapDownloader if(!url || !url.length) return null; + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading figure map from ${url}`); + const content = await FileUtilities.readFileAsString(url); if(!content || !content.length) return null; diff --git a/src/converters/furniture/FurnitureDownloader.ts b/src/converters/furniture/FurnitureDownloader.ts index b52470c..df4b920 100644 --- a/src/converters/furniture/FurnitureDownloader.ts +++ b/src/converters/furniture/FurnitureDownloader.ts @@ -104,6 +104,10 @@ export class FurnitureDownloader if(!url || !url.length) return null; + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading furniture data from ${url}`); + const content = await FileUtilities.readFileAsString(url); if(!content || !content.length) return null; @@ -120,6 +124,10 @@ export class FurnitureDownloader url = url.replace('%revision%', revision.toString()); url = url.replace('%className%', className); + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading furniture from ${url}`); + const buffer = await FileUtilities.readFileAsBuffer(url); if(!buffer) return; diff --git a/src/converters/furnituredata/FurnitureDataDownloader.ts b/src/converters/furnituredata/FurnitureDataDownloader.ts index 53b7a2e..d3abee8 100644 --- a/src/converters/furnituredata/FurnitureDataDownloader.ts +++ b/src/converters/furnituredata/FurnitureDataDownloader.ts @@ -6,7 +6,8 @@ import { FileUtilities } from '../../utils/FileUtilities'; export class FurnitureDataDownloader { constructor(private readonly _configuration: Configuration) - {} + { + } public async download(callback: (content: string) => Promise): Promise { @@ -23,6 +24,10 @@ export class FurnitureDataDownloader if(!url || !url.length) return null; + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading furniture data from ${url}`); + const content = await FileUtilities.readFileAsString(url); if(!content || !content.length) return null; diff --git a/src/converters/productdata/ProductDataDownloader.ts b/src/converters/productdata/ProductDataDownloader.ts index b769f75..1d7dced 100644 --- a/src/converters/productdata/ProductDataDownloader.ts +++ b/src/converters/productdata/ProductDataDownloader.ts @@ -23,6 +23,10 @@ export class ProductDataDownloader if(!url || !url.length) return null; + const logDownloads = this._configuration.getBoolean('misc.log_download_urls'); + + if(logDownloads) console.log(` Downloading product data from ${url}`); + const content = await FileUtilities.readFileAsString(url); if(!content || !content.length) return null;