Fix various download issues

This commit is contained in:
Bill 2021-02-23 14:40:36 -05:00
parent 27c8aa6728
commit 8f78267712
10 changed files with 187 additions and 152 deletions

View File

@ -12,10 +12,10 @@
"dynamic.download.furniture.url": "${flash.dynamic.download.url}%revision%/%className%.swf", "dynamic.download.furniture.url": "${flash.dynamic.download.url}%revision%/%className%.swf",
"external.variables.url": "https://www.habbo.com/gamedata/external_variables/1", "external.variables.url": "https://www.habbo.com/gamedata/external_variables/1",
"external.texts.url": "${external.texts.txt}", "external.texts.url": "${external.texts.txt}",
"convert.productdata": "0", "convert.productdata": "1",
"convert.externaltexts": "0", "convert.externaltexts": "1",
"convert.figure": "0", "convert.figure": "1",
"convert.effect": "0", "convert.effect": "1",
"convert.furniture": "0", "convert.furniture": "1",
"convert.pet": "0" "convert.pet": "1"
} }

View File

@ -33,7 +33,7 @@ export class EffectDownloader
const existingFile = new File(directory.path + '/' + className + '.nitro'); const existingFile = new File(directory.path + '/' + className + '.nitro');
if(existingFile.isDirectory()) continue; if(existingFile.exists()) continue;
if(classNames.indexOf(className) >= 0) continue; if(classNames.indexOf(className) >= 0) continue;

View File

@ -23,45 +23,52 @@ export class EffectMapConverter extends Converter
public async convertAsync(): Promise<void> public async convertAsync(): Promise<void>
{ {
const now = Date.now(); return new Promise((resolve, reject) =>
const spinner = ora('Preparing EffectMap').start();
const directory = this.getDirectory();
try
{ {
await this._effectMapDownloader.download(async (content: string) => const now = Date.now();
const spinner = ora('Preparing EffectMap').start();
const directory = this.getDirectory();
try
{ {
spinner.text = 'Parsing EffectMap'; this._effectMapDownloader.download(async (content: string) =>
spinner.render();
let effectMapString = content;
if(!effectMapString.startsWith('{'))
{ {
const xml = await parseStringPromise(effectMapString); spinner.text = 'Parsing EffectMap';
const effectMap = await this.mapXML2JSON(xml); spinner.render();
effectMapString = JSON.stringify(effectMap); let effectMapString = content;
}
const path = directory.path + '/EffectMap.json'; if(!effectMapString.startsWith('{'))
{
const xml = await parseStringPromise(effectMapString);
await writeFile(path, effectMapString, 'utf8'); const effectMap = await this.mapXML2JSON(xml);
this._configuration.setValue('effectmap.load.url', path); effectMapString = JSON.stringify(effectMap);
}); }
spinner.succeed(`EffectMap finished in ${ Date.now() - now }ms`); const path = directory.path + '/EffectMap.json';
}
catch (error) await writeFile(path, effectMapString, 'utf8');
{
spinner.fail('EffectMap failed: ' + error.message); this._configuration.setValue('effectmap.load.url', path);
}
spinner.succeed(`EffectMap finished in ${ Date.now() - now }ms`);
resolve();
});
}
catch (error)
{
spinner.fail('EffectMap failed: ' + error.message);
reject(error);
}
});
} }
private getDirectory(): File private getDirectory(): File

View File

