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

Fix: watch page for community restricted videos #1080

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JackReevies
Copy link

Issue

Community age restricted videos on Youtube (the ones that require clicking the "I understand and wish to proceed" button before watching) were causing the module to throw a 410 when trying a getInfo

Cause

getInfo runs through a maximum of 3 urls until it has enough metadata (as defined in the validate function on info.js:59). Often we can get enough data from the first url (the basic watch page) to satisfy this and exit early, unfortunately no formats are made available when a video requires the user to click that age restricted button. The other URLs are visited and the last one in the list (youtube.com/get_video_info) throws a 410 Gone, causing the module to also throw.

Solution

Appending &bpctr=9999999999&has_verified=1 to the first url (the basic watch page) seems to bypass that "I understand and wish to proceed" button and makes the format/stream data available right away, thus eliminating the need to visit the other URLs and never calling out to the youtube.com/get_video_info url

Related

I didn't discover this, I simply ran into the problem and was searching for solutions. There have been conversations on this repo in issues and PRs about this (#1009 and #1010) but they've been closed/dismissed as being fixed under #1022. This does not seem to be the case for me (and at least a few other users).

Here's a video I've been using to test with https://www.youtube.com/watch?v=lwVhz0QCFEY (you can also see here that adding &bpctr=9999999999&has_verified=1 to the end of that URL gets rid of the prompt and starts playing immediately.

Code can be tested with the following test function

async function start() {
	  try { 
	  	const info = await getInfo('lwVhz0QCFEY') 
	  } catch(e) {
	    console.error(e)
	  }
}

@bmckalip
Copy link

This works for me. I might suggest using &bpctr=${Date.now()}&has_verified=1 instead of &bpctr=9999999999&has_verified=1 as after inspecting the query params of the url from youtube's site, this seems to be more accurate. Both work for me, however.

There might be a better way to do this overall, though. I'm just diving into the code of this project after running into the issue in my app, and it seems like there is no way to specify arbitrary query params for the request made in getWatchHTMLURL. I may try my hand at creating something more generic.

@pixelblob
Copy link

when can this be merged?

@TimeForANinja TimeForANinja changed the title Fix for watch page community restricted videos Fix: watch page for community restricted videos Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants