-
-
Save jpluimers/a4c1253b968f7d5bc41715e5cfee4309 to your computer and use it in GitHub Desktop.
Download all HD wallpapers from MKBHD's panels.art website
This file contains 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