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(LiveChatPaidMessage): Parse headerOverlayImage and lowerBumper #851

Merged
merged 2 commits into from
Dec 22, 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
18 changes: 18 additions & 0 deletions src/parser/classes/livechat/items/BumperUserEduContentView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { YTNode } from '../../../helpers.js';
import { type RawNode } from '../../../index.js';
import Text from '../../misc/Text.js';

export default class BumperUserEduContentView extends YTNode {
static type = 'BumperUserEduContentView';

text: Text;
image_name: string;
image_color: number;

constructor(data: RawNode) {
super();
this.text = Text.fromAttributed(data.text);
this.image_name = data.image.sources[0].clientResource.imageName;
this.image_color = data.image.sources[0].clientResource.imageColor;
}
}
14 changes: 14 additions & 0 deletions src/parser/classes/livechat/items/LiveChatItemBumperView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { YTNode } from '../../../helpers.js';
import { Parser, type RawNode } from '../../../index.js';
import BumperUserEduContentView from './BumperUserEduContentView.js';

export default class LiveChatItemBumperView extends YTNode {
static type = 'LiveChatItemBumperView';

content: BumperUserEduContentView | null;

constructor(data: RawNode) {
super();
this.content = Parser.parseItem(data.content, BumperUserEduContentView);
}
}
10 changes: 10 additions & 0 deletions src/parser/classes/livechat/items/LiveChatPaidMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { Parser, type RawNode } from '../../../index.js';
import NavigationEndpoint from '../../NavigationEndpoint.js';
import Author from '../../misc/Author.js';
import Text from '../../misc/Text.js';
import Thumbnail from '../../misc/Thumbnail.js';
import CreatorHeartView from './CreatorHeartView.js';
import LiveChatItemBumperView from './LiveChatItemBumperView.js';
import PdgReplyButtonView from './PdgReplyButtonView.js';

export default class LiveChatPaidMessage extends YTNode {
Expand All @@ -24,7 +26,9 @@ export default class LiveChatPaidMessage extends YTNode {
timestamp_usec: string;
timestamp_text?: string;
timestamp_color: number;
header_overlay_image?: Thumbnail[];
text_input_background_color: number;
lower_bumper: LiveChatItemBumperView | null;
creator_heart_button: CreatorHeartView | null;
is_v2_style: boolean;
reply_button: PdgReplyButtonView | null;
Expand Down Expand Up @@ -57,7 +61,13 @@ export default class LiveChatPaidMessage extends YTNode {
}

this.timestamp_color = data.timestampColor;

if (Reflect.has(data, 'headerOverlayImage')) {
this.header_overlay_image = Thumbnail.fromResponse(data.headerOverlayImage);
}

this.text_input_background_color = data.textInputBackgroundColor;
this.lower_bumper = Parser.parseItem(data.lowerBumper, LiveChatItemBumperView);
this.creator_heart_button = Parser.parseItem(data.creatorHeartButton, CreatorHeartView);
this.is_v2_style = data.isV2Style;
this.reply_button = Parser.parseItem(data.replyButton, PdgReplyButtonView);
Expand Down
2 changes: 2 additions & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,15 @@ export { default as AddBannerToLiveChatCommand } from './classes/livechat/AddBan
export { default as AddChatItemAction } from './classes/livechat/AddChatItemAction.js';
export { default as AddLiveChatTickerItemAction } from './classes/livechat/AddLiveChatTickerItemAction.js';
export { default as DimChatItemAction } from './classes/livechat/DimChatItemAction.js';
export { default as BumperUserEduContentView } from './classes/livechat/items/BumperUserEduContentView.js';
export { default as CreatorHeartView } from './classes/livechat/items/CreatorHeartView.js';
export { default as LiveChatAutoModMessage } from './classes/livechat/items/LiveChatAutoModMessage.js';
export { default as LiveChatBanner } from './classes/livechat/items/LiveChatBanner.js';
export { default as LiveChatBannerChatSummary } from './classes/livechat/items/LiveChatBannerChatSummary.js';
export { default as LiveChatBannerHeader } from './classes/livechat/items/LiveChatBannerHeader.js';
export { default as LiveChatBannerPoll } from './classes/livechat/items/LiveChatBannerPoll.js';
export { default as LiveChatBannerRedirect } from './classes/livechat/items/LiveChatBannerRedirect.js';
export { default as LiveChatItemBumperView } from './classes/livechat/items/LiveChatItemBumperView.js';
export { default as LiveChatMembershipItem } from './classes/livechat/items/LiveChatMembershipItem.js';
export { default as LiveChatModeChangeMessage } from './classes/livechat/items/LiveChatModeChangeMessage.js';
export { default as LiveChatPaidMessage } from './classes/livechat/items/LiveChatPaidMessage.js';
Expand Down
Loading