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(proto): Add comment_id to commentSectionParams #693

Merged
merged 1 commit into from
Jul 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export declare namespace $.youtube.GetCommentsSectionParams.Params {
videoId: string;
sortBy: number;
type: number;
commentId?: string;
}
}

Expand All @@ -31,6 +32,7 @@ export function getDefaultValue(): $.youtube.GetCommentsSectionParams.Params.Opt
videoId: "",
sortBy: 0,
type: 0,
commentId: undefined,
};
}

Expand All @@ -46,6 +48,7 @@ export function encodeJson(value: $.youtube.GetCommentsSectionParams.Params.Opti
if (value.videoId !== undefined) result.videoId = tsValueToJsonValueFns.string(value.videoId);
if (value.sortBy !== undefined) result.sortBy = tsValueToJsonValueFns.int32(value.sortBy);
if (value.type !== undefined) result.type = tsValueToJsonValueFns.int32(value.type);
if (value.commentId !== undefined) result.commentId = tsValueToJsonValueFns.string(value.commentId);
return result;
}

Expand All @@ -54,6 +57,7 @@ export function decodeJson(value: any): $.youtube.GetCommentsSectionParams.Param
if (value.videoId !== undefined) result.videoId = jsonValueToTsValueFns.string(value.videoId);
if (value.sortBy !== undefined) result.sortBy = jsonValueToTsValueFns.int32(value.sortBy);
if (value.type !== undefined) result.type = jsonValueToTsValueFns.int32(value.type);
if (value.commentId !== undefined) result.commentId = jsonValueToTsValueFns.string(value.commentId);
return result;
}

Expand All @@ -77,6 +81,12 @@ export function encodeBinary(value: $.youtube.GetCommentsSectionParams.Params.Op
[15, tsValueToWireValueFns.int32(tsValue)],
);
}
if (value.commentId !== undefined) {
const tsValue = value.commentId;
result.push(
[16, tsValueToWireValueFns.string(tsValue)],
);
}
return serialize(result);
}

Expand Down Expand Up @@ -105,5 +115,12 @@ export function decodeBinary(binary: Uint8Array): $.youtube.GetCommentsSectionPa
if (value === undefined) break field;
result.type = value;
}
field: {
const wireValue = wireFields.get(16);
if (wireValue === undefined) break field;
const value = wireValueToTsValueFns.string(wireValue);
if (value === undefined) break field;
result.commentId = value;
}
return result;
}
6 changes: 4 additions & 2 deletions src/proto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export function encodeMessageParams(channel_id: string, video_id: string): strin

export function encodeCommentsSectionParams(video_id: string, options: {
type?: number,
sort_by?: 'TOP_COMMENTS' | 'NEWEST_FIRST'
sort_by?: 'TOP_COMMENTS' | 'NEWEST_FIRST',
comment_id?: string
} = {}): string {
const sort_options = {
TOP_COMMENTS: 0,
Expand All @@ -171,7 +172,8 @@ export function encodeCommentsSectionParams(video_id: string, options: {
opts: {
videoId: video_id,
sortBy: sort_options[options.sort_by || 'TOP_COMMENTS'],
type: options.type || 2
type: options.type || 2,
commentId: options.comment_id || ''
},
target: 'comments-section'
}
Expand Down
1 change: 1 addition & 0 deletions src/proto/youtube.proto
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ message GetCommentsSectionParams {
required string video_id = 4;
required int32 sort_by = 6;
required int32 type = 15;
optional string comment_id = 16;
}

message RepliesOptions {
Expand Down
Loading