mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-16 19:12:24 +00:00
* tests: improve coverage * refactor: clean up nodes * chore: lint * feat(parser): ignore `BrandVideoShelf` Seems to be used for ads. * feat(parser): ignore `BrandVideoSingleton` too
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { YTNode, observe, type ObservedArray } from '../helpers.js';
|
|
import type { RawNode } from '../index.js';
|
|
import NavigationEndpoint from './NavigationEndpoint.js';
|
|
import Text from './misc/Text.js';
|
|
import Thumbnail from './misc/Thumbnail.js';
|
|
|
|
// XXX (LuanRT): This is not a real YTNode, but we treat it as one to keep things clean.
|
|
export class HeaderLink extends YTNode {
|
|
static type = 'HeaderLink';
|
|
|
|
endpoint: NavigationEndpoint;
|
|
icon: Thumbnail[];
|
|
title: Text;
|
|
|
|
constructor(data: RawNode) {
|
|
super();
|
|
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
|
this.icon = Thumbnail.fromResponse(data.icon);
|
|
this.title = new Text(data.title);
|
|
}
|
|
}
|
|
|
|
export default class ChannelHeaderLinks extends YTNode {
|
|
static type = 'ChannelHeaderLinks';
|
|
|
|
primary: ObservedArray<HeaderLink>;
|
|
secondary: ObservedArray<HeaderLink>;
|
|
|
|
constructor(data: RawNode) {
|
|
super();
|
|
this.primary = observe(data.primaryLinks?.map((link: RawNode) => new HeaderLink(link)) || []);
|
|
this.secondary = observe(data.secondaryLinks?.map((link: RawNode) => new HeaderLink(link)) || []);
|
|
}
|
|
} |