refactor!: move everything that needs parsing to parser and improve oauth system

This commit is contained in:
luan.lrt4@gmail.com
2022-04-16 22:08:01 -03:00
parent 440d80063d
commit 4bbc2d50f4
16 changed files with 682 additions and 516 deletions

View File

@@ -24,6 +24,10 @@ module.exports = {
'referer': `https://www.youtube.com/tv`,
'accept-language': 'en-US'
}
},
REGEX: {
AUTH_SCRIPT: /<script id=\"base-js\" src=\"(.*?)\" nonce=".*?"><\/script>/,
CLIENT_IDENTITY: /.+?={};var .+?={clientId:\"(?<id>.+?)\",.+?:\"(?<secret>.+?)\"},/
}
},
DEFAULT_HEADERS: (session) => {
@@ -63,13 +67,14 @@ module.exports = {
'origin': origin
};
if (info.session.logged_in) {
const auth_creds = info.session.cookie.length && info.session.auth_apisid || `Bearer ${info.session.access_token}`
if (info.session.logged_in) {
headers.Cookie = info.session.cookie;
headers.authorization = info.session.cookie.length && info.session.auth_apisid || `Bearer ${info.session.access_token}`;
headers.authorization = auth_creds;
}
return headers
return headers;
},
VIDEO_INFO_REQBODY: (id, sts, context) => {
return {

View File

@@ -6,7 +6,7 @@ const UserAgent = require('user-agents');
const Flatten = require('flat');
function InnertubeError(message, info) {
this.info = info;
this.info = info || {};
this.stack = Error(message).stack;
}