Node-ytdl-core: 403 Statys

Created on 11 Jun 2019  路  26Comments  路  Source: fent/node-ytdl-core

Hi, I was getting this error everytime when I try to play music on my discord bot.

2019-06-11T09:46:23.752174+00:00 app[worker.1]: events.js:170
2019-06-11T09:46:23.752194+00:00 app[worker.1]: throw er; // Unhandled 'error' event
2019-06-11T09:46:23.752196+00:00 app[worker.1]: ^
2019-06-11T09:46:23.752198+00:00 app[worker.1]:
2019-06-11T09:46:23.752201+00:00 app[worker.1]: Error: Status code: 403
2019-06-11T09:46:23.752203+00:00 app[worker.1]: at ClientRequest.httpLib.get (/app/node_modules/miniget/lib/index.js:123:19)
2019-06-11T09:46:23.752205+00:00 app[worker.1]: at Object.onceWrapper (events.js:281:20)
2019-06-11T09:46:23.752208+00:00 app[worker.1]: at ClientRequest.emit (events.js:193:13)
2019-06-11T09:46:23.752210+00:00 app[worker.1]: at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:560:23)
2019-06-11T09:46:23.752212+00:00 app[worker.1]: at HTTPParser.parserOnHeadersComplete (_http_common.js:113:17)
2019-06-11T09:46:23.752215+00:00 app[worker.1]: at TLSSocket.socketOnData (_http_client.js:447:22)
2019-06-11T09:46:23.752217+00:00 app[worker.1]: at TLSSocket.emit (events.js:193:13)
2019-06-11T09:46:23.752219+00:00 app[worker.1]: at addChunk (_stream_readable.js:295:12)
2019-06-11T09:46:23.752221+00:00 app[worker.1]: at readableAddChunk (_stream_readable.js:276:11)
2019-06-11T09:46:23.752223+00:00 app[worker.1]: at TLSSocket.Readable.push (_stream_readable.js:231:10)
2019-06-11T09:46:23.752225+00:00 app[worker.1]: Emitted 'error' event at:
2019-06-11T09:46:23.752227+00:00 app[worker.1]: at errorOrDestroy (internal/streams/destroy.js:107:12)
2019-06-11T09:46:23.752229+00:00 app[worker.1]: at PassThrough.onerror (_stream_readable.js:729:7)
2019-06-11T09:46:23.752231+00:00 app[worker.1]: at PassThrough.emit (events.js:193:13)
2019-06-11T09:46:23.752233+00:00 app[worker.1]: at PassThrough.req.prependListener (/app/node_modules/ytdl-core/lib/index.js:131:14)
2019-06-11T09:46:23.752235+00:00 app[worker.1]: at PassThrough.emit (events.js:193:13)
2019-06-11T09:46:23.752237+00:00 app[worker.1]: at ClientRequest.httpLib.get (/app/node_modules/miniget/lib/index.js:127:18)
2019-06-11T09:46:23.752239+00:00 app[worker.1]: at Object.onceWrapper (events.js:281:20)
2019-06-11T09:46:23.752241+00:00 app[worker.1]: [... lines matching original stack trace ...]
2019-06-11T09:46:23.752243+00:00 app[worker.1]: at HTTPParser.parserOnHeadersComplete (_http_common.js:113:17)

stale

Most helpful comment

I think this was fixed in 1f79df3448a6c218c9bff0a64781d82e4da8eee6 and merged (#428). Installing [email protected] fixes this issue for me for now.

All 26 comments

Confirmed Issue started appearing recently
Error: Status code: 403 at ClientRequest.httpLib.get (C:\Users\tyler\Desktop\midspike-discord-sync\node_modules\miniget\lib\index.js:123:19) at Object.onceWrapper (events.js:273:13) at ClientRequest.emit (events.js:182:13) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17) at TLSSocket.socketOnData (_http_client.js:442:20) at TLSSocket.emit (events.js:182:13) at addChunk (_stream_readable.js:283:12) at readableAddChunk (_stream_readable.js:264:11) at TLSSocket.Readable.push (_stream_readable.js:219:10) at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) Emitted 'error' event at: at PassThrough.onerror (_stream_readable.js:690:12) at PassThrough.emit (events.js:182:13) at PassThrough.req.prependListener (C:\Users\tyler\Desktop\midspike-discord-sync\node_modules\ytdl-core\lib\index.js:131:14) at PassThrough.emit (events.js:182:13) at ClientRequest.httpLib.get (C:\Users\tyler\Desktop\midspike-discord-sync\node_modules\miniget\lib\index.js:127:18) at Object.onceWrapper (events.js:273:13) [... lines matching original stack trace ...] at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

