Open JaxonPlays opened 4 years ago
This is what Google calls botguard. It expects a bgRequest
parameter to be sent with the login which youtube-dl does not.
The code to generate this string is a bit complex. I've figured it out but it would be tricky to make into correct Python code.
If you look at accounts.google.com/ServiceLogin
source, you'll see a data-initial-setup-data
attribute (JSON embedded) which has the starting random string that's used to generate the challenge string. It is very long. Once the JSON is decoded, the field is index 18.
Using this string, the code calls window.botguard.bg(theString, void 0)
. This returns an object which has an invoke()
method. The signature seems to be invoke(callback?: (x: any) => any, d: boolean, e: object)
, usually with b = false
and e = {}
.
The callback used in the code just passes the string around to assign it to various objects, so it is not important.
You can generate the string on demand by using this in console:
window.botguard.bg(JSON.parse('[' + document.querySelector('[data-initial-setup-data]').dataset.initialSetupData.substr(4))[18], void 0).invoke(null, false, {})
Below is the code from Chrome's VM from botguard, which generates the string (which starts with !
).
Start from the definition of invoke()
on line 839. Remember ,
in JavaScript means the last statement is what gets assigned or returned.
@Tatsh The bgRequest
is obviously very important,I tested. And bgRequest
is tied to Google account.
Any news?
@Tatsh Thanks for that info about Login is broken and your patch https://github.com/Tatsh/youtube-unofficial/commit/ae749c50989e1ed4bd34d78a020450e2754efd58 I am having trouble ascertaining which init.py file it pertains to as none in 2020.03.24 in Arch installs seems to have a corresponding file that meets your changes. Is there another version that can be installed to incorporate your changes to test the login? And will this apply to all YouTube authenticated functions or only those related to "subscriptions"? This problem has numerous issues raised other than subscriptions so I hope there is some co-ordination with the other groups on it as it looks like you have broken the back of the problem.
Checklist
Verbose log
Description
Correct login details "HTTP Error 400".