Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to download video (Error: connect ETIMEDOUT 46.201.72.15:443) #705

Closed
EugeneLoy opened this issue Sep 11, 2020 · 1 comment
Closed
Labels

Comments

@EugeneLoy
Copy link

Hi. I am unable to download this video: https://www.youtube.com/watch?v=WztFR_ESFrI

I am using example code with minor modifications:

const readline = require('readline');
const path = require('path');
const fs = require('fs');
const ytdl = require('ytdl-core');

const url = 'https://www.youtube.com/watch?v=WztFR_ESFrI';
const output = path.resolve(__dirname, 'video.mp4');

const video = ytdl(url);
let starttime;
video.pipe(fs.createWriteStream(output));
video.once('response', () => {
  starttime = Date.now();
});
video.on('progress', (chunkLength, downloaded, total) => {
  const percent = downloaded / total;
  const downloadedMinutes = (Date.now() - starttime) / 1000 / 60;
  const estimatedDownloadTime = (downloadedMinutes / percent) - downloadedMinutes;
  readline.cursorTo(process.stdout, 0);
  process.stdout.write(`${(percent * 100).toFixed(2)}% downloaded `);
  process.stdout.write(`(${(downloaded / 1024 / 1024).toFixed(2)}MB of ${(total / 1024 / 1024).toFixed(2)}MB)\n`);
  process.stdout.write(`running for: ${downloadedMinutes.toFixed(2)}minutes`);
  process.stdout.write(`, estimated time left: ${estimatedDownloadTime.toFixed(2)}minutes `);
  readline.moveCursor(process.stdout, 0, -1);
});
video.on('end', () => {
  process.stdout.write('\n\n');
});

... and getting the following error (after some time):

>node temp.js
events.js:173
      throw er; // Unhandled 'error' event
      ^

Error: connect ETIMEDOUT 46.201.72.15:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1054:14)
Emitted 'error' event at:
    at errorOrDestroy (internal/streams/destroy.js:107:12)
    at PassThrough.onerror (_stream_readable.js:720:7)
    at PassThrough.emit (events.js:196:13)
    at PassThrough. (C:\Users\Leo\workspace\edx-archive\node_modules\ytdl-core\lib\index.js:96:16)
    at PassThrough.emit (events.js:196:13)
    at ClientRequest.onRequestError (C:\Users\Leo\workspace\edx-archive\node_modules\miniget\dist\index.js:92:20)
    at ClientRequest.emit (events.js:196:13)
    at TLSSocket.socketErrorListener (_http_client.js:402:9)
    at TLSSocket.emit (events.js:196:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)

Note: I am able to view this video on youtube and I am able to download other videos using ytdl-core.

What the problem might be and is there something I can do to fix it?

@fent
Copy link
Owner

fent commented Sep 11, 2020

this is very similar to this error, except it only downloads a bit of the video from the beginning of the file, then stops. I tried making it reconnect to download later bytes, the request was made, but it would hang and timeout too

@fent fent added the bug label Sep 25, 2020
@fent fent closed this as completed in 0d27df3 Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants