mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 12:31:17 +00:00
refactor: improve livechat parser & add remaining action nodes (#285)
* refactor: improve live chat parsers & add missing nodes * chore: update example and docs * docs: rephrasing/formatting * chore: remove unneeded test (unrelated)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { observe, ObservedArray, YTNode } from '../../../helpers';
|
||||
import Parser from '../../../index';
|
||||
import NavigationEndpoint from '../../NavigationEndpoint';
|
||||
import Thumbnail from '../../misc/Thumbnail';
|
||||
import LiveChatAuthorBadge from '../../LiveChatAuthorBadge';
|
||||
import MetadataBadge from '../../MetadataBadge';
|
||||
import Text from '../../misc/Text';
|
||||
import { YTNode } from '../../../helpers';
|
||||
import Thumbnail from '../../misc/Thumbnail';
|
||||
import NavigationEndpoint from '../../NavigationEndpoint';
|
||||
|
||||
class LiveChatPaidSticker extends YTNode {
|
||||
static type = 'LiveChatPaidSticker';
|
||||
@@ -13,7 +15,10 @@ class LiveChatPaidSticker extends YTNode {
|
||||
id: string;
|
||||
name: Text;
|
||||
thumbnails: Thumbnail[];
|
||||
badges: any;
|
||||
badges: ObservedArray<LiveChatAuthorBadge | MetadataBadge>;
|
||||
is_moderator: boolean | null;
|
||||
is_verified: boolean | null;
|
||||
is_verified_artist: boolean | null;
|
||||
};
|
||||
|
||||
money_chip_background_color: number;
|
||||
@@ -34,9 +39,19 @@ class LiveChatPaidSticker extends YTNode {
|
||||
id: data.authorExternalChannelId,
|
||||
name: new Text(data.authorName),
|
||||
thumbnails: Thumbnail.fromResponse(data.authorPhoto),
|
||||
badges: Parser.parse(data.authorBadges)
|
||||
badges: observe([]).as(LiveChatAuthorBadge, MetadataBadge),
|
||||
is_moderator: null,
|
||||
is_verified: null,
|
||||
is_verified_artist: null
|
||||
};
|
||||
|
||||
const badges = Parser.parseArray<LiveChatAuthorBadge | MetadataBadge>(data.authorBadges, [ MetadataBadge, LiveChatAuthorBadge ]);
|
||||
|
||||
this.author.badges = badges;
|
||||
this.author.is_moderator = badges ? badges.some((badge) => badge.icon_type == 'MODERATOR') : null;
|
||||
this.author.is_verified = badges ? badges.some((badge) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED') : null;
|
||||
this.author.is_verified_artist = badges ? badges.some((badge) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED_ARTIST') : null;
|
||||
|
||||
this.money_chip_background_color = data.moneyChipBackgroundColor;
|
||||
this.money_chip_text_color = data.moneyChipTextColor;
|
||||
this.background_color = data.backgroundColor;
|
||||
|
||||
Reference in New Issue
Block a user