Closed m-milek closed 4 months ago
Hey m-milek!
Unfortunately it is not possible to get the metadata directly from an age-restricted video. There is a work-around though. You can get the metadata by setting a cookie of an account where it's age has been verified. You can set a cookie by using a custom agent. Here is a small example of how you can set a cookie:
const ytstream = require('yt-stream');
const agent = new ytstream.YTStreamAgent([{
key: 'The key of the cookie',
value: 'The value of the cookie',
domain: 'youtube.com', // Do not change the domain
expires: 'Infinity',
sameSite: 'lax',
httpOnly: false,
hostOnly: false,
secure: true,
path: '/'
}], {});
ytstream.setGlobalAgent(agent);
By setting this agent, all requests made to YouTube will include the cookies included inside the agent's first argument. Since the first argument is an array, you can add multiple cookies. To find the cookies of your account, you need to open YouTube in your browser, then open the inspector, select the 'Network' tab, refresh the page, open the first GET request to YouTube and go to the 'Cookies' tab inside the request.
Kind regards,
Luuk
Hello,
Is it possible to work with age-restricted videos? I need to fetch metadata and later download the audio.
When I try to
getInfo
those videos, I getI've checked closed issues and there was one very similar to mine. It seems that the previous fix doesn't always work?
Thank you for developing this library, it's working really well so far 👍🏻