forked from uso-archive/data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpepega.js
37 lines (29 loc) · 1.16 KB
/
pepega.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require("fs").promises;
const path = require("path");
const utils = require("./lib/utils");
const uso = require("./lib/uso");
const logger = require("./lib/logger");
async function main() {
const index = {};
const files = await fs.readdir(path.resolve(__dirname, "data", "uso-styles"));
const downloadedScreenshots = await fs.readdir(path.resolve(__dirname, "data", "screenshots"));
for (const stylePath of files/*["131452.json"]*/) {
const json = JSON.parse(await fs.readFile(path.resolve(__dirname, "data", "uso-styles", stylePath)));
const h = uso.convertFromUso(json);
index[json.id] = h.indexStyle;
if (h.style.screenshots) {
if (h.style.screenshots.main) {
h.style.screenshots.main.archived = downloadedScreenshots.includes(h.style.screenshots.main.name);
}
if (h.style.screenshots.additional) {
for (const screenshot of h.style.screenshots.additional) {
screenshot.archived = downloadedScreenshots.includes(screenshot.name);
}
}
}
uso.saveStyle({ id: h.id, style: h.style });
logger.info(["Regen"], `Regenerated ${json.id}`);
}
await utils.saveIndexes(index);
}
main().catch(e => logger.error(["Regen"], e));