mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-28 09:06:51 +00:00
refactor: Migrate to ts-proto (#752)
* refactor: Add extracted protos * refactor: Remove old stuff and update affected code * chore(package): Update `build:proto` script * chore(ClientInfo): Rename `androidSdkVersion` to `android_sdk_version` * chore: remove refs to old proto file * refactor(sabr_request): Rename `Gw` to `media_type` * chore(sabr_request): Fix typo in field num * feat(parser): Parse `video_playback_ustreamer_config` and `server_abr_streaming_url` * refactor: update protos * chore(package): streamline clean and build scripts * chore: update package.json * chore: update npmignore * chore(protos): Remove unneeded definitions See https://github.com/LuanRT/googlevideo for video playback proto definitions. * chore(package): add `rimraf` dependency
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import * as Proto from '../../proto/index.js';
|
||||
import { EventEmitter } from '../../utils/index.js';
|
||||
import { InnertubeError, Platform } from '../../utils/Utils.js';
|
||||
import { InnertubeError, Platform, u8ToBase64 } from '../../utils/Utils.js';
|
||||
import { Parser, LiveChatContinuation } from '../index.js';
|
||||
import SmoothedQueue from './SmoothedQueue.js';
|
||||
|
||||
@@ -13,6 +12,8 @@ import UpdateViewershipAction from '../classes/livechat/UpdateViewershipAction.j
|
||||
import NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
import ItemMenu from './ItemMenu.js';
|
||||
|
||||
import { LiveMessageParams } from '../../../protos/generated/misc/params.js';
|
||||
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
|
||||
import type VideoInfo from './VideoInfo.js';
|
||||
@@ -42,7 +43,7 @@ export type ChatAction =
|
||||
ReplaceChatItemAction | ReplayChatItemAction | ShowLiveChatActionPanelAction | ShowLiveChatTooltipCommand;
|
||||
|
||||
export type ChatItemWithMenu = LiveChatAutoModMessage | LiveChatMembershipItem | LiveChatPaidMessage | LiveChatPaidSticker | LiveChatTextMessage | LiveChatViewerEngagementMessage;
|
||||
|
||||
|
||||
export interface LiveMetadata {
|
||||
title?: UpdateTitleAction;
|
||||
description?: UpdateDescriptionAction;
|
||||
@@ -250,12 +251,25 @@ export default class LiveChat extends EventEmitter {
|
||||
* @param text - Text to send.
|
||||
*/
|
||||
async sendMessage(text: string): Promise<ObservedArray<AddChatItemAction>> {
|
||||
const writer = LiveMessageParams.encode({
|
||||
params: {
|
||||
ids: {
|
||||
videoId: this.#video_id,
|
||||
channelId: this.#channel_id
|
||||
}
|
||||
},
|
||||
number0: 1,
|
||||
number1: 4
|
||||
});
|
||||
|
||||
const params = btoa(encodeURIComponent(u8ToBase64(writer.finish())));
|
||||
|
||||
const response = await this.#actions.execute('/live_chat/send_message', {
|
||||
params: Proto.encodeMessageParams(this.#channel_id, this.#video_id),
|
||||
richMessage: { textSegments: [ { text } ] },
|
||||
clientMessageId: Platform.shim.uuidv4(),
|
||||
client: 'ANDROID',
|
||||
parse: true
|
||||
parse: true,
|
||||
params
|
||||
});
|
||||
|
||||
if (!response.actions)
|
||||
|
||||
Reference in New Issue
Block a user