Experiencing the same issue, don't know why. It seems like it's only a problem with popular/big videos. I have a song uploaded to Youtube with little views and it worked for that song. Maybe it is an issue with Youtube.

I am not an experienced coder but for now, you can handle this error by
ytdl(url, { filter: "audio" }).on('error', e=>console.log(e))
when creating the stream.

I am also getting 403 errors, on all video's....

Could be related: https://github.com/ytdl-org/youtube-dl/issues/21218

Basically in my case I'm getting 403s, but it may be due to the fact I'm extracting the download URL and then passing it to a client which is then failing to load the URL (i.e. youtube is blocking that).

Solution: Update simple-youtube-api (If you are using it)

@HeadTriXz how is that solution to people faced with the issue in this library? the have no dependency between each other?

Ye I don't see how simple-youtube-api relates at all.

I hope the developers will look into this problem soon, but for now, you may consider using youtube-dl:

const youtubedl = require('youtube-dl');
const audio = youtubedl(url,
  ['-x', '--audio-format', 'mp3'],
  { cwd: __dirname });

audio.pipe(fs.createWriteStream('audio.mp3'))

Can you try to do npm i fent/node-ytdl-core

@PLASMAchicken Still same 403 error.

At my job, we ran npm i fent/node-ytdl-core as user volumio, so we got [email protected]. Then as root edited /data/plugins/music_service/youtube/package.json line 18 to same version "ytdl-core": "^0.29.2", then removed whole node_modules folder, then npm install. After reboot it was working nicely again

I think this was fixed in 1f79df3448a6c218c9bff0a64781d82e4da8eee6 and merged (#428). Installing [email protected] fixes this issue for me for now.

Yep seems like updating to 0.29.2 does the trick

I will try them on monday on our volumio

I use my music bot very regularly and I haven't had any 403 error since 0.29.2.
Make sure you're actually on 0.29.2, delete your node_modules folder and run npm install if you have to.

@UraYukimitsu I tried all 3 of those and they work fine for me?

As per my previous comment:

Could be related: https://github.com/ytdl-org/youtube-dl/issues/21218

It looks like it could be this is only occurring when the machine trying to download the url is different to the one that gets the URL (i.e youtube is locking the urls down to the IPs that requested them).

@motorlatitude still getting 403 on 0.29.2 on this link

@kartik1225 That link also works fine for me on 0.29.2, your issue could be related to what @benkaiser mentioned?

@motorlatitude this will work fine if you are testing this on the localhost. because the ip will be the same but that same link might not work on the different ip (device).

@kartik1225 sorry, I should have specified, I tested on my remote server using my discord bot. The URL issue mentioned previously is with reference to the download URL which is separate to the link you provided I believe.

For example, if I run;

$ youtube-dl -g https://www.youtube.com/watch?v=PT2_F-1esPk

I will get these download URLs;

https://r1---sn-3xtjvh-ac5e.googlevideo.com/videoplayback?expire=1560912108&ei=i0wJXaHANsSnVtX0gogK&ip=109.246.19.50&id=o-AH-_u7BSGz0QUhmF9snvUxn2V7S9RTOD-L62NT5wIwKm&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-3xtjvh-ac5e%2Csn-aigzrn7z&ms=au%2Crdu&mv=m&pl=20&gcr=gb&initcwndbps=1361250&mime=video%2Fmp4&gir=yes&clen=104491761&dur=261.803&lmt=1556983934018483&mt=1560890410&fvip=1&keepalive=yes&c=WEB&txp=5535432&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cgcr%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cpl%2Cinitcwndbps&lsig=AHylml4wRAIgSKOViPZ6VZCC24LBGv84XETl1SqkiAMcs3Jt7ad9StkCIE1fnTCtHWA4LGKPho198JTBytIBMVsNQMleysD9uXNs&sig=ALgxI2wwRAIgWoMyIOPaoZZTeFlaTBJtcuaBUhMOwNg3kcct3N7TzEACIEabXEUKII7ktCAgYCCLaYDOJ_pPkY7IWvFdofZU_1ab&ratebypass=yes
https://r1---sn-3xtjvh-ac5e.googlevideo.com/videoplayback?expire=1560912108&ei=i0wJXaHANsSnVtX0gogK&ip=109.246.19.50&id=o-AH-_u7BSGz0QUhmF9snvUxn2V7S9RTOD-L62NT5wIwKm&itag=251&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-3xtjvh-ac5e%2Csn-aigzrn7z&ms=au%2Crdu&mv=m&pl=20&gcr=gb&initcwndbps=1361250&mime=audio%2Fwebm&gir=yes&clen=4348334&dur=261.821&lmt=1540261587251261&mt=1560890410&fvip=1&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cpl%2Cinitcwndbps&lsig=AHylml4wRAIgSKOViPZ6VZCC24LBGv84XETl1SqkiAMcs3Jt7ad9StkCIE1fnTCtHWA4LGKPho198JTBytIBMVsNQMleysD9uXNs&sig=ALgxI2wwRgIhAPrFih6EoNMrLLcBxoU5h6pxp1eIelLGHus71RIVm6INAiEAzECJLuwwKQuMH_QKCFZX-zm8A-9OwkoSxiZ_N_PfD5Q=&ratebypass=yes

These are the URLs that will be used to download the video and are tied to your IP (device). Using these URLs to attempt to download the video will sometimes return 403s if you have gotten this URL from a separate device.

I have the same issue. In localhost, I can run the video url, when I tried in my server , it does not work.

I got it all fixed by simply updating the package

@kartik1225 sorry, I should have specified, I tested on my remote server using my discord bot. The URL issue mentioned previously is with reference to the download URL which is separate to the link you provided I believe.

For example, if I run;

$ youtube-dl -g https://www.youtube.com/watch?v=PT2_F-1esPk

I will get these download URLs;

https://r1---sn-3xtjvh-ac5e.googlevideo.com/videoplayback?expire=1560912108&ei=i0wJXaHANsSnVtX0gogK&ip=109.246.19.50&id=o-AH-_u7BSGz0QUhmF9snvUxn2V7S9RTOD-L62NT5wIwKm&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-3xtjvh-ac5e%2Csn-aigzrn7z&ms=au%2Crdu&mv=m&pl=20&gcr=gb&initcwndbps=1361250&mime=video%2Fmp4&gir=yes&clen=104491761&dur=261.803&lmt=1556983934018483&mt=1560890410&fvip=1&keepalive=yes&c=WEB&txp=5535432&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cgcr%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cpl%2Cinitcwndbps&lsig=AHylml4wRAIgSKOViPZ6VZCC24LBGv84XETl1SqkiAMcs3Jt7ad9StkCIE1fnTCtHWA4LGKPho198JTBytIBMVsNQMleysD9uXNs&sig=ALgxI2wwRAIgWoMyIOPaoZZTeFlaTBJtcuaBUhMOwNg3kcct3N7TzEACIEabXEUKII7ktCAgYCCLaYDOJ_pPkY7IWvFdofZU_1ab&ratebypass=yes
https://r1---sn-3xtjvh-ac5e.googlevideo.com/videoplayback?expire=1560912108&ei=i0wJXaHANsSnVtX0gogK&ip=109.246.19.50&id=o-AH-_u7BSGz0QUhmF9snvUxn2V7S9RTOD-L62NT5wIwKm&itag=251&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-3xtjvh-ac5e%2Csn-aigzrn7z&ms=au%2Crdu&mv=m&pl=20&gcr=gb&initcwndbps=1361250&mime=audio%2Fwebm&gir=yes&clen=4348334&dur=261.821&lmt=1540261587251261&mt=1560890410&fvip=1&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cpl%2Cinitcwndbps&lsig=AHylml4wRAIgSKOViPZ6VZCC24LBGv84XETl1SqkiAMcs3Jt7ad9StkCIE1fnTCtHWA4LGKPho198JTBytIBMVsNQMleysD9uXNs&sig=ALgxI2wwRgIhAPrFih6EoNMrLLcBxoU5h6pxp1eIelLGHus71RIVm6INAiEAzECJLuwwKQuMH_QKCFZX-zm8A-9OwkoSxiZ_N_PfD5Q=&ratebypass=yes

These are the URLs that will be used to download the video and are tied to your IP (device). Using these URLs to attempt to download the video will sometimes return 403s if you have gotten this URL from a separate device.

hi, do you have any solution for fix this issues?

Thank you very much, @tsrubar, your hint helped me a lot. Now it is fixed for me, but I had some troubles to apply properly since I never used npm nor commandline in volumio.
It has to be mentioned that npm must be run within the directory of the package.json, both times. Otherwise I got some warnings and the new version didn#t install properly.

At my job, we ran npm i fent/node-ytdl-core as user volumio, so we got [email protected]. Then as root edited /data/plugins/music_service/youtube/package.json line 18 to same version "ytdl-core": "^0.29.2", then removed whole node_modules folder, then npm install. After reboot it was working nicely again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arcovoltaico picture arcovoltaico  路  6Comments

GamerXD4 picture GamerXD4  路  5Comments

MidSpike picture MidSpike  路  4Comments

PKPear picture PKPear  路  4Comments

cloudrac3r picture cloudrac3r  路  5Comments