Files
YouTube.js/src/parser/classes/ChannelAboutFullMetadata.ts
LuanRT 257bd475a0 refactor: clean up parser and tests (#387)
* tests: improve coverage

* refactor: clean up nodes

* chore: lint

* feat(parser): ignore `BrandVideoShelf`

Seems to be used for ads.

* feat(parser): ignore `BrandVideoSingleton` too
2023-04-23 06:37:33 -03:00

69 lines
1.9 KiB
TypeScript

import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import Button from './Button.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';
import Thumbnail from './misc/Thumbnail.js';
export default class ChannelAboutFullMetadata extends YTNode {
static type = 'ChannelAboutFullMetadata';
id: string;
name: Text;
avatar: Thumbnail[];
canonical_channel_url: string;
primary_links: {
endpoint: NavigationEndpoint;
icon: Thumbnail[];
title: Text;
}[];
view_count: Text;
joined_date: Text;
description: Text;
email_reveal: NavigationEndpoint;
can_reveal_email: boolean;
country: Text;
buttons: ObservedArray<Button>;
constructor(data: RawNode) {
super();
this.id = data.channelId;
this.name = new Text(data.title);
this.avatar = Thumbnail.fromResponse(data.avatar);
this.canonical_channel_url = data.canonicalChannelUrl;
this.primary_links = data.primaryLinks?.map((link: any) => ({
endpoint: new NavigationEndpoint(link.navigationEndpoint),
icon: Thumbnail.fromResponse(link.icon),
title: new Text(link.title)
})) ?? [];
this.view_count = new Text(data.viewCountText);
this.joined_date = new Text(data.joinedDateText);
this.description = new Text(data.description);
this.email_reveal = new NavigationEndpoint(data.onBusinessEmailRevealClickCommand);
this.can_reveal_email = !data.signInForBusinessEmail;
this.country = new Text(data.country);
this.buttons = Parser.parseArray(data.actionButtons, Button);
}
/**
* @deprecated
* This will be removed in a future release.
* Please use {@link Channel.view_count} instead.
*/
get views() {
return this.view_count;
}
/**
* @deprecated
* This will be removed in a future release.
* Please use {@link Channel.joined_date} instead.
*/
get joined(): Text {
return this.joined_date;
}
}