mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
* refactor: move common info into MediaInfo * refactor: better inference on Memo * refactor: improved typesafety in parser methods * refactor: remove PlaylistAuthor in favor of Author * refactor: cleanup live chat parsers - Replace non standard author type with Author class - Remove redundant code * fix: new errors due to changes * fix: pass actions to FormatUtils#toDash * refactor!: merge NavigatableText and Text into single class
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import Text from './misc/Text.js';
|
|
import Parser from '../index.js';
|
|
import Thumbnail from './misc/Thumbnail.js';
|
|
import Author from './misc/Author.js';
|
|
import NavigationEndpoint from './NavigationEndpoint.js';
|
|
import ThumbnailOverlayTimeStatus from './ThumbnailOverlayTimeStatus.js';
|
|
import Menu from './menus/Menu.js';
|
|
|
|
import { YTNode } from '../helpers.js';
|
|
|
|
class PlaylistVideo extends YTNode {
|
|
static type = 'PlaylistVideo';
|
|
|
|
id: string;
|
|
index: Text;
|
|
title: Text;
|
|
author: Author;
|
|
thumbnails: Thumbnail[];
|
|
thumbnail_overlays;
|
|
set_video_id: string | undefined;
|
|
endpoint: NavigationEndpoint;
|
|
is_playable: boolean;
|
|
menu: Menu | null;
|
|
upcoming;
|
|
|
|
duration: {
|
|
text: string;
|
|
seconds: number;
|
|
};
|
|
|
|
constructor(data: any) {
|
|
super();
|
|
this.id = data.videoId;
|
|
this.index = new Text(data.index);
|
|
this.title = new Text(data.title);
|
|
this.author = new Author(data.shortBylineText);
|
|
this.thumbnails = Thumbnail.fromResponse(data.thumbnail);
|
|
this.thumbnail_overlays = Parser.parseArray(data.thumbnailOverlays);
|
|
this.set_video_id = data?.setVideoId;
|
|
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
|
this.is_playable = data.isPlayable;
|
|
this.menu = Parser.parseItem(data.menu, Menu);
|
|
|
|
const upcoming = data.upcomingEventData && Number(`${data.upcomingEventData.startTime}000`);
|
|
if (upcoming) {
|
|
this.upcoming = new Date(upcoming);
|
|
}
|
|
|
|
this.duration = {
|
|
text: new Text(data.lengthText).toString(),
|
|
seconds: parseInt(data.lengthSeconds)
|
|
};
|
|
}
|
|
|
|
get is_live(): boolean {
|
|
return this.thumbnail_overlays.firstOfType(ThumbnailOverlayTimeStatus)?.style === 'LIVE';
|
|
}
|
|
|
|
get is_upcoming(): boolean {
|
|
return this.thumbnail_overlays.firstOfType(ThumbnailOverlayTimeStatus)?.style === 'UPCOMING';
|
|
}
|
|
}
|
|
|
|
export default PlaylistVideo; |