Skip to content

Commit

Permalink
scripts: Add avatars fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
schneefux committed Nov 14, 2023
1 parent 6436e13 commit c48605c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/download_maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ async function main() {
const icons = await getStarlistIcons()
await fs.mkdir('./out/avatars', { recursive: true })
for (const icon of [].concat(Object.values(icons.player), Object.values(icons.club))) {
await pipeline((await fetch(icon.imageUrl)).body, createWriteStream('./out/avatars/' + icon.id + '.png'))
// Brawlify does not update avatar icons anymore, fall back to Brawlace
for (const imageUrl of [icon.imageUrl, `https://brawlace.com/assets/images/brawlstars/icons-players/${icon.id}.png`]) {
const res = await fetch(imageUrl)
if (res.ok) {
await pipeline(res.body, createWriteStream('./out/avatars/' + icon.id + '.png'))
break
}
}
await sleep(500)
}

Expand Down

0 comments on commit c48605c

Please sign in to comment.