Files
YouTube.js/typings/lib/Innertube.d.ts
Daniel Wykerd 4a102878d8 refactor!: feature complete contents parser
* feat: allow setting search params to custom value

This is useful for getting results other than videos, like playlists and
channels.

* feat: add initial parsers for common renderers

* feat: artist search renderers

Added common renderers used when searching artists

* refactor: snake_case

* feat: channel home page renderers

* feat: parsers for more channel tabs

These are needed for channel tabs: Videos, Playlists, Community,
Channels

Additionally, do not merely return text as string, since they may
include links which may be navigated to

* feat: channel full metadata

* feat: renderers for playlists

* refactor!: Actions.browse

Channels should be viewable when not logged in, also added 'navigation'
type for use in NagivationEndpoint in the future.

* feat: home feed parsers

* feat: watch page renderers

* feat: start implementing HomeFeed API

The HomeFeed class remains compatible with the existing API

* feat: generate types using tsc and jsdoc

* feat: browse continuations from navigationEndpoint

* fix: Actions moved to session

This follows commit 1bfe2676d8

* fix: add more typescript config

* chore: use correct spaces and quotes

* feat: Trending API

* feat: reimplement existing channel API

* feat: add base video feed class

* feat: get channel videos

* feat: channel playlists

* feat: get channel community posts

* feat: get channels from channel

* feat: get channel about page data

* feat: add missing channel parsers

this commit also adds regenerated types I've neglected to push

* feat: initial playlist reimplementation

* feat: complete playlist reimplementation

* refactor: change InnertubeError to ES6 class

* fix: some unresolved types

* chore: update types

* feat: wip video details

* feat: get music tracks in video

Possibly an implementation for issue #48

* refactor:  merge parsers (wip)

This is a work in progress.

* fix: add pnpm to ignore

* fix: merge issues

* fix: merge Video and VideoInfo

VideoInfo should be working again.
Also remove the old parsers.

* feat: set matching in Simplify

Still looking into removing Simplify

* fix: ContinuationItem

This `call` method allows for traversal of continuations with the Simplify API
but may be removed in the future

* fix: optionally returned data

* revert: replace ContinuationItem with main

* feat(parser): contents memoization by classname

* feat(channel): working without Simplify

* feat(feed): working continuations

* fix: liniting issues

* feat(feed): filterable feed for home

* feat(feed): tabbed feed for trending & channel

* refactor: remove Simplify completely

* chore: lint

* refactor: alias `items` with `contents`

* refactor: `Search` to extend `Feed`

* fix: Search working

Also added MenuServiceItemDownload

* refactor: move `Channel` and `Playlist`

* fix: pass all tests

* fix: linting errors
2022-06-15 18:31:34 -03:00

305 lines
9.9 KiB
TypeScript

export = Innertube;
declare class Innertube {
/**
* @example
* ```js
* const Innertube = require('youtubei.js');
* const youtube = await new Innertube();
* ```
* @param {object} [config]
* @param {string} [config.gl]
* @param {string} [config.cookie]
* @param {boolean} [config.debug]
* @param {object} [config.proxy]
* @param {object} [config.http_ent]
* @param {object} [config.https_agent]
*/
constructor(config?: {
gl?: string;
cookie?: string;
debug?: boolean;
proxy?: object;
http_ent?: object;
https_agent?: object;
});
config: {
gl?: string;
cookie?: string;
debug?: boolean;
proxy?: object;
http_ent?: object;
https_agent?: object;
};
key: any;
version: any;
context: any;
logged_in: boolean;
player_url: any;
sts: any;
/**
* @fires Innertube#auth - fired when signing in to an account.
* @fires Innertube#update-credentials - fired when the access token is no longer valid.
* @type {EventEmitter}
*/
ev: EventEmitter;
oauth: OAuth;
auth_apisid: any;
request: Request;
actions: Actions;
account: AccountManager;
playlist: PlaylistManager;
interact: InteractionManager;
music: YTMusic;
/**
* Signs in to a google account.
*
* @param {object} auth_info
* @param {string} auth_info.access_token - Token used to sign in.
* @param {string} auth_info.refresh_token - Token used to get a new access token.
* @param {Date} auth_info.expires - Access token's expiration date, which is usually 24hrs-ish.
* @returns {Promise.<void>}
*/
signIn(auth_info?: {
access_token: string;
refresh_token: string;
expires: Date;
}): Promise<void>;
access_token: string;
refresh_token: string;
/**
* Signs out of an account.
*
* @returns {Promise.<{ success: boolean, status_code: number }>}
*/
signOut(): Promise<{
success: boolean;
status_code: number;
}>;
/**
* Retrieves search suggestions for a given query.
*
* @param {string} query - the search query.
* @param {object} [options] - search options.
* @param {string} [options.client='YOUTUBE'] - client used to retrieve search suggestions, can be: `YOUTUBE` or `YTMUSIC`.
* @returns {Promise.<{ query: string, results: string[] }>}
*/
getSearchSuggestions(query: string, options?: {
client?: string;
}): Promise<{
query: string;
results: string[];
}>;
/**
* Retrieves video info.
*
* @param {string} video_id
* @returns {Promise.<VideoInfo>}
*/
getInfo(video_id: string): Promise<VideoInfo>;
/**
* Searches a given query.
*
* @param {string} query - search query.
* @param {object} [filters] - search filters.
* @param {string} [filters.upload_date] - filter videos by upload date, can be: any | last_hour | today | this_week | this_month | this_year
* @param {string} [filters.type] - filter results by type, can be: any | video | channel | playlist | movie
* @param {string} [filters.duration] - filter videos by duration, can be: any | short | medium | long
* @param {string} [filters.sort_by] - filter video results by order, can be: relevance | rating | upload_date | view_count
* @returns {Promise.<Search>}
*/
search(query: string, filters?: {
upload_date?: string;
type?: string;
duration?: string;
sort_by?: string;
}): Promise<Search>;
/**
* Retrieves video info.
*
* @deprecated do not use this, it is slow and inefficient.
* Use {@link getInfo} instead.
* @param {string} video_id - the video id.
* @returns {Promise.<{ title: string, description: string, thumbnail: any[], metadata: object }>}
*/
getDetails(video_id: string): Promise<{
title: string;
description: string;
thumbnail: any[];
metadata: object;
}>;
/**
* Retrieves comments for a video.
*
* @param {string} video_id - the video id.
* @param {string} [sort_by] - can be: `TOP_COMMENTS` or `NEWEST_FIRST`.
* @returns {Promise.<{ page_count: number, comment_count: number, items: object[] }>}
*/
getComments(video_id: string, sort_by?: string): Promise<{
page_count: number;
comment_count: number;
items: object[];
}>;
/**
* Retrieves contents for a given channel. (WIP)
*
* @param {string} id - channel id
* @returns {Promise<Channel>}
*/
getChannel(id: string): Promise<Channel>;
/**
* Retrieves watch history.
*
* @returns {Promise.<{ items: Array.<{ date: string, videos: object[] }>}>}
*/
getHistory(): Promise<{
items: Array<{
date: string;
videos: object[];
}>;
}>;
/**
* Retrieves YouTube's home feed (aka recommendations).
*
* @returns {Promise<FilterableFeed>}
*/
getHomeFeed(): Promise<FilterableFeed>;
/**
* Retrieves trending content.
*
* @returns {Promise<TabbedFeed>}
*/
getTrending(): Promise<TabbedFeed>;
/**
* @todo finish this
* WIP
*/
getLibrary(): Promise<any>;
/**
* Retrieves subscriptions feed.
*
* @returns {Promise.<{ items: Array.<{ date: string, videos: object[] }>}>}
*/
getSubscriptionsFeed(): Promise<{
items: Array<{
date: string;
videos: object[];
}>;
}>;
/**
* Retrieves notifications.
*
* @returns {Promise.<{ items: Array.<{ title: string, sent_time: string, channel_name: string, channel_thumbnail: object, video_thumbnail: object, video_url: string, read: boolean, notification_id: string }>}>}
*/
getNotifications(): Promise<{
items: Array<{
title: string;
sent_time: string;
channel_name: string;
channel_thumbnail: object;
video_thumbnail: object;
video_url: string;
read: boolean;
notification_id: string;
}>;
}>;
/**
* Retrieves unseen notifications count.
*
* @returns {Promise.<number>}
*/
getUnseenNotificationsCount(): Promise<number>;
/**
* Retrieves lyrics for a given song if available.
*
* @param {string} video_id
* @returns {Promise.<string>}
*/
getLyrics(video_id: string): Promise<string>;
/**
* Retrieves the contents of a given playlist.
*
* @param {string} playlist_id - the id of the playlist.
* @param {object} options - `YOUTUBE` | `YTMUSIC`
* @param {string} options.client - client used to parse the playlist, can be: `YTMUSIC` | `YOUTUBE`
* @returns {Promise.<
* { title: string, description: string, total_items: string, last_updated: string, views: string, items: object[] } |
* { title: string, description: string, total_items: number, duration: string, year: string, items: object[] }>}
*/
getPlaylist(playlist_id: string, options?: {
client: string;
}): Promise<{
title: string;
description: string;
total_items: string;
last_updated: string;
views: string;
items: object[];
} | {
title: string;
description: string;
total_items: number;
duration: string;
year: string;
items: object[];
}>;
/**
* An alternative to {@link download}.
* Returns deciphered streaming data.
*
* @param {string} video_id - video id
* @param {object} options - download options.
* @param {string} options.quality - video quality; 360p, 720p, 1080p, etc...
* @param {string} options.type - download type, can be: video, audio or videoandaudio
* @param {string} options.format - file format
* @returns {Promise.<{ selected_format: object, formats: object[] }>}
*/
getStreamingData(video_id: string, options?: {
quality: string;
type: string;
format: string;
}): Promise<{
selected_format: object;
formats: object[];
}>;
/**
* Downloads a given video. If you only need the direct download link take a look at {@link getStreamingData}.
*
* @param {string} video_id - video id
* @param {object} options - download options.
* @param {string} [options.quality] - video quality; 360p, 720p, 1080p, etc...
* @param {string} [options.type] - download type, can be: video, audio or videoandaudio
* @param {string} [options.format] - file format
* @param {object} [options.range] - download range, indicates which bytes should be downloaded.
* @param {number} options.range.start - the beginning of the range.
* @param {number} options.range.end - the end of the range.
* @returns {Stream.PassThrough}
*/
download(video_id: string, options?: {
quality?: string;
type?: string;
format?: string;
range?: {
start: number;
end: number;
};
}): Stream.PassThrough;
getPlayer(): any;
/** @readonly */
readonly get axios(): any;
#private;
}
import EventEmitter = require("events");
import OAuth = require("./core/OAuth");
import Request = require("./utils/Request");
import Actions = require("./core/Actions");
import AccountManager = require("./core/AccountManager");
import PlaylistManager = require("./core/PlaylistManager");
import InteractionManager = require("./core/InteractionManager");
import YTMusic = require("./core/Music");
import VideoInfo = require("./parser/youtube/VideoInfo");
import Search = require("./parser/youtube/Search");
import Channel = require("./parser/youtube/Channel");
import FilterableFeed = require("./core/FilterableFeed");
import TabbedFeed = require("./core/TabbedFeed");
import Stream = require("stream");