mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-22 05:58:14 +00:00
chore(parser): lint
This commit is contained in:
@@ -10,42 +10,47 @@ import type Actions from '../../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../../core/Actions.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
// TODO: Move these types to a different file.
|
||||
export type CommentKeys = {
|
||||
comment: string;
|
||||
comment_surface: string;
|
||||
toolbar_state: string;
|
||||
toolbar_surface: string;
|
||||
shared: string;
|
||||
}
|
||||
|
||||
export type MemberBadge = {
|
||||
url: string;
|
||||
a11y: string;
|
||||
}
|
||||
|
||||
export default class CommentView extends YTNode {
|
||||
static type = 'CommentView';
|
||||
|
||||
#actions?: Actions;
|
||||
|
||||
like_command?: NavigationEndpoint;
|
||||
dislike_command?: NavigationEndpoint;
|
||||
unlike_command?: NavigationEndpoint;
|
||||
undislike_command?: NavigationEndpoint;
|
||||
reply_command?: NavigationEndpoint;
|
||||
public like_command?: NavigationEndpoint;
|
||||
public dislike_command?: NavigationEndpoint;
|
||||
public unlike_command?: NavigationEndpoint;
|
||||
public undislike_command?: NavigationEndpoint;
|
||||
public reply_command?: NavigationEndpoint;
|
||||
|
||||
comment_id: string;
|
||||
is_pinned: boolean;
|
||||
keys: {
|
||||
comment: string;
|
||||
comment_surface: string;
|
||||
toolbar_state: string;
|
||||
toolbar_surface: string;
|
||||
shared: string;
|
||||
};
|
||||
public comment_id: string;
|
||||
public is_pinned: boolean;
|
||||
public keys: CommentKeys;
|
||||
|
||||
content?: Text;
|
||||
published_time?: string;
|
||||
author_is_channel_owner?: boolean;
|
||||
like_count?: string;
|
||||
reply_count?: string;
|
||||
is_member?: boolean;
|
||||
member_badge?: {
|
||||
url: string,
|
||||
a11y: string;
|
||||
};
|
||||
author?: Author;
|
||||
public content?: Text;
|
||||
public published_time?: string;
|
||||
public author_is_channel_owner?: boolean;
|
||||
public like_count?: string;
|
||||
public reply_count?: string;
|
||||
public is_member?: boolean;
|
||||
public member_badge?: MemberBadge;
|
||||
public author?: Author;
|
||||
|
||||
is_liked?: boolean;
|
||||
is_disliked?: boolean;
|
||||
is_hearted?: boolean;
|
||||
public is_liked?: boolean;
|
||||
public is_disliked?: boolean;
|
||||
public is_hearted?: boolean;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
@@ -205,7 +210,7 @@ export default class CommentView extends YTNode {
|
||||
/**
|
||||
* Translates the comment to the specified target language.
|
||||
* @param target_language - The target language to translate the comment to, e.g. 'en', 'ja'.
|
||||
* @returns A Promise that resolves to an ApiResponse object with the translated content, if available.
|
||||
* @returns Resolves to an ApiResponse object with the translated content, if available.
|
||||
* @throws if the Actions instance is not set for this comment or if the comment content is not found.
|
||||
*/
|
||||
async translate(target_language: string): Promise<ApiResponse & { content?: string }> {
|
||||
@@ -218,13 +223,10 @@ export default class CommentView extends YTNode {
|
||||
// Emojis must be removed otherwise InnerTube throws a 400 status code at us.
|
||||
const text = this.content.toString().replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu, '');
|
||||
|
||||
const payload = {
|
||||
text,
|
||||
target_language
|
||||
};
|
||||
const payload = { text, target_language };
|
||||
|
||||
const action = ProtoUtils.encodeCommentActionParams(22, payload);
|
||||
const response = await this.#actions.execute('comment/perform_comment_action', { action, client: 'ANDROID' });
|
||||
const response = await this.#actions.execute('comment/perform_comment_action', { action });
|
||||
|
||||
// XXX: Should move this to Parser#parseResponse
|
||||
const mutations = response.data.frameworkUpdates?.entityBatchUpdate?.mutations;
|
||||
|
||||
Reference in New Issue
Block a user