Skip to content

Commit 2e710dc

Browse files
authored
feat(Channel): Support getting about with PageHeader (#581)
1 parent fed3512 commit 2e710dc

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

src/parser/classes/DescriptionPreviewView.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { YTNode } from '../helpers.js';
2-
import type { RawNode } from '../index.js';
2+
import { Parser, type RawNode } from '../index.js';
3+
import EngagementPanelSectionList from './EngagementPanelSectionList.js';
34
import Text from './misc/Text.js';
45

56
export default class DescriptionPreviewView extends YTNode {
@@ -9,6 +10,16 @@ export default class DescriptionPreviewView extends YTNode {
910
max_lines: number;
1011
truncation_text: Text;
1112
always_show_truncation_text: boolean;
13+
more_endpoint?: {
14+
show_engagement_panel_endpoint: {
15+
engagement_panel: EngagementPanelSectionList | null,
16+
engagement_panel_popup_type: string;
17+
identifier: {
18+
surface: string,
19+
tag: string
20+
}
21+
}
22+
};
1223

1324
constructor(data: RawNode) {
1425
super();
@@ -17,5 +28,20 @@ export default class DescriptionPreviewView extends YTNode {
1728
this.max_lines = parseInt(data.maxLines);
1829
this.truncation_text = Text.fromAttributed(data.truncationText);
1930
this.always_show_truncation_text = !!data.alwaysShowTruncationText;
31+
32+
if (data.rendererContext.commandContext?.onTap?.innertubeCommand?.showEngagementPanelEndpoint) {
33+
const endpoint = data.rendererContext.commandContext?.onTap?.innertubeCommand?.showEngagementPanelEndpoint;
34+
35+
this.more_endpoint = {
36+
show_engagement_panel_endpoint: {
37+
engagement_panel: Parser.parseItem(endpoint.engagementPanel, EngagementPanelSectionList),
38+
engagement_panel_popup_type: endpoint.engagementPanelPresentationConfigs.engagementPanelPopupPresentationConfig.popupType,
39+
identifier: {
40+
surface: endpoint.identifier.surface,
41+
tag: endpoint.identifier.tag
42+
}
43+
}
44+
};
45+
}
2046
}
2147
}

src/parser/youtube/Channel.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,13 @@ export default class Channel extends TabbedFeed<IBrowseResponse> {
196196
if (this.hasTabWithURL('about')) {
197197
const tab = await this.getTabByURL('about');
198198
return tab.memo.getType(ChannelAboutFullMetadata)[0];
199-
} else if (this.header?.is(C4TabbedHeader) && this.header.tagline) {
199+
}
200+
201+
const tagline = this.header?.is(C4TabbedHeader) && this.header.tagline;
200202

201-
if (this.header.tagline.more_endpoint instanceof NavigationEndpoint) {
202-
const response = await this.header.tagline.more_endpoint.call(this.actions);
203+
if (tagline || this.header?.is(PageHeader) && this.header.content?.description) {
204+
if (tagline && tagline.more_endpoint instanceof NavigationEndpoint) {
205+
const response = await tagline.more_endpoint.call(this.actions);
203206

204207
const tab = new TabbedFeed<IBrowseResponse>(this.actions, response, false);
205208
return tab.memo.getType(ChannelAboutFullMetadata)[0];
@@ -271,7 +274,9 @@ export default class Channel extends TabbedFeed<IBrowseResponse> {
271274

272275
get has_about(): boolean {
273276
// Game topic channels still have an about tab, user channels have switched to the popup
274-
return this.hasTabWithURL('about') || !!(this.header?.is(C4TabbedHeader) && this.header.tagline?.more_endpoint);
277+
return this.hasTabWithURL('about') ||
278+
!!(this.header?.is(C4TabbedHeader) && this.header.tagline?.more_endpoint) ||
279+
!!(this.header?.is(PageHeader) && this.header.content?.description?.more_endpoint);
275280
}
276281

277282
get has_search(): boolean {

0 commit comments

Comments
 (0)