mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 12:31:17 +00:00
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { YTNode } from '../helpers.ts';
|
|
import type { RawNode } from '../index.ts';
|
|
|
|
export default class PlayerStoryboardSpec extends YTNode {
|
|
static type = 'PlayerStoryboardSpec';
|
|
|
|
boards: {
|
|
template_url: string;
|
|
thumbnail_width: number;
|
|
thumbnail_height: number;
|
|
thumbnail_count: number;
|
|
interval: number;
|
|
columns: number;
|
|
rows: number;
|
|
storyboard_count: number;
|
|
}[];
|
|
|
|
constructor(data: RawNode) {
|
|
super();
|
|
|
|
const parts = data.spec.split('|');
|
|
const url = new URL(parts.shift());
|
|
|
|
this.boards = parts.map((part: any, i: any) => {
|
|
const [ thumbnail_width, thumbnail_height, thumbnail_count, columns, rows, interval, name, sigh ] = part.split('#');
|
|
|
|
url.searchParams.set('sigh', sigh);
|
|
|
|
const storyboard_count = Math.ceil(parseInt(thumbnail_count, 10) / (parseInt(columns, 10) * parseInt(rows, 10)));
|
|
|
|
return {
|
|
template_url: url.toString().replace('$L', i).replace('$N', name),
|
|
thumbnail_width: parseInt(thumbnail_width, 10),
|
|
thumbnail_height: parseInt(thumbnail_height, 10),
|
|
thumbnail_count: parseInt(thumbnail_count, 10),
|
|
interval: parseInt(interval, 10),
|
|
columns: parseInt(columns, 10),
|
|
rows: parseInt(rows, 10),
|
|
storyboard_count
|
|
};
|
|
});
|
|
}
|
|
} |