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

Age Restricted Youtube Video Support #997

Open
bencorryp opened this issue Feb 10, 2024 · 5 comments
Open

Age Restricted Youtube Video Support #997

bencorryp opened this issue Feb 10, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@bencorryp
Copy link

Is it possible to allow the bot to search (and play) age-restricted content on youtube? Could not find a setting on the generated API key to allow for age restricted content to be viewed.

@codetheweb
Copy link
Owner

No, but happy to accept a PR for this.

@codetheweb codetheweb added enhancement New feature or request and removed support labels Feb 12, 2024
@jogerj
Copy link

jogerj commented May 17, 2024

Afaik there's no way of directly accessing restricted videos from the YouTube API without being logged in. In other words, you'll have to pass a YouTube account credentials by exporting your browser cookies and passing it to the client. This incidentally also allows accessing private/membership required videos/streams as long as the credentials allows it.

Quick search through code tells me you need to pass the cookie as a header here

this.got = got.extend({
prefixUrl: 'https://www.googleapis.com/youtube/v3/',
searchParams: {
key: this.youtubeKey,
responseType: 'json',
},
});

and the generated header should look something like this

@Happyllama25
Copy link

What about the ytdl library? I've used ytdlp (Python fork) in some personal projects and age-restricted video downloads work as intended.
Granted, I'm not sure how they do it, but it's probably not account credentials.

@jogerj
Copy link

jogerj commented May 17, 2024

@Happyllama25 I've worked with yt-dlp before. Passing cookies to the client is the way. It's straight forward in code too, but since this project is written in typescript and doesn't rely on yt-dlp at all, we'll have to do on our own. But the proof of concept above should work.

Edit: you may have been on to something. It does work, sort-of by spoofing a TV client (?) Discussion on reddit here but apparently it's not foolproof if the owner of the video disables the option

@Happyllama25
Copy link

It does work, sort-of

Yes, it works for me on my bot, something I did notice though is it seems to take longer to download an age-restricted video than a non-restricted one - not 100% sure, I have not done a 1:1 test of this.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants