Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Forked from maacpiash/index.js
Created September 25, 2024 15:55
Show Gist options
  • Save jpluimers/a4c1253b968f7d5bc41715e5cfee4309 to your computer and use it in GitHub Desktop.
Save jpluimers/a4c1253b968f7d5bc41715e5cfee4309 to your computer and use it in GitHub Desktop.
Download all HD wallpapers from MKBHD's panels.art website
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