mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-07-19 17:33:08 -05:00
Retrieve Splatfest ranking data for each region
This isn't currently displayed in the UI anywhere, but it will be useful for other people who wish to use it.
This commit is contained in:
parent
927012572d
commit
1dff97bd46
|
|
@ -4,8 +4,9 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
const jsonpath = require('jsonpath');
|
||||
const { readJson } = require('@/common/utilities');
|
||||
const { readJson, writeJson } = require('@/common/utilities');
|
||||
const { languages } = require('@/common/regions');
|
||||
const SplatNet = require('@/common/splatnet');
|
||||
|
||||
class FestivalsUpdater extends Updater {
|
||||
constructor(region) {
|
||||
|
|
@ -39,7 +40,7 @@ class FestivalsUpdater extends Updater {
|
|||
this.region = region;
|
||||
}
|
||||
|
||||
processData(regionData) {
|
||||
async processData(regionData) {
|
||||
// Fix alpha/bravo images for the Chicken vs. Egg Splatfest.
|
||||
// For some reason these got swapped out with images that have an opaque background
|
||||
// even though they started out with transparent images.
|
||||
|
|
@ -52,6 +53,25 @@ class FestivalsUpdater extends Updater {
|
|||
"/images/festival/d93df77468714c6211e9377f39a559f4.png"
|
||||
));
|
||||
|
||||
// Download result ranking data
|
||||
let festivalIds = jsonpath.query(regionData, '$.results..festival_id');
|
||||
for (let id of festivalIds) {
|
||||
let filename = `${this.getOutputPath()}/festivals/${this.region.toLowerCase()}-${id}-rankings.json`;
|
||||
|
||||
// Have we already downloaded these rankings?
|
||||
if (!fs.existsSync(filename)) {
|
||||
let splatnet = new SplatNet(this.region);
|
||||
this.info(`Retrieving rankings for festival ID ${id}`);
|
||||
try {
|
||||
let rankings = await this.handleRequest(splatnet.getFestivalRankings(id));
|
||||
writeJson(filename, rankings);
|
||||
}
|
||||
catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load existing data since we only need to modify this region's data
|
||||
let data = {};
|
||||
let filename = this.getFilename();
|
||||
|
|
|
|||
|
|
@ -51,13 +51,17 @@ class Updater {
|
|||
this.info('Done.');
|
||||
}
|
||||
|
||||
getOutputPath() {
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
getFilename() {
|
||||
return `${dataPath}/${this.options.filename}`;
|
||||
return `${this.getOutputPath()}/${this.options.filename}`;
|
||||
}
|
||||
|
||||
getCalendarFilename() {
|
||||
if (this.options.calendarFilename)
|
||||
return `${dataPath}/${this.options.calendarFilename}`;
|
||||
return `${this.getOutputPath()}/${this.options.calendarFilename}`;
|
||||
}
|
||||
|
||||
getData({ region, language }) {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,10 @@ class SplatNet {
|
|||
};
|
||||
}
|
||||
|
||||
getFestivalRankings(id) {
|
||||
return this.getResponse(`festivals/${id}/rankings`);
|
||||
}
|
||||
|
||||
getMerchandises() {
|
||||
return this.getResponse('onlineshop/merchandises');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user