Last active
October 2, 2024 23:18
-
-
Save maacpiash/2c3479c1c35fe3d5289e2f5a15d1b32d to your computer and use it in GitHub Desktop.
Download all HD wallpapers from MKBHD's panels.art website
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 { createWriteStream } from 'fs' | |
import { Readable } from 'stream' | |
import dump from './media-1a-i-p~s.json' with { type: 'json' } | |
// JSON dump link: https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s | |
const urls = [] | |
const KEY = 'dhd' | |
for (let id in dump.data) { | |
if (Object.hasOwn(dump.data[id], KEY)) | |
urls.push(dump.data[id]['dhd']) | |
} | |
const downloadWallpaper = async (url) => { | |
const fileName = url.split('/').pop().split('?')[0] | |
const resp = await fetch(url) | |
if (resp.ok && resp.body) { | |
let writer = createWriteStream(fileName); | |
Readable.fromWeb(resp.body).pipe(writer); | |
} | |
} | |
const forEachSeries = async (iterable, action) => { | |
for (const x of iterable) { | |
await action(x) | |
} | |
} | |
forEachSeries(urls, downloadWallpaper) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment