mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-08-20 17:45:10 -05:00
Use the previous updated timestamp from SplatNet 2 to check for updates
This prevents redownloading (or missing data) if the local system time is slightly different to SplatNet 2's time.
This commit is contained in:
@@ -272,6 +272,8 @@ ${colour}
|
||||
const mn = body.match(/<html(?:\s+[a-z0-9-]+(?:=(?:"[^"]*"|[^\s>]*))?)*\s+data-nsa-id=(?:"([^"]*)"|([^\s>]*))/i);
|
||||
const [language, region, user_id, nsa_id] = [ml, mr, mu, mn].map(m => m?.[1] || m?.[2] || null);
|
||||
|
||||
debug('SplatNet 2 user', {language, region, user_id, nsa_id});
|
||||
|
||||
return {
|
||||
webserviceToken,
|
||||
url: url.toString(),
|
||||
|
||||
@@ -123,9 +123,9 @@ export async function dumpRecords(
|
||||
|
||||
if (updated) {
|
||||
try {
|
||||
const {timestamp} = JSON.parse(await fs.readFile(latest_file, 'utf-8'));
|
||||
const {sn2_updated_timestamp} = JSON.parse(await fs.readFile(latest_file, 'utf-8'));
|
||||
|
||||
if (timestamp > updated.getTime()) {
|
||||
if ((sn2_updated_timestamp * 1000) >= updated.getTime()) {
|
||||
debug('Skipping user records, not updated');
|
||||
return;
|
||||
}
|
||||
@@ -133,6 +133,8 @@ export async function dumpRecords(
|
||||
}
|
||||
|
||||
const timestamp = Date.now();
|
||||
const sn2_updated_timestamp = records.records.update_time;
|
||||
|
||||
const filename = 'splatnet2-records-' + user_id + '-' + timestamp + '.json';
|
||||
const file = path.join(directory, filename);
|
||||
const ni_filename = 'splatnet2-ni-' + user_id + '-' + timestamp + '.json';
|
||||
@@ -144,7 +146,7 @@ export async function dumpRecords(
|
||||
debug('Writing records %s', ni_filename);
|
||||
await fs.writeFile(ni_file, JSON.stringify(nickname_and_icon, null, 4) + '\n', 'utf-8');
|
||||
|
||||
await fs.writeFile(latest_file, JSON.stringify({timestamp}, null, 4) + '\n', 'utf-8');
|
||||
await fs.writeFile(latest_file, JSON.stringify({timestamp, sn2_updated_timestamp}, null, 4) + '\n', 'utf-8');
|
||||
}
|
||||
|
||||
export async function dumpProfileImage(
|
||||
|
||||
@@ -147,9 +147,9 @@ export class SplatNet2RecordsMonitor extends Loop {
|
||||
const updated = new Date(records.records.update_time * 1000);
|
||||
|
||||
try {
|
||||
const {timestamp} = JSON.parse(await fs.readFile(latest_file, 'utf-8'));
|
||||
const {sn2_updated_timestamp} = JSON.parse(await fs.readFile(latest_file, 'utf-8'));
|
||||
|
||||
return timestamp <= updated.getTime();
|
||||
return (sn2_updated_timestamp * 1000) < updated.getTime();
|
||||
} catch (err) {}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user