feature(proto): Add comment_id to commentSectionParams (#693)

This commit is contained in:
GurumNyang
2024-07-25 03:54:14 +09:00
committed by GitHub
parent a352ddeb9d
commit a5f62093a1
3 changed files with 22 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ export declare namespace $.youtube.GetCommentsSectionParams.Params {
videoId: string;
sortBy: number;
type: number;
commentId?: string;
}
}
@@ -31,6 +32,7 @@ export function getDefaultValue(): $.youtube.GetCommentsSectionParams.Params.Opt
videoId: "",
sortBy: 0,
type: 0,
commentId: undefined,
};
}
@@ -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;
}
@@ -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;
}
@@ -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);
}
@@ -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;
}

View File

@@ -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,
@@ -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'
}

View File

@@ -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 {