From a0e6cef00fb9e3f52593cec22704f7ddc1f7553e Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Sat, 25 Feb 2023 16:11:03 +0100 Subject: [PATCH] fix(PlayerMicroformat): Make the embed field optional (#320) --- src/parser/classes/PlayerMicroformat.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/parser/classes/PlayerMicroformat.ts b/src/parser/classes/PlayerMicroformat.ts index 2ea56a99..814509cc 100644 --- a/src/parser/classes/PlayerMicroformat.ts +++ b/src/parser/classes/PlayerMicroformat.ts @@ -16,7 +16,7 @@ class PlayerMicroformat extends YTNode { // TODO: check these width: any; height: any; - }; + } | null; length_seconds: number; @@ -42,13 +42,17 @@ class PlayerMicroformat extends YTNode { this.description = new Text(data.description); this.thumbnails = Thumbnail.fromResponse(data.thumbnail); - this.embed = { - iframe_url: data.embed.iframeUrl, - flash_url: data.embed.flashUrl, - flash_secure_url: data.embed.flashSecureUrl, - width: data.embed.width, - height: data.embed.height - }; + if (data.embed) { + this.embed = { + iframe_url: data.embed.iframeUrl, + flash_url: data.embed.flashUrl, + flash_secure_url: data.embed.flashSecureUrl, + width: data.embed.width, + height: data.embed.height + }; + } else { + this.embed = null; + } this.length_seconds = parseInt(data.lengthSeconds);