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

refactor(parser)!: Implement endpoint/command parsers #812

Merged
merged 12 commits into from
Nov 21, 2024

Conversation

LuanRT
Copy link
Owner

@LuanRT LuanRT commented Nov 20, 2024

Closes #810

The old request builders (under the Endpoints namespace) have been removed. Those who relied on them should now use the NavigationEndpoint node to build requests.

Example:

const continuationCommand = new YTNodes.NavigationEndpoint({
    continuationCommand: {
        request: 'CONTINUATION_REQUEST_TYPE_WATCH_NEXT',
        token: continuation
    }
});

const response = await continuationCommand.call(innertube.session.actions, /** additional payloads, etc */);
console.log(response);

Why?

The old request builders were messy and incompatible with the parser. With this PR, the parser can correctly identify endpoints, commands, and build request payloads.

@absidue
Copy link
Collaborator

absidue commented Nov 21, 2024

Before this gets merged, I would like to try adding support for this gigantic refractoring in FreeTube, we definitely need to make changes on our side. I want to check that FreeTube can still do everything that it currently does, so that I can request changes if necessary before this is merged.

@@ -26,5 +26,5 @@ export interface StreamingInfoOptions {
*
* Defaults to `(audio_track_display_name) => audio_track_display_name + " (Stable Volume)"`
*/
label_drc_mutiple?: (audio_track_display_name: string) => string;
label_drc_multiple?: (audio_track_display_name: string) => string;
Copy link
Owner Author

@LuanRT LuanRT Nov 21, 2024

Choose a reason for hiding this comment

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

^^ Technically, this is also a breaking change. This was going to be a big refactor anyway, so I went ahead fixed some typos and removed deprecated code (like the YouTube Studio stuff).

@absidue
Copy link
Collaborator

absidue commented Nov 21, 2024

As this will trigger a major version bump because of the breaking changes, should we also use it as an opportunity to get rid of some of the dead nodes?

In a separate pull request of course (wouldn't want to make this one even bigger) but in the same release because it will also be a breaking change (TypeScript users will probably get type errors after the dead nodes are removed).

Copy link
Collaborator

@absidue absidue left a comment

Choose a reason for hiding this comment

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

Less changes were necessary to FreeTube than expected (just 3 minor ones). I did notice that this increases FreeTube's bundle size by 15 kb compared to the main branch, which is likely because the endpoints used to be just variables and functions that could be inlined and now they are fully fledged classes, it's not a big deal though.

@LuanRT LuanRT marked this pull request as ready for review November 21, 2024 19:36
@LuanRT LuanRT merged commit 7397aa3 into main Nov 21, 2024
4 checks passed
@LuanRT LuanRT deleted the feat/innertube-command-parser branch November 21, 2024 21:25
@bcomnes
Copy link

bcomnes commented Dec 6, 2024

Any pointers on how to refactor the onsie request to use this new class?

https://github.com/LuanRT/googlevideo/blob/96004ce991ac7846ab6a35b29203ae208a80413b/examples/onesie-request/main.ts#L73-L77

...Endpoints.PlayerEndpoint.build({ ... })

@LuanRT
Copy link
Owner Author

LuanRT commented Dec 6, 2024

@bcomnes
Copy link

bcomnes commented Dec 7, 2024

Hrmmm. afraid I'm still not quite getting it.

Any plans to update the onesie example to use v12 of youtubei.js? I can reference that if you do.

@LuanRT
Copy link
Owner Author

LuanRT commented Dec 10, 2024

@bcomnes LuanRT/googlevideo@7a106dc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a proper endpoint/command mapper
3 participants