mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
feat: add PlaylistPanelVideoWrapper parser (#176)
* feat: add `PlaylistPanelVideoWrapper` parser * fix: `PlaylistPanelVideoWrapper` no counterpart
This commit is contained in:
@@ -4,6 +4,7 @@ import PlaylistPanelVideo from './PlaylistPanelVideo';
|
||||
|
||||
import { YTNode } from '../helpers';
|
||||
import AutomixPreviewVideo from './AutomixPreviewVideo';
|
||||
import PlaylistPanelVideoWrapper from './PlaylistPanelVideoWrapper';
|
||||
|
||||
class PlaylistPanel extends YTNode {
|
||||
static type = 'PlaylistPanel';
|
||||
@@ -22,7 +23,7 @@ class PlaylistPanel extends YTNode {
|
||||
super();
|
||||
this.title = data.title;
|
||||
this.title_text = new Text(data.titleText);
|
||||
this.contents = Parser.parseArray<PlaylistPanelVideo | AutomixPreviewVideo>(data.contents, [ PlaylistPanelVideo, AutomixPreviewVideo ]);
|
||||
this.contents = Parser.parseArray<PlaylistPanelVideoWrapper | PlaylistPanelVideo | AutomixPreviewVideo>(data.contents);
|
||||
this.playlist_id = data.playlistId;
|
||||
this.is_infinite = data.isInfinite;
|
||||
this.continuation = data.continuations?.[0]?.nextRadioContinuationData?.continuation || data.continuations?.[0]?.nextContinuationData?.continuation;
|
||||
|
||||
18
src/parser/classes/PlaylistPanelVideoWrapper.ts
Normal file
18
src/parser/classes/PlaylistPanelVideoWrapper.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import Parser from '..';
|
||||
import { YTNode } from '../helpers';
|
||||
import PlaylistPanelVideo from './PlaylistPanelVideo';
|
||||
|
||||
class PlaylistPanelVideoWrapper extends YTNode {
|
||||
static type = 'PlaylistPanelVideoWrapper';
|
||||
|
||||
primary: PlaylistPanelVideo | null;
|
||||
counterpart: Array<PlaylistPanelVideo | null>;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.primary = Parser.parseItem<PlaylistPanelVideo>(data.primaryRenderer);
|
||||
this.counterpart = data.counterpart?.map((item: any) => Parser.parseItem<PlaylistPanelVideo>(item.counterpartRenderer)) || [];
|
||||
}
|
||||
}
|
||||
|
||||
export default PlaylistPanelVideoWrapper;
|
||||
@@ -184,6 +184,7 @@ import { default as PlaylistInfoCardContent } from './classes/PlaylistInfoCardCo
|
||||
import { default as PlaylistMetadata } from './classes/PlaylistMetadata';
|
||||
import { default as PlaylistPanel } from './classes/PlaylistPanel';
|
||||
import { default as PlaylistPanelVideo } from './classes/PlaylistPanelVideo';
|
||||
import { default as PlaylistPanelVideoWrapper } from './classes/PlaylistPanelVideoWrapper';
|
||||
import { default as PlaylistSidebar } from './classes/PlaylistSidebar';
|
||||
import { default as PlaylistSidebarPrimaryInfo } from './classes/PlaylistSidebarPrimaryInfo';
|
||||
import { default as PlaylistSidebarSecondaryInfo } from './classes/PlaylistSidebarSecondaryInfo';
|
||||
@@ -450,6 +451,7 @@ const map: Record<string, YTNodeConstructor> = {
|
||||
PlaylistMetadata,
|
||||
PlaylistPanel,
|
||||
PlaylistPanelVideo,
|
||||
PlaylistPanelVideoWrapper,
|
||||
PlaylistSidebar,
|
||||
PlaylistSidebarPrimaryInfo,
|
||||
PlaylistSidebarSecondaryInfo,
|
||||
|
||||
Reference in New Issue
Block a user