From 6a4b4f335924b96550403ad0d0b12eabeb29d760 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Tue, 27 Dec 2022 04:17:05 -0300 Subject: [PATCH] feat: add support for chapters & video heatmap (#263) * feat: add support for chapters & video heatmap * chore: add tests --- src/parser/classes/Chapter.ts | 21 ++++++++++ src/parser/classes/DecoratedPlayerBar.ts | 19 +++++++++ src/parser/classes/HeatMarker.ts | 18 +++++++++ src/parser/classes/Heatmap.ts | 25 ++++++++++++ src/parser/classes/MultiMarkersPlayerBar.ts | 44 +++++++++++++++++++++ src/parser/classes/PlayerOverlay.ts | 3 ++ src/parser/classes/TimedMarkerDecoration.ts | 23 +++++++++++ src/parser/map.ts | 12 ++++++ test/main.test.ts | 22 +++++++++-- 9 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 src/parser/classes/Chapter.ts create mode 100644 src/parser/classes/DecoratedPlayerBar.ts create mode 100644 src/parser/classes/HeatMarker.ts create mode 100644 src/parser/classes/Heatmap.ts create mode 100644 src/parser/classes/MultiMarkersPlayerBar.ts create mode 100644 src/parser/classes/TimedMarkerDecoration.ts diff --git a/src/parser/classes/Chapter.ts b/src/parser/classes/Chapter.ts new file mode 100644 index 000000000..463e9b188 --- /dev/null +++ b/src/parser/classes/Chapter.ts @@ -0,0 +1,21 @@ +import Text from './misc/Text'; +import Thumbnail from './misc/Thumbnail'; + +import { YTNode } from '../helpers'; + +class Chapter extends YTNode { + static type = 'Chapter'; + + title: Text; + time_range_start_millis: number; + thumbnail: Thumbnail[]; + + constructor(data: any) { + super(); + this.title = new Text(data.title); + this.time_range_start_millis = data.timeRangeStartMillis; + this.thumbnail = Thumbnail.fromResponse(data.thumbnail); + } +} + +export default Chapter; \ No newline at end of file diff --git a/src/parser/classes/DecoratedPlayerBar.ts b/src/parser/classes/DecoratedPlayerBar.ts new file mode 100644 index 000000000..d972c1261 --- /dev/null +++ b/src/parser/classes/DecoratedPlayerBar.ts @@ -0,0 +1,19 @@ +import Parser from '..'; +import { YTNode } from '../helpers'; +import type Button from './Button'; +import type MultiMarkersPlayerBar from './MultiMarkersPlayerBar'; + +class DecoratedPlayerBar extends YTNode { + static type = 'DecoratedPlayerBar'; + + player_bar: MultiMarkersPlayerBar | null; + player_bar_action_button: Button | null; + + constructor(data: any) { + super(); + this.player_bar = Parser.parseItem(data.playerBar); + this.player_bar_action_button = Parser.parseItem