Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/heads.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ await bufferUnordered(items, async item => {

await bufferUnordered(heads, async item => {
if (!item.texture || await fs.promises.stat(`./assets/textures/${item.id}.png`).then(() => true).catch(e => false))
return console.log(`Skipped "${item.name}" ${++i}/${items.length}...`);
return console.log(`Skipped "${item.name}" ${++i}/${heads.length}...`);

const { data: buf } = await axios.get(`https://sky.shiiyu.moe/head/${item.texture}`, {
const { data: buf } = await axios.get(`https://sky.shiiiyu.moe/head/${item.texture}`, {
responseType: 'arraybuffer'
});

Expand Down
15 changes: 9 additions & 6 deletions scripts/materials.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const ORDER = [
];

const ANIMATE_REGEX = /_(\d+)\.[^.]+$/;
const MAX_HEAD_DOWNLOAD_ATTEMPTS = 3;

fs.mkdirSync('./assets/materials', { recursive: true });
fs.mkdirSync('./assets/textures', { recursive: true });
Expand Down Expand Up @@ -68,11 +69,9 @@ for (const name of ORDER) {
const texture = data.textures.SKIN.url;
const id = texture.slice(texture.lastIndexOf('/') + 1);

let tryagain = true;

while (tryagain) {
for (let attempt = 1; attempt <= MAX_HEAD_DOWNLOAD_ATTEMPTS; attempt++) {
try {
const { data: buf } = await axios.get(`https://sky.shiiyu.moe/head/${id}`, {
const { data: buf } = await axios.get(`https://sky.shiiiyu.moe/head/${id}`, {
responseType: 'arraybuffer'
});

Expand All @@ -83,10 +82,14 @@ for (const name of ORDER) {
})
.toFile(`./assets/materials/${name.replace(/:/g, ';').toUpperCase()}.png`);

tryagain = false;

console.log(`[MATERIAL] Processed "${name}" (${path})`);
break;
} catch (e) {
if (attempt === MAX_HEAD_DOWNLOAD_ATTEMPTS) {
console.error(`Failed to download head texture "${id}" after ${attempt} attempts`, e);
break;
}

console.error(e);
}
}
Expand Down