W
W
Wasya UK2017-09-08 20:26:28
JavaScript
Wasya UK, 2017-09-08 20:26:28

Is it possible to download videos using nodejs?

I got the episode playlist from the site . Is it possible to download them to a computer using Node.js? In my head, only form a list of links from download. I will be glad and literature.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Abcdefgk, 2017-09-08
@Abcdefgk

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');	
      });

V
Vahe, 2017-09-09
@vahe_2000

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");
    }
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question