-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): Add
LiveChatSponsorshipsGiftPurchaseAnnouncement
and …
…`LiveChatSponsorshipsHeader` nodes (#793) * feat(parser): Add `LiveChatSponsorshipsGiftPurchaseAnnouncement` and `LiveChatSponsorshipsHeader` nodes * refactor: flatten nested field * refactor: attempt to replace `author_*` fields with a single `Author` class * fix: add back `author_*` fields in `LiveChatSponsorshipsHeader` * fix: use `parseArray` to parse author_badges data * refactor: revert `Author` logic --------- Co-authored-by: absidue <[email protected]>
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/parser/classes/livechat/items/LiveChatSponsorshipsGiftPurchaseAnnouncement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { YTNode } from '../../../helpers.js'; | ||
import { Parser, type RawNode } from '../../../index.js'; | ||
import LiveChatSponsorshipsHeader from './LiveChatSponsorshipsHeader.js'; | ||
|
||
export default class LiveChatSponsorshipsGiftPurchaseAnnouncement extends YTNode { | ||
static type = 'LiveChatSponsorshipsGiftPurchaseAnnouncement'; | ||
|
||
id: string; | ||
timestamp_usec: string; | ||
author_external_channel_id: string; | ||
header: LiveChatSponsorshipsHeader | null; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
this.id = data.id; | ||
this.timestamp_usec = data.timestampUsec; | ||
this.author_external_channel_id = data.authorExternalChannelId; | ||
this.header = Parser.parseItem(data.header, LiveChatSponsorshipsHeader); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/parser/classes/livechat/items/LiveChatSponsorshipsHeader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Parser } from '../../../index.js'; | ||
import { YTNode } from '../../../helpers.js'; | ||
import type { ObservedArray } from '../../../helpers.js'; | ||
import type { RawNode } from '../../../index.js'; | ||
import NavigationEndpoint from '../../NavigationEndpoint.js'; | ||
import Text from '../../misc/Text.js'; | ||
import Thumbnail from '../../misc/Thumbnail.js'; | ||
import LiveChatAuthorBadge from '../../LiveChatAuthorBadge.js'; | ||
|
||
export default class LiveChatSponsorshipsHeader extends YTNode { | ||
static type = 'LiveChatSponsorshipsHeader'; | ||
|
||
author_name: Text; | ||
author_photo: Thumbnail[]; | ||
author_badges: ObservedArray<LiveChatAuthorBadge> | null; | ||
primary_text: Text; | ||
menu_endpoint: NavigationEndpoint; | ||
context_menu_accessibility_label: string; | ||
image: Thumbnail[]; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
this.author_name = new Text(data.authorName); | ||
this.author_photo = Thumbnail.fromResponse(data.authorPhoto); | ||
this.author_badges = Parser.parseArray(data.authorBadges, LiveChatAuthorBadge); | ||
this.primary_text = new Text(data.primaryText); | ||
this.menu_endpoint = new NavigationEndpoint(data.contextMenuEndpoint); | ||
this.context_menu_accessibility_label = data.contextMenuAccessibility.accessibilityData.label; | ||
this.image = Thumbnail.fromResponse(data.image); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters