-
-
Save Rokt33r/48643041c265a542557a1254bc11416c to your computer and use it in GitHub Desktop.
got download pipe
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
'use strict' | |
const got = require('got') | |
const fs = require('fs') | |
const path = require('path') | |
let beta = fs.readFileSync(path.join(__dirname, 'beta.json')) | |
beta = JSON.parse(beta) | |
let data = [] | |
for (let key in beta) { | |
let category = beta[key] | |
category.forEach((_item) => { | |
let item = Object.assign(_item, {category: key}) | |
data.push(item) | |
}) | |
} | |
try { | |
fs.mkdirSync(path.join(__dirname, 'download')) | |
} catch (err) { | |
} | |
data.forEach((item) => { | |
got.stream(item.img).pipe(fs.createWriteStream(path.join(__dirname, 'download', item.id + '.jpeg'))) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment