Skip to content

Commit

Permalink
fix(VideoInfo): Fix like count being undefined (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue authored Oct 28, 2024
1 parent dba0be7 commit 182bf42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/parser/classes/menus/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import type { ObservedArray } from '../../helpers.js';
import { YTNode } from '../../helpers.js';
import type { RawNode } from '../../index.js';
import Button from '../Button.js';
import ButtonView from '../ButtonView.js';
import SegmentedLikeDislikeButtonView from '../SegmentedLikeDislikeButtonView.js';

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

items: ObservedArray<YTNode>;
top_level_buttons: ObservedArray<Button>;
top_level_buttons: ObservedArray<Button | ButtonView | SegmentedLikeDislikeButtonView>;
label?: string;

constructor(data: RawNode) {
super();
this.items = Parser.parseArray(data.items);
this.top_level_buttons = Parser.parseArray(data.topLevelButtons, Button);
this.top_level_buttons = Parser.parseArray(data.topLevelButtons, [ Button, ButtonView, SegmentedLikeDislikeButtonView ]);

if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'accessibilityData')) {
this.label = data.accessibility.accessibilityData.label;
Expand Down
3 changes: 2 additions & 1 deletion src/parser/youtube/History.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Feed from '../../core/mixins/Feed.js';
import ItemSection from '../classes/ItemSection.js';
import BrowseFeedActions from '../classes/BrowseFeedActions.js';
import Button from '../classes/Button.js';

import type { Actions, ApiResponse } from '../../core/index.js';
import type { IBrowseResponse } from '../types/index.js';
Expand Down Expand Up @@ -37,7 +38,7 @@ export default class History extends Feed<IBrowseResponse> {
for (const content of section.contents) {
const video = content as Video;
if (video.id === video_id && video.menu) {
feedbackToken = video.menu.top_level_buttons[0].endpoint.payload.feedbackToken;
feedbackToken = video.menu.top_level_buttons[0].as(Button).endpoint.payload.feedbackToken;
break;
}
}
Expand Down

0 comments on commit 182bf42

Please sign in to comment.