mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-16 11:02:10 +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
39 lines
965 B
TypeScript
39 lines
965 B
TypeScript
import Parser, { type RawNode } from '../index.js';
|
|
import { YTNode } from '../helpers.js';
|
|
|
|
export default class Card extends YTNode {
|
|
static type = 'Card';
|
|
|
|
teaser: YTNode;
|
|
content: YTNode;
|
|
card_id?: string;
|
|
feature?: string;
|
|
|
|
cue_ranges: {
|
|
start_card_active_ms: string;
|
|
end_card_active_ms: string;
|
|
teaser_duration_ms: string;
|
|
icon_after_teaser_ms: string;
|
|
}[];
|
|
|
|
constructor(data: RawNode) {
|
|
super();
|
|
this.teaser = Parser.parseItem(data.teaser);
|
|
this.content = Parser.parseItem(data.content);
|
|
|
|
if (Reflect.has(data, 'cardId')) {
|
|
this.card_id = data.cardId;
|
|
}
|
|
|
|
if (Reflect.has(data, 'feature')) {
|
|
this.feature = data.feature;
|
|
}
|
|
|
|
this.cue_ranges = data.cueRanges.map((cr: any) => ({
|
|
start_card_active_ms: cr.startCardActiveMs,
|
|
end_card_active_ms: cr.endCardActiveMs,
|
|
teaser_duration_ms: cr.teaserDurationMs,
|
|
icon_after_teaser_ms: cr.iconAfterTeaserMs
|
|
}));
|
|
}
|
|
} |