From 5da8a66551c85fa45a01713383e6f621db053b46 Mon Sep 17 00:00:00 2001 From: Luan Date: Sat, 14 Dec 2024 12:32:29 -0300 Subject: [PATCH] feat(Parser): Add `HowThisWasMadeSectionView` node --- .../classes/HowThisWasMadeSectionView.ts | 18 ++++++++++++++++++ .../classes/StructuredDescriptionContent.ts | 15 +++++++++------ src/parser/nodes.ts | 1 + 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/parser/classes/HowThisWasMadeSectionView.ts diff --git a/src/parser/classes/HowThisWasMadeSectionView.ts b/src/parser/classes/HowThisWasMadeSectionView.ts new file mode 100644 index 00000000..1981e74b --- /dev/null +++ b/src/parser/classes/HowThisWasMadeSectionView.ts @@ -0,0 +1,18 @@ +import { type RawNode } from '../index.js'; +import { YTNode } from '../helpers.js'; +import Text from "./misc/Text.js"; + +export default class HowThisWasMadeSectionView extends YTNode { + static type = 'HowThisWasMadeSectionView'; + + public section_title: Text; + public body_text: Text; + public body_header: Text; + + constructor(data: RawNode) { + super(); + this.section_title = Text.fromAttributed(data.sectionText); + this.body_text = Text.fromAttributed(data.bodyText); + this.body_header = Text.fromAttributed(data.bodyHeader); + } +} \ No newline at end of file diff --git a/src/parser/classes/StructuredDescriptionContent.ts b/src/parser/classes/StructuredDescriptionContent.ts index f0e478e4..91be47a7 100644 --- a/src/parser/classes/StructuredDescriptionContent.ts +++ b/src/parser/classes/StructuredDescriptionContent.ts @@ -1,4 +1,4 @@ -import { YTNode, type ObservedArray } from '../helpers.js'; +import { type ObservedArray, YTNode } from '../helpers.js'; import { Parser, type RawNode } from '../index.js'; import ExpandableVideoDescriptionBody from './ExpandableVideoDescriptionBody.js'; import HorizontalCardList from './HorizontalCardList.js'; @@ -7,16 +7,18 @@ import VideoDescriptionInfocardsSection from './VideoDescriptionInfocardsSection import VideoDescriptionMusicSection from './VideoDescriptionMusicSection.js'; import VideoDescriptionTranscriptSection from './VideoDescriptionTranscriptSection.js'; import VideoDescriptionCourseSection from './VideoDescriptionCourseSection.js'; -import ReelShelf from './ReelShelf.js'; import VideoAttributesSectionView from './VideoAttributesSectionView.js'; +import HowThisWasMadeSectionView from "./HowThisWasMadeSectionView.js"; +import ReelShelf from './ReelShelf.js'; export default class StructuredDescriptionContent extends YTNode { static type = 'StructuredDescriptionContent'; - items: ObservedArray< + public items: ObservedArray< VideoDescriptionHeader | ExpandableVideoDescriptionBody | VideoDescriptionMusicSection | - VideoDescriptionInfocardsSection | VideoDescriptionTranscriptSection | VideoDescriptionTranscriptSection | - VideoDescriptionCourseSection | HorizontalCardList | ReelShelf | VideoAttributesSectionView + VideoDescriptionInfocardsSection | VideoDescriptionTranscriptSection | + VideoDescriptionCourseSection | HorizontalCardList | ReelShelf | VideoAttributesSectionView | + HowThisWasMadeSectionView >; constructor(data: RawNode) { @@ -24,7 +26,8 @@ export default class StructuredDescriptionContent extends YTNode { this.items = Parser.parseArray(data.items, [ VideoDescriptionHeader, ExpandableVideoDescriptionBody, VideoDescriptionMusicSection, VideoDescriptionInfocardsSection, VideoDescriptionCourseSection, VideoDescriptionTranscriptSection, - VideoDescriptionTranscriptSection, HorizontalCardList, ReelShelf, VideoAttributesSectionView + VideoDescriptionTranscriptSection, HorizontalCardList, ReelShelf, VideoAttributesSectionView, + HowThisWasMadeSectionView ]); } } \ No newline at end of file diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index db32fe1e..85cb66aa 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -201,6 +201,7 @@ export { default as HistorySuggestion } from './classes/HistorySuggestion.js'; export { default as HorizontalCardList } from './classes/HorizontalCardList.js'; export { default as HorizontalList } from './classes/HorizontalList.js'; export { default as HorizontalMovieList } from './classes/HorizontalMovieList.js'; +export { default as HowThisWasMadeSectionView } from './classes/HowThisWasMadeSectionView.js'; export { default as IconLink } from './classes/IconLink.js'; export { default as ImageBannerView } from './classes/ImageBannerView.js'; export { default as IncludingResultsFor } from './classes/IncludingResultsFor.js';