mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
29 lines
1.3 KiB
JavaScript
29 lines
1.3 KiB
JavaScript
import Parser from '../index';
|
|
import Text from './misc/Text';
|
|
import Thumbnail from './misc/Thumbnail';
|
|
import NavigationEndpoint from './NavigationEndpoint';
|
|
import Author from './misc/Author';
|
|
import { YTNode } from '../helpers';
|
|
|
|
class GridVideo extends YTNode {
|
|
static type = 'GridVideo';
|
|
|
|
constructor(data) {
|
|
super();
|
|
const length_alt = data.thumbnailOverlays.find((overlay) => overlay.hasOwnProperty('thumbnailOverlayTimeStatusRenderer'))?.thumbnailOverlayTimeStatusRenderer;
|
|
this.id = data.videoId;
|
|
this.title = new Text(data.title);
|
|
this.thumbnails = Thumbnail.fromResponse(data.thumbnail);
|
|
this.thumbnail_overlays = Parser.parse(data.thumbnailOverlays);
|
|
this.rich_thumbnail = data.richThumbnail && Parser.parse(data.richThumbnail);
|
|
this.published = new Text(data.publishedTimeText);
|
|
this.duration = data.lengthText ? new Text(data.lengthText) : length_alt?.text ? new Text(length_alt.text) : '';
|
|
this.author = data.shortBylineText && new Author(data.shortBylineText, data.ownerBadges);
|
|
this.views = new Text(data.viewCountText);
|
|
this.short_view_count = new Text(data.shortViewCountText);
|
|
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
|
this.menu = Parser.parse(data.menu);
|
|
}
|
|
}
|
|
|
|
export default GridVideo; |