mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-28 00:56:23 +00:00
refactor!: welp, a lot of stuff
- Use the OS temp folder to cache the player, closes #57. - Added support for editing channel name, closes #40. - Added support for editing channel description. - Added support for retrieving basic channel analytics, closes #54. - Moved `Innertube#getAccountInfo()` to `Innertube#account`, and renamed it to `getInfo()`. - `getInfo()` is now able to return email, channel id, etc. - Improved jsdoc.
This commit is contained in:
@@ -4,11 +4,8 @@ const Axios = require('axios');
|
||||
const Constants = require('../utils/Constants');
|
||||
const Uuid = require('uuid');
|
||||
|
||||
/** @namespace */
|
||||
class OAuth {
|
||||
#scope = Constants.OAUTH.SCOPE;
|
||||
#model_name = Constants.OAUTH.MODEL_NAME;
|
||||
#grant_type = Constants.OAUTH.GRANT_TYPE;
|
||||
|
||||
#oauth_code_url = `${Constants.URLS.YT_BASE}/o/oauth2/device/code`;
|
||||
#oauth_token_url = `${Constants.URLS.YT_BASE}/o/oauth2/token`;
|
||||
#oauth_revoke_url = `${Constants.URLS.YT_BASE}/o/oauth2/revoke`;
|
||||
@@ -17,6 +14,10 @@ class OAuth {
|
||||
#polling_interval = 5;
|
||||
#ev = null;
|
||||
|
||||
/**
|
||||
* @param {EventEmitter} ev
|
||||
* @constructor
|
||||
*/
|
||||
constructor(ev) {
|
||||
this.#ev = ev;
|
||||
}
|
||||
@@ -46,9 +47,9 @@ class OAuth {
|
||||
|
||||
const data = {
|
||||
client_id: this.client_id,
|
||||
scope: this.#scope,
|
||||
scope: Constants.OAUTH.SCOPE,
|
||||
device_id: Uuid.v4(),
|
||||
model_name: this.#model_name
|
||||
model_name: Constants.OAUTH.MODEL_NAME
|
||||
};
|
||||
|
||||
const response = await Axios.post(this.#oauth_code_url, JSON.stringify(data), Constants.OAUTH.HEADERS).catch((error) => error);
|
||||
@@ -77,7 +78,7 @@ class OAuth {
|
||||
client_id: this.client_id,
|
||||
client_secret: this.client_secret,
|
||||
code: device_code,
|
||||
grant_type: this.#grant_type
|
||||
grant_type: Constants.OAUTH.GRANT_TYPE
|
||||
};
|
||||
|
||||
setTimeout(async () => {
|
||||
@@ -204,16 +205,24 @@ class OAuth {
|
||||
return client_identity.groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the access token.
|
||||
* @returns {string}
|
||||
*/
|
||||
getAccessToken() {
|
||||
return this.#auth_info.access_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the refresh token.
|
||||
* @returns {string}
|
||||
*/
|
||||
getRefreshToken() {
|
||||
return this.#auth_info.refresh_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the auth info is valid.
|
||||
* Checks if the auth info format is valid.
|
||||
* @returns {boolean} true | false
|
||||
*/
|
||||
isValidAuthInfo() {
|
||||
|
||||
Reference in New Issue
Block a user