mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-13 01:22:11 +00:00
fix(LockupView): Fix content_image parsing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import ThumbnailView from './ThumbnailView.js';
|
||||
import CollectionThumbnailView from './CollectionThumbnailView.js';
|
||||
import LockupMetadataView from './LockupMetadataView.js';
|
||||
import RendererContext from './misc/RendererContext.js';
|
||||
@@ -7,7 +8,7 @@ import RendererContext from './misc/RendererContext.js';
|
||||
export default class LockupView extends YTNode {
|
||||
static type = 'LockupView';
|
||||
|
||||
public content_image: CollectionThumbnailView | null;
|
||||
public content_image: CollectionThumbnailView | ThumbnailView | null;
|
||||
public metadata: LockupMetadataView | null;
|
||||
public content_id: string;
|
||||
public content_type: 'VIDEO' | 'MOVIE' | 'CHANNEL' | 'CLIP' | 'SOURCE' | 'PLAYLIST' | 'ALBUM' | 'PODCAST' | 'SHOPPING_COLLECTION' | 'SHORT' | 'GAME' | 'PRODUCT';
|
||||
@@ -15,7 +16,7 @@ export default class LockupView extends YTNode {
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.content_image = Parser.parseItem(data.contentImage, CollectionThumbnailView);
|
||||
this.content_image = Parser.parseItem(data.contentImage, [ CollectionThumbnailView, ThumbnailView ]);
|
||||
this.metadata = Parser.parseItem(data.metadata, LockupMetadataView);
|
||||
this.content_id = data.contentId;
|
||||
this.content_type = data.contentType.replace('LOCKUP_CONTENT_TYPE_', '');
|
||||
|
||||
@@ -4,22 +4,25 @@ import ThumbnailHoverOverlayView from './ThumbnailHoverOverlayView.js';
|
||||
import ThumbnailOverlayBadgeView from './ThumbnailOverlayBadgeView.js';
|
||||
import Thumbnail from './misc/Thumbnail.js';
|
||||
|
||||
export type ThumbnailBackgroundColor = {
|
||||
light_theme: number;
|
||||
dark_theme: number;
|
||||
};
|
||||
|
||||
export default class ThumbnailView extends YTNode {
|
||||
static type = 'ThumbnailView';
|
||||
|
||||
image: Thumbnail[];
|
||||
overlays: (ThumbnailOverlayBadgeView | ThumbnailHoverOverlayView)[];
|
||||
background_color?: {
|
||||
light_theme: number;
|
||||
dark_theme: number;
|
||||
};
|
||||
public image: Thumbnail[];
|
||||
public overlays: (ThumbnailOverlayBadgeView | ThumbnailHoverOverlayView)[];
|
||||
public background_color?: ThumbnailBackgroundColor;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.image = Thumbnail.fromResponse(data.image);
|
||||
this.overlays = Parser.parseArray(data.overlays, [ ThumbnailOverlayBadgeView, ThumbnailHoverOverlayView ]);
|
||||
if (data.backgroundColor) {
|
||||
|
||||
if ('backgroundColor' in data) {
|
||||
this.background_color = {
|
||||
light_theme: data.backgroundColor.lightTheme,
|
||||
dark_theme: data.backgroundColor.darkTheme
|
||||
|
||||
Reference in New Issue
Block a user