mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-24 07:11:48 +00:00
* refactor: merge NavigatableText into Text * fix(Text): data might not be object * refactor: remove GetParserByName from map * feat(Parser): just-in-time YTNode generation * refactor: cleanup YTNodeGenerator * fix: YTNode map imports * feat(YTNodeGenerator): primative types Add support for inferring primatives types * fix(YTNodeGenerator): NavigationEndpoint detection * fix(YTNodeGenerator): fix generated typescript Correct types and linting for generated typescript class * chore: update parsers after merge * feat: add support for object type inference * fix: object type def * docs: basic YTNodeGenerator explanation * docs: tsdoc for YTNodeGenerator * docs: update parser updating guide * fix: apply suggested changes * docs: accessing generated nodes
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import Parser from '../index.js';
|
|
import Author from './misc/Author.js';
|
|
import Thumbnail from './misc/Thumbnail.js';
|
|
import NavigationEndpoint from './NavigationEndpoint.js';
|
|
import { timeToSeconds } from '../../utils/Utils.js';
|
|
import Text from './misc/Text.js';
|
|
import { YTNode } from '../helpers.js';
|
|
|
|
class Movie extends YTNode {
|
|
static type = 'Movie';
|
|
|
|
id: string;
|
|
title: Text;
|
|
description_snippet: Text | null;
|
|
top_metadata_items: Text;
|
|
thumbnails: Thumbnail[];
|
|
thumbnail_overlays;
|
|
author: Author;
|
|
|
|
duration: {
|
|
text: string;
|
|
seconds: number;
|
|
};
|
|
|
|
endpoint: NavigationEndpoint;
|
|
badges;
|
|
use_vertical_poster: boolean;
|
|
show_action_menu: boolean;
|
|
menu;
|
|
|
|
constructor(data: any) {
|
|
super();
|
|
const overlay_time_status = data.thumbnailOverlays
|
|
.find((overlay: any) => overlay.thumbnailOverlayTimeStatusRenderer)
|
|
?.thumbnailOverlayTimeStatusRenderer.text || 'N/A';
|
|
|
|
this.id = data.videoId;
|
|
this.title = new Text(data.title);
|
|
this.description_snippet = data.descriptionSnippet ? new Text(data.descriptionSnippet) : null;
|
|
this.top_metadata_items = new Text(data.topMetadataItems);
|
|
this.thumbnails = Thumbnail.fromResponse(data.thumbnail);
|
|
this.thumbnail_overlays = Parser.parse(data.thumbnailOverlays);
|
|
this.author = new Author(data.longBylineText, data.ownerBadges, data.channelThumbnailSupportedRenderers?.channelThumbnailWithLinkRenderer?.thumbnail);
|
|
|
|
this.duration = {
|
|
text: data.lengthText ? new Text(data.lengthText).toString() : new Text(overlay_time_status).toString(),
|
|
seconds: timeToSeconds(data.lengthText ? new Text(data.lengthText).toString() : new Text(overlay_time_status).toString())
|
|
};
|
|
|
|
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
|
this.badges = Parser.parse(data.badges);
|
|
this.use_vertical_poster = data.useVerticalPoster;
|
|
this.show_action_menu = data.showActionMenu;
|
|
this.menu = Parser.parse(data.menu);
|
|
}
|
|
}
|
|
|
|
export default Movie; |