diff --git a/README.md b/README.md index b30944ff5..6b8d9e37d 100644 --- a/README.md +++ b/README.md @@ -300,6 +300,9 @@ Retrieves video info, including playback data and even layout elements such as m - `#getLiveChat()` - Returns a LiveChat instance. +- `#getTrailerInfo()` + - Returns trailer info in a new `VideoInfo` instance, or `null` if none. Typically available for non-purchased movies or films. + - `#chooseFormat(options)` - Used to choose streaming data formats. @@ -324,6 +327,9 @@ Retrieves video info, including playback data and even layout elements such as m - `#autoplay_video_endpoint` - Returns the endpoint of the video for Autoplay. +- `#has_trailer` + - Checks if trailer is available. + - `#page` - Returns original InnerTube response (sanitized). diff --git a/src/parser/classes/GridMovie.ts b/src/parser/classes/GridMovie.ts new file mode 100644 index 000000000..f2b160a6a --- /dev/null +++ b/src/parser/classes/GridMovie.ts @@ -0,0 +1,34 @@ +import Parser from '../index.js'; +import Text from './misc/Text.js'; +import Thumbnail from './misc/Thumbnail.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; +import { YTNode } from '../helpers.js'; +import MetadataBadge from './MetadataBadge.js'; + +class GridMovie extends YTNode { + static type = 'GridMovie'; + + id: string; + title: Text; + thumbnails: Thumbnail[]; + duration: Text | null; + endpoint: NavigationEndpoint; + badges: MetadataBadge[]; + metadata: Text; + thumbnail_overlays; + + constructor(data: any) { + super(); + const length_alt = data.thumbnailOverlays.find((overlay: any) => overlay.hasOwnProperty('thumbnailOverlayTimeStatusRenderer'))?.thumbnailOverlayTimeStatusRenderer; + this.id = data.videoId; + this.title = new Text(data.title); + this.thumbnails = Thumbnail.fromResponse(data.thumbnail); + this.duration = data.lengthText ? new Text(data.lengthText) : length_alt?.text ? new Text(length_alt.text) : null; + this.endpoint = new NavigationEndpoint(data.navigationEndpoint); + this.badges = Parser.parseArray(data.badges, MetadataBadge); + this.metadata = new Text(data.metadata); + this.thumbnail_overlays = Parser.parseArray(data.thumbnailOverlays); + } +} + +export default GridMovie; \ No newline at end of file diff --git a/src/parser/classes/HorizontalMovieList.ts b/src/parser/classes/HorizontalMovieList.ts new file mode 100644 index 000000000..2548a337a --- /dev/null +++ b/src/parser/classes/HorizontalMovieList.ts @@ -0,0 +1,25 @@ +import Parser from '../index.js'; +import { YTNode } from '../helpers.js'; +import Button from './Button.js'; + +class HorizontalMovieList extends YTNode { + static type = 'HorizontalMovieList'; + + items; + previous_button: Button | null; + next_button: Button | null; + + constructor(data: any) { + super(); + this.items = Parser.parseArray(data.items); + this.previous_button = Parser.parseItem