Created
September 11, 2018 22:51
-
-
Save leemartin/efa5a2717c7780b31a29c34ee613a7bc to your computer and use it in GitHub Desktop.
Download Instagram Videos
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
// node instagram-dl.js BnmcJ-tnAey | |
const rest = require('restler') | |
const fs = require('fs') | |
const request = require('request') | |
rest.get(`https://www.instagram.com/p/${process.argv.slice(2)[0]}/?__a=1`).on('complete', function(data) { | |
var videoUrl = data.graphql.shortcode_media.video_url | |
var videoFilename = videoUrl.split("/")[videoUrl.split("/").length - 1] | |
Promise.resolve() | |
.then(() => new Promise((resolve, revoke) => { | |
let writeStream = fs.createWriteStream(`videos/${videoFilename}`) | |
writeStream.on('finish', resolve) | |
writeStream.on('error', revoke) | |
request(videoUrl).pipe(writeStream) | |
}) | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment