-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
69 lines (60 loc) · 2.19 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const axios = require('axios');
const fs = require('fs');
const CHAPTER = 1; // Set to any chapter number you want
const SEASON = 10; // Limit seasons for the current chapter you set
async function is_valid_intro(intro) {
if (!intro) return false;
if ('chapter' in intro && 'season' in intro) {
// If the chapter is less than the current CHAPTER, no season limit
if (intro.chapter < CHAPTER) {
return true;
}
// If the chapter is less than or equal to the current CHAPTER, check season limit
if (intro.chapter <= CHAPTER) {
if (intro.season.match(/^\d+$/) && parseInt(intro.season) <= SEASON) {
return true;
}
}
//Check if season 10 to get season x items (this some how works???)
if (CHAPTER == 1 && SEASON == 10) {
if (intro.chapter === '1') {
return true;
}
}
}
return false;
}
async function main() {
try {
const url = "https://fortnite-api.com/v2/cosmetics/br";
const response = await axios.get(url);
const data = response.data;
const valid_items = [];
for (const item of data.data) {
const intro = item.introduction;
if (await is_valid_intro(intro)) {
const valid_item = {
id: item.id,
type: item.type?.backendValue,
rarity: item.rarity?.value,
introduction: {
chapter: intro.chapter,
season: intro.season
},
// shopHistory: item.shopHistory
};
valid_items.push(valid_item);
}
}
fs.writeFileSync('items.json', JSON.stringify(valid_items, null, 4));
console.log('Items successfully saved to items.json');
} catch (error) {
console.error('An error occurred:', error);
}
console.log('Closing the Generator in 5 seconds...');
setTimeout(() => {
console.log('Exiting...');
process.exit(0); // Exit duh
}, 5000);
}
main();