fent / node-ytdl-core

YouTube video downloader in javascript.
MIT License
4.48k stars 790 forks source link

Error: This video contains content from [organization], who has blocked it on copyright grounds. #550

Closed medallyon closed 4 years ago

medallyon commented 4 years ago

Issue

I'm getting the "This video contains content from [organization], who has blocked it on copyright grounds." error and I can't seem to find a solution for it, neither on google nor in a previous issue (except for #510, which doesn't address the issue).

I'm not sure exactly which video it's erroring out on since I'm loading multiple videos from a playlist, but it might be this one.

It seems like ytdl-core itself is throwing the error internally which crashes my application, and I've tried wrapping the ytdl call in a try-catch block, which doesn't seem to do anything. See the code snippet below.

Stack Trace

events.js:187
      throw er; // Unhandled 'error' event
      ^

Error: This video contains content from Entertainment One U.S., LP, who has blocked it on copyright grounds.
    at .\node_modules\ytdl-core\lib\info.js:47:25
    at PassThrough.<anonymous> (.\node_modules\miniget\dist\index.js:196:32)
    at PassThrough.emit (events.js:210:5)
    at endReadableNT (_stream_readable.js:1183:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on PassThrough instance at:
    at .\node_modules\ytdl-core\lib\index.js:19:14
    at .\node_modules\ytdl-core\lib\info.js:335:25
    at .\node_modules\ytdl-core\lib\info.js:190:21
    at .\node_modules\ytdl-core\lib\info.js:335:25
    at .\node_modules\ytdl-core\lib\info.js:47:16
    at PassThrough.<anonymous> (.\node_modules\miniget\dist\index.js:196:32)

Relevant code

_loadStream()
{
    console.log("loading video", this.id);

    // todo: fix blocked video throwing errors. might be from ytdl call or from `info` event
    let stream;
    try
    {
        stream = ytdl(this.id, {
            filter: "audioonly",
            // https://github.com/fent/node-ytdl-core/issues/402#issuecomment-538070017
            highWaterMark: 1<<25
        });
    }

    catch (err)
    {
        console.log("ERRORED ON YTDL CALL?");
        console.error(err);
        return null;
    }

    return stream;
}

Thanks in advance for any help with this.

fent commented 4 years ago

use stream.on('error', ...)

medallyon commented 4 years ago

Ah yeah that's a thing. Thanks, fent.