-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for chapters & video heatmap (#263)
* feat: add support for chapters & video heatmap * chore: add tests
- Loading branch information
Showing
9 changed files
with
183 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MultiMarkersPlayerBar>(data.playerBar); | ||
this.player_bar_action_button = Parser.parseItem<Button>(data.playerBarActionButton); | ||
} | ||
} | ||
|
||
export default DecoratedPlayerBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { YTNode } from '../helpers'; | ||
|
||
class HeatMarker extends YTNode { | ||
static type = 'HeatMarker'; | ||
|
||
time_range_start_millis: number; | ||
marker_duration_millis: number; | ||
heat_marker_intensity_score_normalized: number; | ||
|
||
constructor(data: any) { | ||
super(); | ||
this.time_range_start_millis = data.timeRangeStartMillis; | ||
this.marker_duration_millis = data.markerDurationMillis; | ||
this.heat_marker_intensity_score_normalized = data.heatMarkerIntensityScoreNormalized; | ||
} | ||
} | ||
|
||
export default HeatMarker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Parser from '..'; | ||
import type HeatMarker from './HeatMarker'; | ||
|
||
import { YTNode } from '../helpers'; | ||
|
||
class Heatmap extends YTNode { | ||
static type = 'Heatmap'; | ||
|
||
max_height_dp: number; | ||
min_height_dp: number; | ||
show_hide_animation_duration_millis: number; | ||
heat_markers: HeatMarker[]; | ||
heat_markers_decorations: any; | ||
|
||
constructor(data: any) { | ||
super(); | ||
this.max_height_dp = data.maxHeightDp; | ||
this.min_height_dp = data.minHeightDp; | ||
this.show_hide_animation_duration_millis = data.showHideAnimationDurationMillis; | ||
this.heat_markers = Parser.parseArray<HeatMarker>(data.heatMarkers); | ||
this.heat_markers_decorations = Parser.parseArray(data.heatMarkersDecorations); | ||
} | ||
} | ||
|
||
export default Heatmap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Parser from '..'; | ||
import type Chapter from './Chapter'; | ||
import type Heatmap from './Heatmap'; | ||
|
||
import { observe, ObservedArray, YTNode } from '../helpers'; | ||
|
||
class Marker extends YTNode { | ||
static type = 'Marker'; | ||
|
||
marker_key: string; | ||
value: { | ||
heatmap?: Heatmap | null; | ||
chapters?: Chapter[]; | ||
}; | ||
|
||
constructor (data: any) { | ||
super(); | ||
this.marker_key = data.key; | ||
|
||
this.value = {}; | ||
|
||
if (data.value.heatmap) { | ||
this.value.heatmap = Parser.parseItem<Heatmap>(data.value.heatmap); | ||
} | ||
|
||
if (data.value.chapters) { | ||
this.value.chapters = Parser.parseArray<Chapter>(data.value.chapters); | ||
} | ||
} | ||
} | ||
|
||
class MultiMarkersPlayerBar extends YTNode { | ||
static type = 'MultiMarkersPlayerBar'; | ||
|
||
markers_map: ObservedArray<Marker>; | ||
|
||
constructor(data: any) { | ||
super(); | ||
this.markers_map = observe(data.markersMap?.map((marker: { key: string; value: { [key: string ]: any }}) => new Marker(marker))); | ||
} | ||
} | ||
|
||
export { Marker }; | ||
export default MultiMarkersPlayerBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Text from './misc/Text'; | ||
import { YTNode } from '../helpers'; | ||
|
||
class TimedMarkerDecoration extends YTNode { | ||
static type = 'TimedMarkerDecoration'; | ||
|
||
visible_time_range_start_millis: number; | ||
visible_time_range_end_millis: number; | ||
decoration_time_millis: number; | ||
label: Text; | ||
icon: string; | ||
|
||
constructor(data: any) { | ||
super(); | ||
this.visible_time_range_start_millis = data.visibleTimeRangeStartMillis; | ||
this.visible_time_range_end_millis = data.visibleTimeRangeEndMillis; | ||
this.decoration_time_millis = data.decorationTimeMillis; | ||
this.label = new Text(data.label); | ||
this.icon = data.icon; | ||
} | ||
} | ||
|
||
export default TimedMarkerDecoration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters