Node-ytdl-core: Unable to play age-restricted videos

Created on 28 Mar 2020  路  11Comments  路  Source: fent/node-ytdl-core

These used to work a few days ago, but now no longer works.
URL: https://www.youtube.com/watch?v=oGW1dRNc314
And: https://www.youtube.com/watch?v=oRSijEW_cDM

ytdl-core version: 2.0.1

I am using DiscordJS to play this song like:

musicYTStream = ytdl('https://www.youtube.com/watch?v=' + ytid, {
            filter: 'audioonly',
            quality: 'highestaudio',
            highWaterMark: 1024*1024*10, // 10mb
        }, {highWaterMark: 1})
musicDispatcher = voice_Connection.play(musicYTStream)

Error message:

Error: input stream: Status code: 403
    at ClientRequest.<anonymous> (/var/www/html/discordvoice/node_modules/miniget/dist/index.js:128:27)
    at Object.onceWrapper (events.js:428:26)
    at ClientRequest.emit (events.js:321:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:603:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
    at TLSSocket.socketOnData (_http_client.js:476:22)
    at TLSSocket.emit (events.js:321:20)
    at addChunk (_stream_readable.js:294:12)
    at readableAddChunk (_stream_readable.js:275:11)
    at TLSSocket.Readable.push (_stream_readable.js:209:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)
bug it fixed itself

Most helpful comment

thanks for the assessment @Gymnophoria. I agree that this is a separate issue, will change the title.

All 11 comments

Same issue here.

My code:

async function play(connection, server) {
    var dispatcher = await connection.play(await ytdl(server.queue[0], { highWaterMark: 1<<25, filter: 
    'audioonly', quality: 'highestaudio' }), { volume: false, bitrate: 96, highWaterMark: 1 });
}

I've had the same issue quite a bit. The videos with this error have something in common: they're getting an error 403, forbidden, because they're age restricted; see the stack trace below.

Error: input stream: Status code: 403
    at ClientRequest.<anonymous> (/home/nikolas/arthur/bot/node_modules/miniget/dist/index.js:128:27)
    at Object.onceWrapper (events.js:418:26)
    at ClientRequest.emit (events.js:311:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:603:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
    at TLSSocket.socketOnData (_http_client.js:476:22)
    at TLSSocket.emit (events.js:311:20)
    at addChunk (_stream_readable.js:294:12)
    at readableAddChunk (_stream_readable.js:275:11)
    at TLSSocket.Readable.push (_stream_readable.js:209:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)

Fent mentioned this in issue #555, although this can probably be considered a separate issue (as it's only age restricted, not age-restricted and unembedable videos).

Some more video IDs: BtLDidvnl8o, IRP-2y43BLo, j0lN0w5HVT8, huvj7eTZGNA, and huvj7eTZGNA. They're all from users of my bot, so I can get more if needed, but the theme is common.

I'd suggest changing the title to Unable to play age-restricted videos.

thanks for the assessment @Gymnophoria. I agree that this is a separate issue, will change the title.

@Gymnophoria thanks! how were you able to debug/figure this out?

easiest way is to open those videos in incognito mode, or on a browser where you're not logged into youtube. you'll get a message saying "Sign in to confirm your age"

@fent yah that I figured out, but maybe there are some other tricks to see some internal error message(s).

Ah yeah I log all music errors using the dispatcher error event, see line 136 of my music.js. You could also probably look at ytdl's stream for errors, using its error event.

Is ytdl-core still trying to fetch the age-restricted videos via embed? When I go to an embed link for an age restricted video, signed out, it loads fine.

Actually some other songs are failing to play for me, despite them not being age restricted (incognito lets me see them, anyway). Both result in 403 forbidden. Is this just a me thing?

https://www.youtube.com/watch?v=nhhAAZ6xg7o
https://www.youtube.com/watch?v=KKHe7qDsJdE

Edit: The first link works now, which is wild. Second is probably separate issue then yeah.

@Kaltzisp The first link you provided works fine for me, and the second one gives me an error 500 (Internal Server Error) - odd? I don't think this is the same issue, but I'm also not sure what distinguishes that second video. It's the same error as issue #163 so perhaps add the link there?

now working again?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cloudrac3r picture cloudrac3r  路  5Comments

Asaduji picture Asaduji  路  6Comments

cloudrac3r picture cloudrac3r  路  5Comments

HcgRandon picture HcgRandon  路  5Comments

NeuronButter picture NeuronButter  路  6Comments