feat(toDash)!: Add support for generating manifests for Post Live DVR videos (#580)

BREAKING CHANGES: The `duration` property in `StreamingInfo` has been
replaced by the asynchronous `getDuration()` function, as getting the duration
of Post Live DVR videos requires making a fetch request.
This commit is contained in:
absidue
2024-01-18 18:51:42 +01:00
committed by GitHub
parent 2073aa910a
commit 6dd03e1658
5 changed files with 231 additions and 51 deletions

View File

@@ -1,11 +1,32 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
export interface LiveStoryboardData {
type: 'live',
template_url: string,
thumbnail_width: number,
thumbnail_height: number,
columns: number,
rows: number
}
export default class PlayerLiveStoryboardSpec extends YTNode {
static type = 'PlayerLiveStoryboardSpec';
constructor() {
board: LiveStoryboardData;
constructor(data: RawNode) {
super();
// TODO: A little bit different from PlayerLiveStoryboardSpec
// https://i.ytimg.com/sb/5qap5aO4i9A/storyboard_live_90_2x2_b2/M$M.jpg?rs=AOn4CLC9s6IeOsw_gKvEbsbU9y-e2FVRTw#159#90#2#2
const [ template_url, thumbnail_width, thumbnail_height, columns, rows ] = data.spec.split('#');
this.board = {
type: 'live',
template_url,
thumbnail_width: parseInt(thumbnail_width, 10),
thumbnail_height: parseInt(thumbnail_height, 10),
columns: parseInt(columns, 10),
rows: parseInt(rows, 10)
};
}
}

View File

@@ -2,6 +2,7 @@ import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
export interface StoryboardData {
type: 'vod'
template_url: string;
thumbnail_width: number;
thumbnail_height: number;
@@ -31,6 +32,7 @@ export default class PlayerStoryboardSpec extends YTNode {
const storyboard_count = Math.ceil(parseInt(thumbnail_count, 10) / (parseInt(columns, 10) * parseInt(rows, 10)));
return {
type: 'vod',
template_url: url.toString().replace('$L', i).replace('$N', name),
thumbnail_width: parseInt(thumbnail_width, 10),
thumbnail_height: parseInt(thumbnail_height, 10),