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

MinigetError: Status Code 403 #932

Closed
jbelford opened this issue Jun 3, 2021 · 23 comments
Closed

MinigetError: Status Code 403 #932

jbelford opened this issue Jun 3, 2021 · 23 comments
Labels

Comments

@jbelford
Copy link

jbelford commented Jun 3, 2021

For some videos the stream will error out with this.

The last stream this occurred with was for this video https://www.youtube.com/watch?v=3_V_2BFWahc

MinigetError: Status code: 403
2021-06-03T03:07:10.828678436Z at ClientRequest. (/home/site/wwwroot/node_modules/miniget/dist/index.js:210:27)
2021-06-03T03:07:10.828685936Z at Object.onceWrapper (events.js:422:26)
2021-06-03T03:07:10.828690636Z at ClientRequest.emit (events.js:315:20)
2021-06-03T03:07:10.828695736Z at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:641:27)
2021-06-03T03:07:10.828700736Z at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
2021-06-03T03:07:10.828721136Z at HTTPParser.execute ()
2021-06-03T03:07:10.828726036Z at TLSSocket.socketOnData (_http_client.js:509:22)
2021-06-03T03:07:10.828730036Z at TLSSocket.emit (events.js:315:20)
2021-06-03T03:07:10.828733836Z at addChunk (_stream_readable.js:309:12)
2021-06-03T03:07:10.828737836Z at readableAddChunk (_stream_readable.js:284:9) {
2021-06-03T03:07:10.828741836Z statusCode: 403
2021-06-03T03:07:10.828745736Z }

I'm also just calling ytdl like this to get the stream

ytdl(track.url, { filter: 'audioonly', quality: 'highestaudio' });

It seems to happen randomly and I can't seem to reproduce the error. I'm on the latest version though and it seems there was an older thread #417 but that was closed a while ago

@Nico-ITA
Copy link

Me too

@Vw7sh
Copy link

Vw7sh commented Jul 14, 2021

me too 😔

@Nico-ITA
Copy link

me too 😔
Have u fixed?

@Vw7sh
Copy link

Vw7sh commented Jul 25, 2021

me too 😔
Have u fixed?

nope .

@TimeForANinja
Copy link
Collaborator

did some testing a while back...
you might know that the format url's are ip & time restricted
breaking those limitations results in a statuscode 403
so this might occur when playing long streams or fetching the info way ahead of actually requesting the resource
might this be the problem?

@Nico-ITA
Copy link

did some testing a while back...
you might know that the format url's are ip & time restricted
breaking those limitations results in a statuscode 403
so this might occur when playing long streams or fetching the info way ahead of actually requesting the resource
might this be the problem?

Hey , yes this might be the problem , becouse happen to me when I play a long playlist

@Vw7sh
Copy link

Vw7sh commented Jul 31, 2021

@TimeForANinja
Yes, that is the problem.

@AkatGabrielGoncalves
Copy link

Any updates? I'm getting this error quite constantly, the most problematic part is that it crashes the whole application, you can try to reproduce it in my FelicityBot repository, right now I changed the ytdl dependency to ytdl-discord, but this problem continues regardless. I can get this error quite constantly using this playlist that I created to "stress-test", so it is the same video over and over again.
It is totally random when it happens.

Error: Status code: 403
    at ClientRequest.<anonymous> (/home/akat/projetos/FelicityBot/node_modules/miniget/src/index.ts:258:17)
    at Object.onceWrapper (events.js:482:26)
    at ClientRequest.emit (events.js:375:28)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:647:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
    at HTTPParser.execute (<anonymous>)
    at TLSSocket.socketOnData (_http_client.js:515:22)
    at TLSSocket.emit (events.js:375:28)
    at addChunk (internal/streams/readable.js:290:12)
    at readableAddChunk (internal/streams/readable.js:265:9)
[ERROR] 14:49:49 Error: Status code: 403

@AkatGabrielGoncalves
Copy link

I made a way to not crash my bot for anyone that needs it. the thing is that:

const stream = await ytdl(url, {
        quality: 'highestaudio',
        filter: 'audioonly',
        requestOptions: {
          headers: {
            cookie: process.env.YOUTUBE_LOGIN_COOKIE,
          },
        },
      });
const audioResource = createAudioResource(stream, {
        inputType: StreamType.Opus,
      });

      this.player.play(audioResource);

when you play this stream no try catch can catch the error because the stream is asynchronous what I did is this, after the play method:

const funcao = stream.listeners('error')[2];
stream.removeListener('error', funcao);

      stream.on('error', (err) => {
        try {
          throw new Error();
        } catch {
          stream.destroy();
          console.log(err);
        }
      });

This removes the last listener that the stream have, which is the one that breaks our bot, then add our own listener to handle that error. You could remove all error listeners too. This is the best I could came up with for now.

@MIGI10
Copy link

MIGI10 commented Oct 3, 2021

any updates? I'm getting this error randomly and it's very frustrating. I've read here that it could be because of fetching the info some time before it actually gets used but I don't really understand how can that affect me as I only fetch video URLs in this format: https://www.youtube.com/watch?v=VIDEO_ID without any time or ip data...

@y0Phoenix
Copy link

I am getting this same error with my discord music bot, last time it crashed it was playing a looped song and crashed about 40 minutes into replaying the looped song. However other times it will crash first time playing anything. Gonna try adding own error listeners to not crash it

@Arniox
Copy link

Arniox commented Oct 17, 2021

I'm also getting this error on random videos

@elliotwestlake
Copy link

Same here 😢

@Laljaka
Copy link

Laljaka commented Oct 26, 2021

Same problem here.
Happens right after video info was retrieved as I never fetch it ahead of time. Possible to overcome by implementing retries, but it's slows the program.
Would be nice if this can be fixed.
Thank you.

@KevinKib
Copy link

KevinKib commented Nov 3, 2021

Just got the same error :(

@fobdev
Copy link

fobdev commented Nov 9, 2021

Still don't know how to bypass this without making my discord bot stop playing.
Any solutions? I'm dropping the bot from the voice channel when the error happens, people needs to do the request again.

@MIGI10
Copy link

MIGI10 commented Nov 9, 2021

Still don't know how to bypass this without making my discord bot stop playing.
Any solutions? I'm dropping the bot from the voice channel when the error happens, people needs to do the request again.

You can listen for the player error event, inside check if the error contains the 403 code and if so, try playing again the song. Sometimes it doesn't return the same error, other times you have to try playing the song like 4 times until it plays without the error. You can also play the song using youtube-dl after the error.

@ghost
Copy link

ghost commented Dec 1, 2021

Still don't know how to bypass this without making my discord bot stop playing.
Any solutions? I'm dropping the bot from the voice channel when the error happens, people needs to do the request again.

You can listen for the player error event, inside check if the error contains the 403 code and if so, try playing again the song. Sometimes it doesn't return the same error, other times you have to try playing the song like 4 times until it plays without the error. You can also play the song using youtube-dl after the error.

it's not work.. currently I only getting 403 error. Can't play music..

const stream = await ytdl(this.currentSong.url, {
                highWaterMark: 1 << 25,
                filter: 'audioonly',
            });

@joaopmi
Copy link

joaopmi commented Dec 14, 2021

Apparently this is a youtube related problem, I don't think devs can fix this, sure there is a workaround, but it's the right way?

@TimeForANinja
Copy link
Collaborator

should be fixed with #1022

@Namnp1521
Copy link

any update? i still got this error

@LuciferSharma
Copy link

Still getting the same error:
MinigetError: Status code: 403

Anyupdate?

@Namnp1521
Copy link

any update? i still got this error when i run on firebase cloud function

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