Last active
December 12, 2025 12:17
-
-
Save 5ouma/92b4478ed374ce42a6222315d35a3bf1 to your computer and use it in GitHub Desktop.
π€ Download decomoji images from collected JSON file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { basename } from "jsr:@std/path"; | |
| import { | |
| array, | |
| object, | |
| parse, | |
| pipe, | |
| regex, | |
| string, | |
| } from "jsr:@valibot/valibot"; | |
| const baseUrl = | |
| "https://raw.githubusercontent.com/decomoji/decomoji/refs/heads/main"; | |
| const dir = "decomoji"; | |
| const decomojiSchema = array( | |
| object({ path: pipe(string(), regex(/^decomoji\/(basic|extra).+\.png$/)) }), | |
| ); | |
| const data = Deno.readTextFileSync("my-collected.json"); | |
| const decomojis = parse(decomojiSchema, JSON.parse(data)); | |
| Deno.mkdirSync(dir, { recursive: true }); | |
| for (const decomoji of decomojis) { | |
| const url = `${baseUrl}/${decomoji.path}`; | |
| const response = await fetch(url); | |
| if (!response.ok) { | |
| console.error(`Failed to download ${url}`); | |
| continue; | |
| } | |
| Deno.writeFileSync( | |
| `${dir}/${basename(decomoji.path).replaceAll("-", "_")}`, | |
| new Uint8Array(await response.arrayBuffer()), | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.