mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-08-20 07:34:28 -05:00
Add festival data updater
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import GearUpdater from "./updaters/GearUpdater.mjs";
|
||||
import StageScheduleUpdater from "./updaters/StageScheduleUpdater.mjs";
|
||||
import CoopUpdater from "./updaters/CoopUpdater.mjs";
|
||||
import FestivalUpdater from "./updaters/FestivalUpdater.mjs";
|
||||
|
||||
function updaters() {
|
||||
return [
|
||||
new StageScheduleUpdater,
|
||||
new GearUpdater,
|
||||
new CoopUpdater,
|
||||
new FestivalUpdater('NA'),
|
||||
new FestivalUpdater('EU'),
|
||||
new FestivalUpdater('JP'),
|
||||
new FestivalUpdater('AP'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,13 @@ export default class DataUpdater
|
||||
this.imageProcessor = new ImageProcessor;
|
||||
}
|
||||
|
||||
get region() {
|
||||
return this.splatnet.nsoClient.region;
|
||||
}
|
||||
|
||||
/** @type {Console} */
|
||||
get console() {
|
||||
this._console ??= prefixedConsole('Updater', this.splatnet.nsoClient.region, this.name);
|
||||
this._console ??= prefixedConsole('Updater', this.region, this.name);
|
||||
|
||||
return this._console;
|
||||
}
|
||||
@@ -78,7 +82,7 @@ export default class DataUpdater
|
||||
// File handling
|
||||
|
||||
async saveData(data) {
|
||||
let s = this.formatDataForWrite(data);
|
||||
let s = await this.formatDataForWrite(data);
|
||||
|
||||
await this.writeFile(this.getPath(this.filename), s);
|
||||
|
||||
@@ -91,7 +95,7 @@ export default class DataUpdater
|
||||
return `${this.outputDirectory}/${filename}.json`;
|
||||
}
|
||||
|
||||
formatDataForWrite(data) {
|
||||
async formatDataForWrite(data) {
|
||||
// If we're running in debug mode, format the JSON output so it's easier to read
|
||||
let debug = !!process.env.DEBUG;
|
||||
let space = debug ? 2 : undefined;
|
||||
|
||||
32
app/data/updaters/FestivalUpdater.mjs
Normal file
32
app/data/updaters/FestivalUpdater.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
import fs from 'fs/promises';
|
||||
import DataUpdater from "./DataUpdater.mjs";
|
||||
|
||||
export default class FestivalUpdater extends DataUpdater
|
||||
{
|
||||
name = 'Festivals';
|
||||
filename = 'festivals';
|
||||
|
||||
imagePaths = [
|
||||
'$..image.url',
|
||||
];
|
||||
|
||||
getData() {
|
||||
return this.splatnet.getFestRecordData();
|
||||
}
|
||||
|
||||
async formatDataForWrite(data) {
|
||||
// Combine this region's data with the other regions' data.
|
||||
let result = null;
|
||||
try {
|
||||
result = await fs.readFile(this.getPath(this.filename));
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
|
||||
result = result ? JSON.parse(result) : {};
|
||||
|
||||
result[this.region] = data;
|
||||
|
||||
return super.formatDataForWrite(result);
|
||||
}
|
||||
}
|
||||
@@ -124,4 +124,8 @@ export default class SplatNet3Client
|
||||
getCoopHistoryData() {
|
||||
return this.getGraphQLPersistedQuery(1, '817618ce39bcf5570f52a97d73301b30');
|
||||
}
|
||||
|
||||
getFestRecordData() {
|
||||
return this.getGraphQLPersistedQuery(1, '44c76790b68ca0f3da87f2a3452de986');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user