Skip to content

Commit

Permalink
fix(YouTube): fix warnings when retrieving members-only content (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT authored Mar 7, 2023
1 parent a511608 commit 95f1d40
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
21 changes: 21 additions & 0 deletions src/parser/classes/PlayerLegacyDesktopYpcOffer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';

class PlayerLegacyDesktopYpcOffer extends YTNode {
static type = 'PlayerLegacyDesktopYpcOffer';

title: string;
thumbnail: string;
offer_description: string;
offer_id: string;

constructor(data: RawNode) {
super();
this.title = data.itemTitle;
this.thumbnail = data.itemThumbnail;
this.offer_description = data.offerDescription;
this.offer_id = data.offerId;
}
}

export default PlayerLegacyDesktopYpcOffer;
20 changes: 13 additions & 7 deletions src/parser/classes/VideoPrimaryInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import type { ObservedArray } from '../helpers.js';
import { YTNodes } from '../index.js';
import Parser from '../index.js';
import Text from './misc/Text.js';
import { YTNode } from '../helpers.js';
import Menu from './menus/Menu.js';

class VideoPrimaryInfo extends YTNode {
static type = 'VideoPrimaryInfo';
Expand All @@ -10,17 +12,21 @@ class VideoPrimaryInfo extends YTNode {
super_title_link: Text;
view_count: Text;
short_view_count: Text;
badges: ObservedArray<YTNodes.MetadataBadge>;
published: Text;
menu;
relative_date: Text;
menu: YTNodes.Menu | null;

constructor(data: any) {
constructor(data: RawNode) {
super();
this.title = new Text(data.title);
this.super_title_link = new Text(data.superTitleLink);
this.view_count = new Text(data.viewCount.videoViewCountRenderer.viewCount);
this.short_view_count = new Text(data.viewCount.videoViewCountRenderer.shortViewCount);
this.view_count = new Text(data.viewCount?.videoViewCountRenderer?.viewCount);
this.short_view_count = new Text(data.viewCount?.videoViewCountRenderer?.shortViewCount);
this.badges = Parser.parseArray(data.badges, YTNodes.MetadataBadge);
this.published = new Text(data.dateText);
this.menu = Parser.parseItem(data.videoActions, Menu);
this.relative_date = new Text(data.relativeDateText);
this.menu = Parser.parseItem(data.videoActions, YTNodes.Menu);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/parser/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ import { default as PlayerCaptionsTracklist } from './classes/PlayerCaptionsTrac
export { PlayerCaptionsTracklist };
import { default as PlayerErrorMessage } from './classes/PlayerErrorMessage.js';
export { PlayerErrorMessage };
import { default as PlayerLegacyDesktopYpcOffer } from './classes/PlayerLegacyDesktopYpcOffer.js';
export { PlayerLegacyDesktopYpcOffer };
import { default as PlayerLiveStoryboardSpec } from './classes/PlayerLiveStoryboardSpec.js';
export { PlayerLiveStoryboardSpec };
import { default as PlayerMicroformat } from './classes/PlayerMicroformat.js';
Expand Down Expand Up @@ -898,6 +900,7 @@ const map: Record<string, YTNodeConstructor> = {
PlayerAnnotationsExpanded,
PlayerCaptionsTracklist,
PlayerErrorMessage,
PlayerLegacyDesktopYpcOffer,
PlayerLiveStoryboardSpec,
PlayerMicroformat,
PlayerOverlay,
Expand Down

0 comments on commit 95f1d40

Please sign in to comment.