feat(Thumbnail): Support sources in Thumbnail.fromResponse (#552)

This commit is contained in:
absidue
2023-12-04 17:50:08 +01:00
committed by GitHub
parent 37ae55a7c3
commit 48a5d4e7c3
6 changed files with 30 additions and 35 deletions

View File

@@ -10,9 +10,7 @@ import Thumbnail from './misc/Thumbnail.js';
export default class VideoAttributeView extends YTNode {
static type = 'VideoAttributeView';
image: ContentPreviewImageView | {
sources: Thumbnail[];
} | null;
image: ContentPreviewImageView | Thumbnail[] | null;
image_style: string;
title: string;
subtitle: string;
@@ -26,11 +24,9 @@ export default class VideoAttributeView extends YTNode {
constructor(data: RawNode) {
super();
// @NOTE: "image" is not a renderer so not sure why we're parsing it as one. Leaving this hack here for now to avoid breaking things.
if (data.image?.sources) {
this.image = {
sources: data.image.sources.map((x: any) => new Thumbnail(x)).sort((a: Thumbnail, b: Thumbnail) => b.width - a.width)
};
this.image = Thumbnail.fromResponse(data.image);
} else {
this.image = Parser.parseItem(data.image, ContentPreviewImageView);
}