Skip to content

Commit

Permalink
feat(GridVideo): add upcoming, upcoming_text, is_reminder_set a…
Browse files Browse the repository at this point in the history
…nd `buttons`

Closes: #380
  • Loading branch information
LuanRT committed Apr 13, 2023
1 parent a056696 commit 05de3ec
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/parser/classes/GridVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Menu from './menus/Menu.js';

import { YTNode } from '../helpers.js';

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

id: string;
Expand All @@ -23,10 +23,15 @@ class GridVideo extends YTNode {
short_view_count: Text;
endpoint: NavigationEndpoint;
menu: Menu | null;
buttons?;
upcoming?: Date;
upcoming_text?: Text;
is_reminder_set?: boolean;

constructor(data: RawNode) {
super();
const length_alt = data.thumbnailOverlays.find((overlay: any) => overlay.hasOwnProperty('thumbnailOverlayTimeStatusRenderer'))?.thumbnailOverlayTimeStatusRenderer;

this.id = data.videoId;
this.title = new Text(data.title);
this.thumbnails = Thumbnail.fromResponse(data.thumbnail);
Expand All @@ -39,7 +44,19 @@ class GridVideo extends YTNode {
this.short_view_count = new Text(data.shortViewCountText);
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
this.menu = Parser.parseItem(data.menu, Menu);

if (Reflect.has(data, 'buttons')) {
this.buttons = Parser.parseArray(data.buttons);
}

if (Reflect.has(data, 'upcomingEventData')) {
this.upcoming = new Date(Number(`${data.upcomingEventData.startTime}000`));
this.upcoming_text = new Text(data.upcomingEventData.upcomingEventText);
this.is_reminder_set = !!data.upcomingEventData?.isReminderSet;
}
}
}

export default GridVideo;
get is_upcoming(): boolean {
return Boolean(this.upcoming && this.upcoming > new Date());
}
}

0 comments on commit 05de3ec

Please sign in to comment.