mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-03 17:38:23 +00:00
feat(VideoInfo): support get by endpoint + more info (#342)
* feat(VideoInfo): get by endpoint + more info * chore: fix param description for `getInfo()`
This commit is contained in:
@@ -20,6 +20,7 @@ import TwoColumnWatchNextResults from '../classes/TwoColumnWatchNextResults.js';
|
||||
import VideoPrimaryInfo from '../classes/VideoPrimaryInfo.js';
|
||||
import VideoSecondaryInfo from '../classes/VideoSecondaryInfo.js';
|
||||
import LiveChatWrap from './LiveChat.js';
|
||||
import NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
|
||||
import type CardCollection from '../classes/CardCollection.js';
|
||||
import type Endscreen from '../classes/Endscreen.js';
|
||||
@@ -60,6 +61,7 @@ class VideoInfo {
|
||||
|
||||
primary_info?: VideoPrimaryInfo | null;
|
||||
secondary_info?: VideoSecondaryInfo | null;
|
||||
playlist?;
|
||||
game_info?;
|
||||
merchandise?: MerchandiseShelf | null;
|
||||
related_chip_cloud?: ChipCloud | null;
|
||||
@@ -67,6 +69,7 @@ class VideoInfo {
|
||||
player_overlays?: PlayerOverlay | null;
|
||||
comments_entry_point_header?: CommentsEntryPointHeader | null;
|
||||
livechat?: LiveChat | null;
|
||||
autoplay?;
|
||||
|
||||
/**
|
||||
* @param data - API response.
|
||||
@@ -141,6 +144,10 @@ class VideoInfo {
|
||||
this.merchandise = results.firstOfType(MerchandiseShelf);
|
||||
this.related_chip_cloud = secondary_results.firstOfType(RelatedChipCloud)?.content.item().as(ChipCloud);
|
||||
|
||||
if (two_col?.playlist) {
|
||||
this.playlist = two_col.playlist;
|
||||
}
|
||||
|
||||
this.watch_next_feed = secondary_results.firstOfType(ItemSection)?.contents || secondary_results;
|
||||
|
||||
if (this.watch_next_feed && Array.isArray(this.watch_next_feed) && this.watch_next_feed.at(-1)?.is(ContinuationItem))
|
||||
@@ -148,6 +155,10 @@ class VideoInfo {
|
||||
|
||||
this.player_overlays = next?.player_overlays?.item().as(PlayerOverlay);
|
||||
|
||||
if (two_col?.autoplay) {
|
||||
this.autoplay = two_col.autoplay;
|
||||
}
|
||||
|
||||
const segmented_like_dislike_button = this.primary_info?.menu?.top_level_buttons.firstOfType(SegmentedLikeDislikeButton);
|
||||
|
||||
if (segmented_like_dislike_button?.like_button?.is(ToggleButton) && segmented_like_dislike_button?.dislike_button?.is(ToggleButton)) {
|
||||
@@ -377,6 +388,13 @@ class VideoInfo {
|
||||
return !!this.#watch_next_continuation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the endpoint of the autoplay video
|
||||
*/
|
||||
get autoplay_video_endpoint(): NavigationEndpoint | null {
|
||||
return this.autoplay?.sets?.[0]?.autoplay_video || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get songs used in the video.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user