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

feat(ProtoUtils): Add support for creating NextParams #762

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
63 changes: 63 additions & 0 deletions protos/generated/misc/params.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions protos/misc/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,8 @@ message ShortsParam {
}
optional Field1 f1 = 1;
optional int32 p59 = 59;
}

message NextParams {
repeated string video_id = 5;
}
7 changes: 6 additions & 1 deletion src/utils/ProtoUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { base64ToU8, u8ToBase64 } from './Utils.js';
import { VisitorData, PeformCommentActionParams } from '../../protos/generated/misc/params.js';
import { VisitorData, PeformCommentActionParams, NextParams } from '../../protos/generated/misc/params.js';

export function encodeVisitorData(id: string, timestamp: number): string {
const writer = VisitorData.encode({ id, timestamp });
Expand Down Expand Up @@ -45,4 +45,9 @@ export function encodeCommentActionParams(type: number, args: {

const writer = PeformCommentActionParams.encode(data);
return encodeURIComponent(u8ToBase64(writer.finish()));
}

export function encodeNextParams(video_ids: string[]): string {
const writer = NextParams.encode({ videoId: video_ids });
return encodeURIComponent(u8ToBase64(writer.finish()).replace(/\+/g, '-').replace(/\//g, '_'));
}