var fs = require('fs')
, request = require('request');
request.get('http://fs.moviestape.net/video/1c4ed0ac8b7d5b4de6c5d58e2ea31a63/serials/Narcos/s01/Narcos.S01E01.mp4')
.on('error', function(err) {
console.error(err);
})
.on('response', function(res) {
console.log(res.statusCode);
console.log(res.headers['content-type']);
})
.pipe(fs.createWriteStream('Narcos.S01E01.mp4'))
.on('finish', function() {
console.log('OK');
});
var fs = require("fs"),
request = require("request");
const download = (uri, filename, callback) => {
request.head(uri, (err, res, body) => {
request(uri)
.pipe(fs.createWriteStream(filename))
.on("close", callback);
});
};
download(
"http://fs.moviestape.net/video/1c4ed0ac8b7d5b4de6c5d58e2ea31a63/serials/Narcos/s01/Narcos.S01E01.mp4",
"./downloads/filename.mp4",
() => {
console.log("done");
}
);