Compare commits

...

2 Commits

Author SHA1 Message Date
LuanRT
b095044baa build (package): increment version 2021-10-29 22:22:53 -03:00
LuanRT
ba2b757fdb fix (OAuth): remove any new lines so the client identity can be found more easily 2021-10-29 22:10:43 -03:00
3 changed files with 7 additions and 7 deletions

View File

@@ -28,7 +28,7 @@ class OAuth extends EventEmitter {
this.auth_script_regex = /<script id=\"base-js\" src=\"(.*?)\" nonce=".*?"><\/script>/;
// Used to find the credentials inside the script.
this.identity_regex = /var .+?=\"(?<id>.+?)\",[.|\s].?=\"(?<secret>.+?)\"/;
this.identity_regex = /var .+?=\"(?<id>.+?)\",.?=\"(?<secret>.+?)\"/;
if (creds.access_token != undefined && creds.refresh_token != undefined) return;
this.requestAuthCode();
@@ -127,9 +127,9 @@ class OAuth extends EventEmitter {
const response = await Axios.get(script_url, Constants.default_headers).catch((error) => error);
if (response instanceof Error) throw new Error(`Could not extract client identify: ${response.message}`);
const identity_function = Utils.getStringBetweenStrings(response.data, '=function(){var a=window.environment', '(function()');
const client_identity = identity_function.match(this.identity_regex).groups;
return client_identity;
const identity_function = Utils.getStringBetweenStrings(response.data, 'YTLR_STORAGE_NAMESPACE",', 'reloadAppFlushLogsMaxTimeoutMs:');
const client_identity = identity_function.replace(/\n/g, '').match(this.identity_regex);
return client_identity.groups;
}
async refreshAccessToken(refresh_token) {

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "youtubei.js",
"version": "1.2.3",
"version": "1.2.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "youtubei.js",
"version": "1.2.3",
"version": "1.2.4",
"license": "MIT",
"dependencies": {
"axios": "^0.21.4",

View File

@@ -1,6 +1,6 @@
{
"name": "youtubei.js",
"version": "1.2.3",
"version": "1.2.4",
"description": "An object-oriented library that allows you to search, get detailed info about videos, subscribe, unsubscribe, like, dislike, comment, download videos and much more!",
"main": "index.js",
"scripts": {