From 277a08069f993aa951df6f95c9bb84546b45e299 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:00:06 -0400 Subject: [PATCH] Fix(VideoCard): fix parsing author, view count and published date --- src/parser/classes/VideoCard.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/parser/classes/VideoCard.ts b/src/parser/classes/VideoCard.ts index 88de7fc02..2950a9670 100644 --- a/src/parser/classes/VideoCard.ts +++ b/src/parser/classes/VideoCard.ts @@ -1,4 +1,6 @@ import type { RawNode } from '../index.js'; +import Author from './misc/Author.js'; +import Text from './misc/Text.js'; import Video from './Video.js'; export default class VideoCard extends Video { @@ -6,5 +8,15 @@ export default class VideoCard extends Video { constructor(data: RawNode) { super(data); + if (Reflect.has(data, 'metadataText')) { + const metadata = new Text(data.metadataText); + if (metadata.text) { + this.short_view_count = new Text({ simpleText: metadata.text.split('·')[0].trim() } as RawNode); + this.published = new Text({ simpleText: metadata.text.split('·')[1].trim() } as RawNode); + } + } + if (Reflect.has(data, 'bylineText')) { + this.author = new Author(data.bylineText, data.ownerBadges, data.channelThumbnailSupportedRenderers?.channelThumbnailWithLinkRenderer?.thumbnail); + } } } \ No newline at end of file