-
-
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.
Fix(VideoCard): fix parsing author, view count and published date
- Loading branch information
1 parent
2e782cf
commit 277a080
Showing
1 changed file
with
12 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,10 +1,22 @@ | ||
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 { | ||
static type = 'VideoCard'; | ||
|
||
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); | ||
} | ||
} | ||
} |