Files
YouTube.js/typings/lib/Innertube.d.ts
2022-07-11 06:13:21 -03:00

227 lines
7.7 KiB
TypeScript

export = Innertube;
/** @namespace */
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_agent]
* @param {object} [config.https_agent]
*/
constructor(config?: {
gl?: string;
cookie?: string;
debug?: boolean;
proxy?: object;
http_agent?: object;
https_agent?: object;
});
config: {
gl?: string;
cookie?: string;
debug?: boolean;
proxy?: object;
http_agent?: object;
https_agent?: object;
};
/** @type {string} */
key: string;
/** @type {string} */
version: string;
/** @type {object} */
context: object;
/** @type {boolean} */
logged_in: boolean;
/** @type {number} */
sts: number;
/** @type {string} */
player_url: string;
/**
* @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;
actions: Actions;
account: AccountManager;
playlist: PlaylistManager;
interact: InteractionManager;
music: YTMusic;
/**
* Signs in to a google account.
* @param {object} credentials
* @param {string} credentials.access_token - Token used to sign in.
* @param {string} credentials.refresh_token - Token used to get a new access token.
* @param {Date} credentials.expires - Access token's expiration date, which is usually 24hrs-ish.
* @returns {Promise.<void>}
*/
signIn(credentials?: {
access_token: string;
refresh_token: string;
expires: Date;
}): Promise<void>;
/**
* Signs out of an account.
* @returns {Promise.<{ success: boolean, status_code: number }>}
*/
signOut(): Promise<{
success: boolean;
status_code: number;
}>;
/**
* Retrieves video info.
* @param {string} video_id
* @returns {Promise.<VideoInfo>}
*/
getInfo(video_id: string): Promise<VideoInfo>;
/**
* Retrieves basic video info.
* @param {string} video_id
* @returns {Promise.<VideoInfo>}
*/
getBasicInfo(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 search suggestions for a given query.
* @param {string} query - the search query.
*/
getSearchSuggestions(query: string): Promise<any>;
/**
* 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.<Comments>}
*/
getComments(video_id: string, sort_by?: string): Promise<Comments>;
/**
* Retrieves YouTube's home feed (aka recommendations).
* @returns {Promise<FilterableFeed>}
*/
getHomeFeed(): Promise<FilterableFeed>;
/**
* Returns the account's library.
* @returns {Promise.<Library>}
*/
getLibrary(): Promise<Library>;
/**
* Retrieves watch history.
* Which can also be achieved with {@link getLibrary()}.
* @returns {Promise.<History>}
*/
getHistory(): Promise<History>;
/**
* Retrieves trending content.
* @returns {Promise<TabbedFeed>}
*/
getTrending(): Promise<TabbedFeed>;
/**
* Retrieves subscriptions feed.
* @returns {Promise.<Feed>}
*/
getSubscriptionsFeed(): Promise<Feed>;
/**
* Retrieves contents for a given channel.
* @param {string} id - channel id
* @returns {Promise<Channel>}
*/
getChannel(id: string): Promise<Channel>;
/**
* Retrieves notifications.
* @returns {Promise.<NotificationsMenu>}
*/
getNotifications(): Promise<NotificationsMenu>;
/**
* Retrieves unseen notifications count.
* @returns {Promise.<number>}
*/
getUnseenNotificationsCount(): Promise<number>;
/**
* Retrieves the contents of a given playlist.
* @param {string} playlist_id - the id of the playlist.
* @returns {Promise.<Playlist>}
*/
getPlaylist(playlist_id: string): Promise<Playlist>;
/**
* 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.<object>}
*/
getStreamingData(video_id: string, options?: {
quality: string;
type: string;
format: string;
}): Promise<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 {PassThrough}
*/
download(video_id: string, options?: {
quality?: string;
type?: string;
format?: string;
range?: {
start: number;
end: number;
};
}): any;
getPlayer(): any;
/** @readonly */
readonly get request(): any;
#private;
}
import OAuth = require("./core/OAuth");
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 Comments = require("./parser/youtube/Comments");
import FilterableFeed = require("./core/FilterableFeed");
import Library = require("./parser/youtube/Library");
import History = require("./parser/youtube/History");
import TabbedFeed = require("./core/TabbedFeed");
import Feed = require("./core/Feed");
import Channel = require("./parser/youtube/Channel");
import NotificationsMenu = require("./parser/youtube/NotificationsMenu");
import Playlist = require("./parser/youtube/Playlist");