Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first try #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/core/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ export type SessionOptions = {
* Fetch function to use.
*/
fetch?: FetchFunction;
/**
* Token for serviceIntegrityDimensions
*/
po_token?: string;
}

export type SessionData = {
Expand Down Expand Up @@ -213,8 +217,9 @@ export default class Session extends EventEmitter {
key: string;
api_version: string;
account_index: number;
po_token?: string;

constructor(context: Context, api_key: string, api_version: string, account_index: number, player?: Player, cookie?: string, fetch?: FetchFunction, cache?: ICache) {
constructor(context: Context, api_key: string, api_version: string, account_index: number, player?: Player, cookie?: string, fetch?: FetchFunction, cache?: ICache, po_token?: string) {
Copy link

@LuanRT LuanRT Jul 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok there's another problem here actually. po_token is a parameter, but it's not being used anywhere. Session#create is not passing the token from SessionOptions when instantiating the class:

return new Session(
context, api_key, api_version, account_index,
options.retrieve_player === false ? undefined : await Player.create(options.cache, options.fetch),
options.cookie, options.fetch, options.cache
);
}

super();
this.http = new HTTPClient(this, cookie, fetch);
this.actions = new Actions(this);
Expand All @@ -226,6 +231,7 @@ export default class Session extends EventEmitter {
this.api_version = api_version;
this.context = context;
this.player = player;
this.po_token = po_token;
}

on(type: 'auth', listener: OAuth2AuthEventHandler): void;
Expand Down
7 changes: 5 additions & 2 deletions src/core/endpoints/PlayerEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export function build(opts: PlayerEndpointOptions): IPlayerRequest {
...{
client: opts.client,
playlistId: opts.playlist_id,
params: opts.params
}
params: opts.params,
serviceIntegrityDimensions: {
poToken: session.po_token.toString(),
Copy link

@LuanRT LuanRT Jul 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you added po_token to the PlayerEndpointOptions type, so I think you meant opts.po_token here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that it looks good. But one last thing, you'll have to update the methods from the Innertube class that use this endpoint (getInfo & getBasicInfo).

},
},
};
}
7 changes: 7 additions & 0 deletions src/types/Endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export interface IPlayerRequest {
playlistId?: string;
params?: string;
client?: InnerTubeClient;
serviceIntegrityDimensions?: {
poToken: string
}
}

export type PlayerEndpointOptions = {
Expand All @@ -52,6 +55,10 @@ export type PlayerEndpointOptions = {
* Additional protobuf parameters.
*/
params?: string;
/**
* Token for serviceIntegrityDimensions
*/
po_token?: string;
}

export type NextEndpointOptions = {
Expand Down