diff --git a/src/parser/classes/CompactVideo.ts b/src/parser/classes/CompactVideo.ts index 7946839c2..443dfd1c9 100644 --- a/src/parser/classes/CompactVideo.ts +++ b/src/parser/classes/CompactVideo.ts @@ -5,6 +5,7 @@ import { timeToSeconds } from '../../utils/Utils'; import Thumbnail from './misc/Thumbnail'; import NavigationEndpoint from './NavigationEndpoint'; import type Menu from './menus/Menu'; +import MetadataBadge from './MetadataBadge'; import { YTNode } from '../helpers'; @@ -19,6 +20,7 @@ class CompactVideo extends YTNode { view_count: Text; short_view_count: Text; published: Text; + badges: MetadataBadge[]; duration: { text: string; @@ -39,6 +41,7 @@ class CompactVideo extends YTNode { this.view_count = new Text(data.viewCountText); this.short_view_count = new Text(data.shortViewCountText); this.published = new Text(data.publishedTimeText); + this.badges = Parser.parseArray(data.badges, MetadataBadge); this.duration = { text: new Text(data.lengthText).toString(), @@ -53,6 +56,25 @@ class CompactVideo extends YTNode { get best_thumbnail() { return this.thumbnails[0]; } + + get is_fundraiser(): boolean { + return this.badges.some((badge) => badge.style === 'Fundraiser'); + } + + get is_live(): boolean { + return this.badges.some((badge) => { + if (badge.label === 'BADGE_STYLE_TYPE_LIVE_NOW' || badge.style === 'LIVE') + return true; + }); + } + + get is_new(): boolean { + return this.badges.some((badge) => badge.style === 'New'); + } + + get is_premiere(): boolean { + return this.badges.some((badge) => badge.style === 'PREMIERE'); + } } export default CompactVideo; \ No newline at end of file