Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parser): Add AnimatedThumbnailOverlayView #903

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ deno/
# VSCode files
.vscode/

# Webstorm files
.idea/

# MacOS
.DS_Store

Expand Down
25 changes: 25 additions & 0 deletions src/parser/classes/AnimatedThumbnailOverlayView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../types/index.js';

export default class AnimatedThumbnailOverlayView extends YTNode {
static type = 'AnimatedThumbnailOverlayView';

thumbnail: {
sources: {
url: string,
width: number,
height: number
}[]
};

constructor(data: RawNode) {
super();
this.thumbnail = {
sources: data.thumbnail.sources.map((item: any) => ({
url: item.url,
width: item.width,
height: item.height
}))
};
}
}
5 changes: 4 additions & 1 deletion src/parser/classes/ThumbnailView.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ObservedArray } from '../helpers.js';
import { YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import AnimatedThumbnailOverlayView from './AnimatedThumbnailOverlayView.js';
import ThumbnailHoverOverlayView from './ThumbnailHoverOverlayView.js';
import ThumbnailOverlayBadgeView from './ThumbnailOverlayBadgeView.js';
import Thumbnail from './misc/Thumbnail.js';
Expand All @@ -19,6 +20,7 @@ export default class ThumbnailView extends YTNode {
public overlays: ObservedArray<
ThumbnailHoverOverlayToggleActionsView | ThumbnailBottomOverlayView |
ThumbnailOverlayBadgeView | ThumbnailHoverOverlayView
| AnimatedThumbnailOverlayView
>;
public background_color?: ThumbnailBackgroundColor;

Expand All @@ -28,7 +30,8 @@ export default class ThumbnailView extends YTNode {
this.image = Thumbnail.fromResponse(data.image);
this.overlays = Parser.parseArray(data.overlays, [
ThumbnailHoverOverlayToggleActionsView, ThumbnailBottomOverlayView,
ThumbnailOverlayBadgeView, ThumbnailHoverOverlayView
ThumbnailOverlayBadgeView, ThumbnailHoverOverlayView,
AnimatedThumbnailOverlayView
]);

if ('backgroundColor' in data) {
Expand Down
1 change: 1 addition & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export { default as ActiveAccountHeader } from './classes/ActiveAccountHeader.js
export { default as AddToPlaylist } from './classes/AddToPlaylist.js';
export { default as Alert } from './classes/Alert.js';
export { default as AlertWithButton } from './classes/AlertWithButton.js';
export { default as AnimatedThumbnailOverlayView } from './classes/AnimatedThumbnailOverlayView.js';
export { default as AttributionView } from './classes/AttributionView.js';
export { default as AudioOnlyPlayability } from './classes/AudioOnlyPlayability.js';
export { default as AutomixPreviewVideo } from './classes/AutomixPreviewVideo.js';
Expand Down
Loading