Skip to content

Instantly share code, notes, and snippets.

@leemartin
Created September 11, 2018 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemartin/efa5a2717c7780b31a29c34ee613a7bc to your computer and use it in GitHub Desktop.
Save leemartin/efa5a2717c7780b31a29c34ee613a7bc to your computer and use it in GitHub Desktop.
Download Instagram Videos
// 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