@ -23,41 +23,48 @@ export class ExternalTextsConverter extends Converter
{ {
if(!this._configuration.getBoolean('convert.externaltexts')) return; if(!this._configuration.getBoolean('convert.externaltexts')) return;
const now = Date.now(); return new Promise((resolve, reject) =>
const spinner = ora('Preparing ExternalTexts').start();
const directory = this.getDirectory();
try
{ {
await this._externalTextsDownloader.download(async (content: string) => const now = Date.now();
const spinner = ora('Preparing ExternalTexts').start();
const directory = this.getDirectory();
try
{ {
spinner.text = 'Parsing ExternalTexts'; this._externalTextsDownloader.download(async (content: string) =>
spinner.render();
let externalTextsString = content;
if(!externalTextsString.startsWith('{'))
{ {
const externalTexts = await this.mapText2JSON(externalTextsString); spinner.text = 'Parsing ExternalTexts';
externalTextsString = JSON.stringify(externalTexts); spinner.render();
}
const path = directory.path + '/ExternalTexts.json'; let externalTextsString = content;
await writeFile(path, externalTextsString, 'utf8'); if(!externalTextsString.startsWith('{'))
}); {
const externalTexts = await this.mapText2JSON(externalTextsString);
spinner.succeed(`ExternalTexts finished in ${ Date.now() - now }ms`); externalTextsString = JSON.stringify(externalTexts);
} }
catch (error) const path = directory.path + '/ExternalTexts.json';
{
spinner.fail('ExternalTexts failed: ' + error.message); await writeFile(path, externalTextsString, 'utf8');
}
spinner.succeed(`ExternalTexts finished in ${ Date.now() - now }ms`);
resolve();
});
}
catch (error)
{
spinner.fail('ExternalTexts failed: ' + error.message);
reject(error);
}
});
} }
private getDirectory(): File private getDirectory(): File

View File

@ -33,7 +33,7 @@ export class FigureDownloader
const existingFile = new File(directory.path + '/' + className + '.nitro'); const existingFile = new File(directory.path + '/' + className + '.nitro');
if(existingFile.isDirectory()) continue; if(existingFile.exists()) continue;
if(className === 'hh_human_fx' || className === 'hh_pets') continue; if(className === 'hh_human_fx' || className === 'hh_pets') continue;

View File

@ -23,45 +23,52 @@ export class FigureMapConverter extends Converter
public async convertAsync(): Promise<void> public async convertAsync(): Promise<void>
{ {
const now = Date.now(); return new Promise((resolve, reject) =>
const spinner = ora('Preparing FigureMap').start();
const directory = this.getDirectory();
try
{ {
await this._figureMapDownloader.download(async (content: string) => const now = Date.now();
const spinner = ora('Preparing FigureMap').start();
const directory = this.getDirectory();
try
{ {
spinner.text = 'Parsing FigureMap'; this._figureMapDownloader.download(async (content: string) =>
spinner.render();
let figureMapString = content;
if(!figureMapString.startsWith('{'))
{ {
const xml = await parseStringPromise(figureMapString); spinner.text = 'Parsing FigureMap';
const figureMap = await this.mapXML2JSON(xml); spinner.render();
figureMapString = JSON.stringify(figureMap); let figureMapString = content;
}
const path = directory.path + '/FigureMap.json'; if(!figureMapString.startsWith('{'))
{
const xml = await parseStringPromise(figureMapString);
await writeFile(path, figureMapString, 'utf8'); const figureMap = await this.mapXML2JSON(xml);
this._configuration.setValue('figuremap.load.url', path); figureMapString = JSON.stringify(figureMap);
}); }
spinner.succeed(`FigureMap finished in ${ Date.now() - now }ms`); const path = directory.path + '/FigureMap.json';
}
catch (error) await writeFile(path, figureMapString, 'utf8');
{
spinner.fail('FigureMap failed: ' + error.message); this._configuration.setValue('figuremap.load.url', path);
}
spinner.succeed(`FigureMap finished in ${ Date.now() - now }ms`);
resolve();
});
}
catch (error)
{
spinner.fail('FigureMap failed: ' + error.message);
reject(error);
}
});
} }
private getDirectory(): File private getDirectory(): File

View File

@ -37,7 +37,7 @@ export class FurnitureDownloader
const existingFile = new File(directory.path + '/' + className + '.nitro'); const existingFile = new File(directory.path + '/' + className + '.nitro');
if(existingFile.isDirectory()) continue; if(existingFile.exists()) continue;
if(classNames.indexOf(className) >= 0) continue; if(classNames.indexOf(className) >= 0) continue;
@ -68,7 +68,7 @@ export class FurnitureDownloader
const existingFile = new File(directory.path + '/' + className + '.nitro'); const existingFile = new File(directory.path + '/' + className + '.nitro');
if(existingFile.isDirectory()) continue; if(existingFile.exists()) continue;
if(classNames.indexOf(className) >= 0) continue; if(classNames.indexOf(className) >= 0) continue;

View File

@ -23,45 +23,52 @@ export class FurnitureDataConverter extends Converter
public async convertAsync(): Promise<void> public async convertAsync(): Promise<void>
{ {
const now = Date.now(); return new Promise((resolve, reject) =>
const spinner = ora('Preparing FurnitureData').start();
const directory = this.getDirectory();
try
{ {
await this._furnitureDataDownloader.download(async (content: string) => const now = Date.now();
const spinner = ora('Preparing FurnitureData').start();
const directory = this.getDirectory();
try
{ {
spinner.text = 'Parsing FurnitureData'; this._furnitureDataDownloader.download(async (content: string) =>
spinner.render();
let furnitureDataString = content;
if(!furnitureDataString.startsWith('{'))
{ {
const xml = await parseStringPromise(furnitureDataString); spinner.text = 'Parsing FurnitureData';
const furnitureData = await this.mapXML2JSON(xml); spinner.render();
furnitureDataString = JSON.stringify(furnitureData); let furnitureDataString = content;
}
const path = directory.path + '/FurnitureData.json'; if(!furnitureDataString.startsWith('{'))
{
const xml = await parseStringPromise(furnitureDataString);
await writeFile(path, furnitureDataString, 'utf8'); const furnitureData = await this.mapXML2JSON(xml);
this._configuration.setValue('furnidata.load.url', path); furnitureDataString = JSON.stringify(furnitureData);
}); }
spinner.succeed(`FurnitureData finished in ${ Date.now() - now }ms`); const path = directory.path + '/FurnitureData.json';
}
catch (error) await writeFile(path, furnitureDataString, 'utf8');
{
spinner.fail('FurnitureData failed: ' + error.message); this._configuration.setValue('furnidata.load.url', path);
}
spinner.succeed(`FurnitureData finished in ${ Date.now() - now }ms`);
resolve();
});
}
catch (error)
{
spinner.fail('FurnitureData failed: ' + error.message);
reject(error);
}
});
} }
private getDirectory(): File private getDirectory(): File

View File

@ -25,7 +25,7 @@ export class PetDownloader
{ {
const existingFile = new File(directory.path + '/' + petType + '.nitro'); const existingFile = new File(directory.path + '/' + petType + '.nitro');
if(existingFile.isDirectory()) continue; if(existingFile.exists()) continue;
if(classNames.indexOf(petType) >= 0) continue; if(classNames.indexOf(petType) >= 0) continue;

View File

@ -23,41 +23,48 @@ export class ProductDataConverter extends Converter
{ {
if(!this._configuration.getBoolean('convert.productdata')) return; if(!this._configuration.getBoolean('convert.productdata')) return;
const now = Date.now(); return new Promise((resolve, reject) =>
const spinner = ora('Preparing ProductData').start();
const directory = this.getDirectory();
try
{ {
await this._productDataDownloader.download(async (content: string) => const now = Date.now();
const spinner = ora('Preparing ProductData').start();
const directory = this.getDirectory();
try
{ {
spinner.text = 'Parsing FurnitureData'; this._productDataDownloader.download(async (content: string) =>
spinner.render();
let productDataString = content;
if(!productDataString.startsWith('{'))
{ {
const productData = await this.mapText2JSON(productDataString); spinner.text = 'Parsing FurnitureData';
productDataString = JSON.stringify(productData); spinner.render();
}
const path = directory.path + '/ProductData.json'; let productDataString = content;
await writeFile(path, productDataString, 'utf8'); if(!productDataString.startsWith('{'))
}); {
const productData = await this.mapText2JSON(productDataString);
spinner.succeed(`ProductData finished in ${ Date.now() - now }ms`); productDataString = JSON.stringify(productData);
} }
catch (error) const path = directory.path + '/ProductData.json';
{
spinner.fail('ProductData failed: ' + error.message); await writeFile(path, productDataString, 'utf8');
}
spinner.succeed(`ProductData finished in ${ Date.now() - now }ms`);
resolve();
});
}
catch (error)
{
spinner.fail('ProductData failed: ' + error.message);
reject(error);
}
});
} }
private getDirectory(): File private getDirectory(): File