mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-26 08:08:54 +00:00
refactor!: move everything that needs parsing to parser and improve oauth system
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user