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

Miniget Error 403 on some videos after update 4.3.0 #854

Closed
Chrisr0 opened this issue Jan 5, 2021 · 10 comments
Closed

Miniget Error 403 on some videos after update 4.3.0 #854

Chrisr0 opened this issue Jan 5, 2021 · 10 comments
Labels

Comments

@Chrisr0
Copy link

Chrisr0 commented Jan 5, 2021

I use ytdl for my discord bot and after updating to version 4.3.0 or later some videos refuse to play and throws this error

    MinigetError: input stream: Status code: 403
    at ClientRequest.<anonymous> (/home/chris/repos/roBOT/node_modules/miniget/dist/index.js:196:27)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:315:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
    at TLSSocket.socketOnData (_http_client.js:469:22)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at TLSSocket.Readable.push (_stream_readable.js:212:10) {
  statusCode: 403
}

My code

const dispatcher = connection
        .play(ytdl(song.vid.url, {
                requestOptions: {
                    headers: {
                        'X-Youtube-Identity-Token': process.env.xyit,
                        'Cookie': 'SID='+process.env.sid+'; HSID='+process.env.hsid+'; SSID='+process.env.ssid
                    }
                }
            })
        )
        .on("error", error => console.error(error));

Video Links

https://www.youtube.com/watch?v=L_jWHffIx5E
https://www.youtube.com/watch?v=5NV6Rdv1a3I
https://www.youtube.com/watch?v=Um7pMggPnug

ytdl-core - 4.3.0 and newer
node - 12.18.2

@fent
Copy link
Owner

fent commented Jan 6, 2021

does the video still play? if yes, then this is the same as #798

@Chrisr0
Copy link
Author

Chrisr0 commented Jan 6, 2021

Video doesn't play and it happens only on specific videos

@fent
Copy link
Owner

fent commented Jan 6, 2021

what was the version you were using before v4.3.0?

@Chrisr0
Copy link
Author

Chrisr0 commented Jan 6, 2021

I was using 4.2.1 but tested 4.2.0 and 4.0.3 and they worked fine too

@fent
Copy link
Owner

fent commented Jan 6, 2021

My code

const dispatcher = connection
        .play(ytdl(song.vid.url, {
                requestOptions: {
                    headers: {
                        'X-Youtube-Identity-Token': process.env.xyit,
                        'Cookie': 'SID='+process.env.sid+'; HSID='+process.env.hsid+'; SSID='+process.env.ssid
                    }
                }
            })
        )
        .on("error", error => console.error(error));

try removing the identity token header

@Chrisr0
Copy link
Author

Chrisr0 commented Jan 6, 2021

Identity token didn't work. Removing any part of cookie helps but then can't play age restricted videos.

@fent
Copy link
Owner

fent commented Jan 6, 2021

ah, so then the issue is related to the cookie. maybe it expired?

btw, ytdl-core should be able to play age restricted videos without a cookie

@Chrisr0
Copy link
Author

Chrisr0 commented Jan 6, 2021

Removing all headers worked and plays age restricted just fine. Thanks for help.

@Chrisr0 Chrisr0 closed this as completed Jan 6, 2021
@VioletFlare
Copy link

VioletFlare commented Oct 20, 2021

The way I resolved it was waiting for a while (250ms) after detecting the er.statusCode status code 403 .on("error", (er) => {...}), and then re-running recursively the function containing connection.play(ytdl(...))... inside the event handler.

@TimeForANinja
Copy link
Collaborator

🤔 creepy - but glad it worked for you

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

4 participants