mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-18 12:02:11 +00:00
* feat: add core comments section classes * chore: update type declarations * chore: fix linter warnings * style: fix linter * chore: update tests * chore(tests): fix typo * chore(tests): fix typo x2 * fix(tests): `getReplies()` method is only present in `CommentThread` and not `Comment` * chore(tests): fix comment id path * chore(tests): remove outdated code * chore(tests): fix results path * chore: enforce code style * chore: update type declarations * docs: add examples and documentation * chore(docs): fix paths * chore(docs): fix more paths * chore(docs): fix `Comments.js` path * chore(docs): fix typo * chore(docs): mention example file * chore(examples): fix imports * chore(examples): fix typo
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const Parser = require('..');
|
|
const Text = require('./Text');
|
|
const Thumbnail = require('./Thumbnail');
|
|
const NavigationEndpoint = require('./NavigationEndpoint');
|
|
const Author = require('./Author');
|
|
|
|
class GridVideo {
|
|
type = 'GridVideo';
|
|
|
|
constructor(data) {
|
|
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);
|
|
}
|
|
}
|
|
|
|
module.exports = GridVideo; |