mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-16 11:02:10 +00:00
refactor!: overhaul core classes and remove redundant code (#388)
* feat(Player.ts): append `cver` to deciphered URLs * refactor(Actions.ts): remove redundant `getVideoInfo` function This is leftover code from previous versions. It had many problems and it is no longer required. * fix(Kids.ts): remove unneeded `await` keywords * dev: add more endpoints * chore: update deps * refactor: separate endpoints into files * dev: improve types * dev: add more endpoints * refactor: put clients in a separate directory inside `core` * chore: lint * refactor: move mixins and managers to separate folders * chore: fix tests * dev: add `CreateVideoEndpoint` * chore: clean up * chore: lint * chore: add some comments * chore: remove unnecessary test * dev: add `playlist/CreateEndpoint` * dev: add `playlist/DeleteEndpoint` * dev: add `browse/EditPlaylistEndpoint` * fix(parser): add a few checks to avoid parsing errors
This commit is contained in:
@@ -54,9 +54,9 @@ export default class HTTPClient {
|
||||
|
||||
request_headers.set('Accept', '*/*');
|
||||
request_headers.set('Accept-Language', '*');
|
||||
request_headers.set('x-goog-visitor-id', this.#session.context.client.visitorData || '');
|
||||
request_headers.set('x-origin', request_url.origin);
|
||||
request_headers.set('x-youtube-client-version', this.#session.context.client.clientVersion || '');
|
||||
request_headers.set('X-Goog-Visitor-Id', this.#session.context.client.visitorData || '');
|
||||
request_headers.set('X-Origin', request_url.origin);
|
||||
request_headers.set('X-Youtube-Client-Version', this.#session.context.client.clientVersion || '');
|
||||
|
||||
if (Platform.shim.server) {
|
||||
request_headers.set('User-Agent', getRandomUserAgent('desktop'));
|
||||
@@ -91,7 +91,6 @@ export default class HTTPClient {
|
||||
|
||||
delete n_body.client;
|
||||
|
||||
|
||||
if (Platform.shim.server) {
|
||||
if (n_body.context.client.clientName === 'ANDROID' || n_body.context.client.clientName === 'ANDROID_MUSIC') {
|
||||
request_headers.set('User-Agent', Constants.CLIENTS.ANDROID.USER_AGENT);
|
||||
@@ -143,6 +142,19 @@ export default class HTTPClient {
|
||||
}
|
||||
|
||||
#adjustContext(ctx: Context, client: string): void {
|
||||
if (
|
||||
client === 'ANDROID' ||
|
||||
client === 'YTMUSIC_ANDROID' ||
|
||||
client === 'YTMUSIC_ANDROID' ||
|
||||
client === 'YTSTUDIO_ANDROID'
|
||||
) {
|
||||
ctx.client.androidSdkVersion = Constants.CLIENTS.ANDROID.SDK_VERSION;
|
||||
ctx.client.userAgent = Constants.CLIENTS.ANDROID.USER_AGENT;
|
||||
ctx.client.osName = 'Android';
|
||||
ctx.client.osVersion = '10';
|
||||
ctx.client.platform = 'MOBILE';
|
||||
}
|
||||
|
||||
switch (client) {
|
||||
case 'YTMUSIC':
|
||||
ctx.client.clientVersion = Constants.CLIENTS.YTMUSIC.VERSION;
|
||||
@@ -152,21 +164,16 @@ export default class HTTPClient {
|
||||
ctx.client.clientVersion = Constants.CLIENTS.ANDROID.VERSION;
|
||||
ctx.client.clientFormFactor = 'SMALL_FORM_FACTOR';
|
||||
ctx.client.clientName = Constants.CLIENTS.ANDROID.NAME;
|
||||
ctx.client.androidSdkVersion = Constants.CLIENTS.ANDROID.SDK_VERSION;
|
||||
ctx.client.platform = 'MOBILE';
|
||||
break;
|
||||
case 'YTMUSIC_ANDROID':
|
||||
ctx.client.clientVersion = Constants.CLIENTS.YTMUSIC_ANDROID.VERSION;
|
||||
ctx.client.clientFormFactor = 'SMALL_FORM_FACTOR';
|
||||
ctx.client.clientName = Constants.CLIENTS.YTMUSIC_ANDROID.NAME;
|
||||
ctx.client.androidSdkVersion = Constants.CLIENTS.ANDROID.SDK_VERSION;
|
||||
ctx.client.platform = 'MOBILE';
|
||||
break;
|
||||
case 'YTSTUDIO_ANDROID':
|
||||
ctx.client.clientVersion = Constants.CLIENTS.YTSTUDIO_ANDROID.VERSION;
|
||||
ctx.client.clientFormFactor = 'SMALL_FORM_FACTOR';
|
||||
ctx.client.clientName = Constants.CLIENTS.YTSTUDIO_ANDROID.NAME;
|
||||
ctx.client.androidSdkVersion = Constants.CLIENTS.ANDROID.SDK_VERSION;
|
||||
break;
|
||||
case 'TV_EMBEDDED':
|
||||
ctx.client.clientName = Constants.CLIENTS.TV_EMBEDDED.NAME;
|
||||
|
||||
Reference in New Issue
Block a user