From 8463f6877a0e4c0b8e9616af29fe71059130410c Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:53:53 -0500 Subject: [PATCH 1/3] Feat: parse isLive in CompactVideo --- src/parser/classes/CompactVideo.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/parser/classes/CompactVideo.ts b/src/parser/classes/CompactVideo.ts index 7946839c2..b696b9ae2 100644 --- a/src/parser/classes/CompactVideo.ts +++ b/src/parser/classes/CompactVideo.ts @@ -19,6 +19,7 @@ class CompactVideo extends YTNode { view_count: Text; short_view_count: Text; published: Text; + is_live: Boolean; duration: { text: string; @@ -39,6 +40,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.is_live = data.badges?.some((badge: any) => badge.metadataBadgeRenderer.style == 'BADGE_STYLE_TYPE_LIVE_NOW') || false; this.duration = { text: new Text(data.lengthText).toString(), From 7d3ee0c770bae36c4c5d050ecf97bf114e7c789e Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Wed, 25 Jan 2023 06:02:55 -0500 Subject: [PATCH 2/3] Use 3 equal signs Co-authored-by: absidue <48293849+absidue@users.noreply.github.com> --- src/parser/classes/CompactVideo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/classes/CompactVideo.ts b/src/parser/classes/CompactVideo.ts index b696b9ae2..3944014b9 100644 --- a/src/parser/classes/CompactVideo.ts +++ b/src/parser/classes/CompactVideo.ts @@ -40,7 +40,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.is_live = data.badges?.some((badge: any) => badge.metadataBadgeRenderer.style == 'BADGE_STYLE_TYPE_LIVE_NOW') || false; + this.is_live = data.badges?.some((badge: any) => badge.metadataBadgeRenderer.style === 'BADGE_STYLE_TYPE_LIVE_NOW') || false; this.duration = { text: new Text(data.lengthText).toString(), From b510f106519385a84730cdb52e8d4b8137b1a4fd Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Fri, 27 Jan 2023 07:43:34 -0500 Subject: [PATCH 3/3] use parse array for badges add is_premiere, is_new, is_fundraiser --- src/parser/classes/CompactVideo.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/parser/classes/CompactVideo.ts b/src/parser/classes/CompactVideo.ts index b696b9ae2..1dc838741 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,7 +20,7 @@ class CompactVideo extends YTNode { view_count: Text; short_view_count: Text; published: Text; - is_live: Boolean; + badges: MetadataBadge[]; duration: { text: string; @@ -40,7 +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.is_live = data.badges?.some((badge: any) => badge.metadataBadgeRenderer.style == 'BADGE_STYLE_TYPE_LIVE_NOW') || false; + this.badges = Parser.parseArray(data.badges, MetadataBadge); this.duration = { text: new Text(data.lengthText).toString(), @@ -52,6 +53,25 @@ class CompactVideo extends YTNode { this.menu = Parser.parseItem