mirror of
https://github.com/PretendoNetwork/BOSS.git
synced 2026-08-19 23:54:08 -05:00
chore: add .editorconfig and move scripts into folder, remove logger as unused
This commit is contained in:
22
scripts/encrypt-contents.js
Normal file
22
scripts/encrypt-contents.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const BOSS = require('boss-js');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const crypto = require('crypto');
|
||||
require('dotenv').config();
|
||||
|
||||
const { PN_BOSS_CONFIG_BOSS_WIIU_AES_KEY, PN_BOSS_CONFIG_BOSS_WIIU_HMAC_KEY } = process.env;
|
||||
|
||||
const decryptedFilePath = path.normalize(path.resolve(__dirname, process.argv[2]));
|
||||
const encryptedFolderName = path.basename(path.dirname(decryptedFilePath));
|
||||
const encryptedFolderPath = path.normalize(path.resolve(decryptedFilePath, '../../../encrypted', encryptedFolderName));
|
||||
|
||||
fs.ensureDirSync(encryptedFolderPath);
|
||||
|
||||
const encryptedContents = BOSS.encryptWiiU(decryptedFilePath, PN_BOSS_CONFIG_BOSS_WIIU_AES_KEY, PN_BOSS_CONFIG_BOSS_WIIU_HMAC_KEY);
|
||||
const hash = crypto.createHash('md5').update(encryptedContents).digest('hex');
|
||||
|
||||
const encryptedFilePath = path.normalize(path.resolve(encryptedFolderPath, hash));
|
||||
|
||||
fs.writeFileSync(encryptedFilePath, encryptedContents);
|
||||
|
||||
console.log(`Encrypted ${process.argv[2].split('/').pop()} to ${encryptedFilePath}, (Length ${encryptedContents.length})`);
|
||||
136
scripts/scrape.js
Normal file
136
scripts/scrape.js
Normal file
@@ -0,0 +1,136 @@
|
||||
const fs = require('fs-extra');
|
||||
const https = require('https');
|
||||
const axios = require('axios');
|
||||
const { convert: xmlParser } = require('xmlbuilder2');
|
||||
|
||||
const { get } = axios.create({
|
||||
httpsAgent: new https.Agent({
|
||||
rejectUnauthorized: false
|
||||
})
|
||||
});
|
||||
|
||||
const TASKSHEET_BASE = 'https://npts.app.nintendo.net/p01/tasksheet/1';
|
||||
const TASKSHEET_BASE_NEW = 'https://npts.app.pretendo.cc/p01/tasksheet/1';
|
||||
|
||||
const TASKSHEETS = [
|
||||
{
|
||||
id: '8UsM86l8xgkjFk8z',
|
||||
files: ['wood1', 'woodBGM']
|
||||
},
|
||||
{
|
||||
id: 'bb6tOEckvgZ50ciH',
|
||||
files: ['optdat2', 'schdat2']
|
||||
},
|
||||
{
|
||||
id: 'bieC9ACJlisFg5xS',
|
||||
files: ['solv']
|
||||
},
|
||||
{
|
||||
id: 'IeUc4hQsKKe9rJHB',
|
||||
files: ['CHARA']
|
||||
},
|
||||
{
|
||||
id: 'IXmFUqR2qenXfF61',
|
||||
files: ['promo1', 'promo2', 'promo3', 'push']
|
||||
},
|
||||
{
|
||||
id: 'LRmanFo4Tx3kEGDp',
|
||||
files: ['sysmsg1', 'sysmsg2']
|
||||
},
|
||||
{
|
||||
id: 'rjVlM7hUXPxmYQJh',
|
||||
files: ['optdat2', 'schdat2']
|
||||
},
|
||||
{
|
||||
id: 'tOaQcoBLtPTgVN3Y',
|
||||
files: ['solv']
|
||||
},
|
||||
{
|
||||
id: 'TZr27FE8wzKiEaTO',
|
||||
files: ['sysmsg1', 'sysmsg2']
|
||||
},
|
||||
{
|
||||
id: 'v1cqzWykBKUg0rHQ',
|
||||
files: ['solv']
|
||||
},
|
||||
{
|
||||
id: 'vGwChBW1ExOoHDsm',
|
||||
files: ['CHARA', 'CHARA/Boss002.pack', 'CHARA/BossStatic002.pack']
|
||||
},
|
||||
{
|
||||
id: 'zvGSM4kOrXpkKnpT',
|
||||
files: ['optdat2', 'schdat2']
|
||||
},
|
||||
{
|
||||
id: 'VFoY6V7u7UUq1EG5',
|
||||
files: ['olvinfo']
|
||||
},
|
||||
{
|
||||
id: 'WJDaV6ePVgrS0TRa',
|
||||
files: ['olvinfo']
|
||||
},
|
||||
{
|
||||
id: '8MNOVprfNVAJjfCM',
|
||||
files: ['olvinfo']
|
||||
},
|
||||
{
|
||||
id: '07E3nY6lAwlwrQRo',
|
||||
files: ['wood1', 'woodBGM']
|
||||
},
|
||||
{
|
||||
id: 'RaPn5saabzliYrpo',
|
||||
files: ['news']
|
||||
},
|
||||
{
|
||||
id: 'pO72Hi5uqf5yuNd8',
|
||||
files: ['sp1_ans']
|
||||
}
|
||||
];
|
||||
|
||||
for (const tasksheet of TASKSHEETS) {
|
||||
const tasksheetId = tasksheet.id;
|
||||
|
||||
fs.ensureDirSync(`cdn/tasksheet/1/${tasksheetId}`);
|
||||
fs.ensureDirSync(`cdn/content/encrypted/${tasksheetId}`);
|
||||
|
||||
for (const tasksheetFileName of tasksheet.files) {
|
||||
if (tasksheetFileName.includes('/')) {
|
||||
fs.ensureDirSync(`cdn/tasksheet/1/${tasksheetId}/_subfolder`);
|
||||
}
|
||||
|
||||
get(`${TASKSHEET_BASE}/${tasksheetId}/${tasksheetFileName}?c=US&l=en`)
|
||||
.then(response => {
|
||||
const replacedUrls = response.data.replaceAll('nintendo.net', 'pretendo.cc');
|
||||
|
||||
if (tasksheetFileName.includes('/')) {
|
||||
fs.writeFileSync(`cdn/tasksheet/1/${tasksheetId}/_subfolder/${tasksheetFileName}`, replacedUrls);
|
||||
} else {
|
||||
fs.writeFileSync(`cdn/tasksheet/1/${tasksheetId}/${tasksheetFileName}`, replacedUrls);
|
||||
}
|
||||
|
||||
const { TaskSheet: xml } = xmlParser(response.data, { format: "object" });
|
||||
const files = xml.Files.File || [];
|
||||
|
||||
if (files instanceof Array) {
|
||||
for (const contentFile of files) {
|
||||
const fileName = contentFile.Url.split('/').pop();
|
||||
|
||||
get(contentFile.Url, {
|
||||
responseType: 'arraybuffer',
|
||||
}).then(response => {
|
||||
fs.writeFileSync(`cdn/content/encrypted/${tasksheetId}/${fileName}`, response.data);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const contentFile = files; // Only one file
|
||||
const fileName = contentFile.Url.split('/').pop();
|
||||
|
||||
get(contentFile.Url, {
|
||||
responseType: 'arraybuffer',
|
||||
}).then(response => {
|
||||
fs.writeFileSync(`cdn/content/encrypted/${tasksheetId}/${fileName}`, response.data);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user