-
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): Support LockupView and it's child nodes (#609)
- Loading branch information
Showing
10 changed files
with
179 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import { Parser, type RawNode } from '../index.js'; | ||
import ThumbnailView from './ThumbnailView.js'; | ||
|
||
export default class CollectionThumbnailView extends YTNode { | ||
static type = 'CollectionThumbnailView'; | ||
|
||
primary_thumbnail: ThumbnailView | null; | ||
stack_color: { | ||
light_theme: number; | ||
dark_theme: number; | ||
}; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
|
||
this.primary_thumbnail = Parser.parseItem(data.primaryThumbnail, ThumbnailView); | ||
this.stack_color = { | ||
light_theme: data.stackColor.lightTheme, | ||
dark_theme: data.stackColor.darkTheme | ||
}; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import { Parser, type RawNode } from '../index.js'; | ||
import ContentMetadataView from './ContentMetadataView.js'; | ||
import Text from './misc/Text.js'; | ||
|
||
export default class LockupMetadataView extends YTNode { | ||
static type = 'LockupMetadataView'; | ||
|
||
title: Text; | ||
metadata: ContentMetadataView | null; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
|
||
this.title = Text.fromAttributed(data.title); | ||
this.metadata = Parser.parseItem(data.metadata, ContentMetadataView); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import { Parser, type RawNode } from '../index.js'; | ||
import CollectionThumbnailView from './CollectionThumbnailView.js'; | ||
import LockupMetadataView from './LockupMetadataView.js'; | ||
import NavigationEndpoint from './NavigationEndpoint.js'; | ||
|
||
export default class LockupView extends YTNode { | ||
static type = 'LockupView'; | ||
|
||
content_image: CollectionThumbnailView | null; | ||
metadata: LockupMetadataView | null; | ||
content_id: string; | ||
content_type: 'SOURCE' | 'PLAYLIST' | 'ALBUM' | 'PODCAST' | 'SHOPPING_COLLECTION' | 'SHORT' | 'GAME' | 'PRODUCT'; | ||
on_tap_endpoint: NavigationEndpoint; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
|
||
this.content_image = Parser.parseItem(data.contentImage, CollectionThumbnailView); | ||
this.metadata = Parser.parseItem(data.metadata, LockupMetadataView); | ||
this.content_id = data.contentId; | ||
this.content_type = data.contentType.replace('LOCKUP_CONTENT_TYPE_', ''); | ||
this.on_tap_endpoint = new NavigationEndpoint(data.rendererContext.commandContext.onTap); | ||
console.log(data); | ||
console.log(this); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import type { RawNode } from '../index.js'; | ||
|
||
export default class ThumbnailBadgeView extends YTNode { | ||
static type = 'ThumbnailBadgeView'; | ||
|
||
icon_name: string; | ||
text: string; | ||
badge_style: string; | ||
background_color: { | ||
light_theme: number; | ||
dark_theme: number; | ||
}; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
|
||
this.icon_name = data.icon.sources[0].clientResource.imageName; | ||
this.text = data.text; | ||
this.badge_style = data.badgeStyle; | ||
this.background_color = { | ||
light_theme: data.backgroundColor.lightTheme, | ||
dark_theme: data.backgroundColor.darkTheme | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import type { RawNode } from '../index.js'; | ||
import Text from './misc/Text.js'; | ||
|
||
export default class ThumbnailHoverOverlayView extends YTNode { | ||
static type = 'ThumbnailHoverOverlayView'; | ||
|
||
icon_name: string; | ||
text: Text; | ||
style: string; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
|
||
this.icon_name = data.icon.sources[0].clientResource.imageName; | ||
this.text = Text.fromAttributed(data.text); | ||
this.style = data.style; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import { Parser, type RawNode } from '../index.js'; | ||
import ThumbnailBadgeView from './ThumbnailBadgeView.js'; | ||
|
||
export default class ThumbnailOverlayBadgeView extends YTNode { | ||
static type = 'ThumbnailOverlayBadgeView'; | ||
|
||
badges: ThumbnailBadgeView[]; | ||
position: string; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
|
||
this.badges = Parser.parseArray(data.thumbnailBadges, ThumbnailBadgeView); | ||
this.position = data.position; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import { Parser, type RawNode } from '../index.js'; | ||
import ThumbnailHoverOverlayView from './ThumbnailHoverOverlayView.js'; | ||
import ThumbnailOverlayBadgeView from './ThumbnailOverlayBadgeView.js'; | ||
import Thumbnail from './misc/Thumbnail.js'; | ||
|
||
export default class ThumbnailView extends YTNode { | ||
static type = 'ThumbnailView'; | ||
|
||
image: Thumbnail[]; | ||
overlays: (ThumbnailOverlayBadgeView | ThumbnailHoverOverlayView)[]; | ||
background_color: { | ||
light_theme: number; | ||
dark_theme: number; | ||
}; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
|
||
this.image = Thumbnail.fromResponse(data.image); | ||
this.overlays = Parser.parseArray(data.overlays, [ ThumbnailOverlayBadgeView, ThumbnailHoverOverlayView ]); | ||
this.background_color = { | ||
light_theme: data.backgroundColor.lightTheme, | ||
dark_theme: data.backgroundColor.darkTheme | ||
}; | ||
} | ||
} |
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