Skip to content

Commit 95f1d40

Browse files
authored
fix(YouTube): fix warnings when retrieving members-only content (#341)
1 parent a511608 commit 95f1d40

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { YTNode } from '../helpers.js';
2+
import type { RawNode } from '../index.js';
3+
4+
class PlayerLegacyDesktopYpcOffer extends YTNode {
5+
static type = 'PlayerLegacyDesktopYpcOffer';
6+
7+
title: string;
8+
thumbnail: string;
9+
offer_description: string;
10+
offer_id: string;
11+
12+
constructor(data: RawNode) {
13+
super();
14+
this.title = data.itemTitle;
15+
this.thumbnail = data.itemThumbnail;
16+
this.offer_description = data.offerDescription;
17+
this.offer_id = data.offerId;
18+
}
19+
}
20+
21+
export default PlayerLegacyDesktopYpcOffer;

src/parser/classes/VideoPrimaryInfo.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { YTNode } from '../helpers.js';
2+
import type { RawNode } from '../index.js';
3+
import type { ObservedArray } from '../helpers.js';
4+
import { YTNodes } from '../index.js';
15
import Parser from '../index.js';
26
import Text from './misc/Text.js';
3-
import { YTNode } from '../helpers.js';
4-
import Menu from './menus/Menu.js';
57

68
class VideoPrimaryInfo extends YTNode {
79
static type = 'VideoPrimaryInfo';
@@ -10,17 +12,21 @@ class VideoPrimaryInfo extends YTNode {
1012
super_title_link: Text;
1113
view_count: Text;
1214
short_view_count: Text;
15+
badges: ObservedArray<YTNodes.MetadataBadge>;
1316
published: Text;
14-
menu;
17+
relative_date: Text;
18+
menu: YTNodes.Menu | null;
1519

16-
constructor(data: any) {
20+
constructor(data: RawNode) {
1721
super();
1822
this.title = new Text(data.title);
1923
this.super_title_link = new Text(data.superTitleLink);
20-
this.view_count = new Text(data.viewCount.videoViewCountRenderer.viewCount);
21-
this.short_view_count = new Text(data.viewCount.videoViewCountRenderer.shortViewCount);
24+
this.view_count = new Text(data.viewCount?.videoViewCountRenderer?.viewCount);
25+
this.short_view_count = new Text(data.viewCount?.videoViewCountRenderer?.shortViewCount);
26+
this.badges = Parser.parseArray(data.badges, YTNodes.MetadataBadge);
2227
this.published = new Text(data.dateText);
23-
this.menu = Parser.parseItem(data.videoActions, Menu);
28+
this.relative_date = new Text(data.relativeDateText);
29+
this.menu = Parser.parseItem(data.videoActions, YTNodes.Menu);
2430
}
2531
}
2632

src/parser/map.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ import { default as PlayerCaptionsTracklist } from './classes/PlayerCaptionsTrac
448448
export { PlayerCaptionsTracklist };
449449
import { default as PlayerErrorMessage } from './classes/PlayerErrorMessage.js';
450450
export { PlayerErrorMessage };
451+
import { default as PlayerLegacyDesktopYpcOffer } from './classes/PlayerLegacyDesktopYpcOffer.js';
452+
export { PlayerLegacyDesktopYpcOffer };
451453
import { default as PlayerLiveStoryboardSpec } from './classes/PlayerLiveStoryboardSpec.js';
452454
export { PlayerLiveStoryboardSpec };
453455
import { default as PlayerMicroformat } from './classes/PlayerMicroformat.js';
@@ -898,6 +900,7 @@ const map: Record<string, YTNodeConstructor> = {
898900
PlayerAnnotationsExpanded,
899901
PlayerCaptionsTracklist,
900902
PlayerErrorMessage,
903+
PlayerLegacyDesktopYpcOffer,
901904
PlayerLiveStoryboardSpec,
902905
PlayerMicroformat,
903906
PlayerOverlay,

0 commit comments

Comments
 (0)