chore: update types

This commit is contained in:
LuanRT
2022-06-14 15:02:28 -03:00
parent 3f22a44ba9
commit 60b67a399c
21 changed files with 326 additions and 236 deletions

View File

@@ -1,8 +1,4 @@
export = Innertube;
/**
* Innertube instance.
* @namespace
*/
declare class Innertube {
/**
* @example
@@ -10,33 +6,29 @@ declare class Innertube {
* 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.httpAgent]
* @param {object} [config.httpsAgent]
*
* @returns {Innertube}
* @constructor
* @param {object} [config.http_ent]
* @param {object} [config.https_agent]
*/
constructor(config?: {
gl?: string;
cookie?: string;
debug?: boolean;
proxy?: object;
httpAgent?: object;
httpsAgent?: object;
http_ent?: object;
https_agent?: object;
});
config: {
gl?: string;
cookie?: string;
debug?: boolean;
proxy?: object;
httpAgent?: object;
httpsAgent?: object;
http_ent?: object;
https_agent?: object;
};
key: any;
version: any;
@@ -65,7 +57,6 @@ declare class Innertube {
* @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?: {
@@ -77,7 +68,8 @@ declare class Innertube {
refresh_token: string;
/**
* Signs out of an account.
* @returns {Promise.<{ success: boolean; status_code: number }>}
*
* @returns {Promise.<{ success: boolean, status_code: number }>}
*/
signOut(): Promise<{
success: boolean;
@@ -89,8 +81,7 @@ declare class Innertube {
* @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[] }>}
* @returns {Promise.<{ query: string, results: string[] }>}
*/
getSearchSuggestions(query: string, options?: {
client?: string;
@@ -100,9 +91,11 @@ declare class Innertube {
}>;
/**
* Retrieves video info.
*
* @param {string} video_id
* @returns {Promise.<VideoInfo>}
*/
getInfo(video_id: any): Promise<VideoInfo>;
getInfo(video_id: string): Promise<VideoInfo>;
/**
* Searches a given query.
*
@@ -112,7 +105,6 @@ declare class Innertube {
* @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?: {
@@ -126,14 +118,13 @@ declare class Innertube {
*
* @deprecated do not use this, it is slow and inefficient.
* Use {@link getInfo} instead.
*
* @param {string} video_id - the video id.
* @return {Promise.<{ title: string; description: string; thumbnail: []; metadata: object }>}
* @returns {Promise.<{ title: string, description: string, thumbnail: any[], metadata: object }>}
*/
getDetails(video_id: string): Promise<{
title: string;
description: string;
thumbnail: [];
thumbnail: any[];
metadata: object;
}>;
/**
@@ -141,7 +132,7 @@ declare class Innertube {
*
* @param {string} video_id - the video id.
* @param {string} [sort_by] - can be: `TOP_COMMENTS` or `NEWEST_FIRST`.
* @return {Promise.<{ page_count: number; comment_count: number; items: object[]; }>}
* @returns {Promise.<{ page_count: number, comment_count: number, items: object[] }>}
*/
getComments(video_id: string, sort_by?: string): Promise<{
page_count: number;
@@ -150,8 +141,9 @@ declare class Innertube {
}>;
/**
* Retrieves contents for a given channel. (WIP)
*
* @param {string} id - channel id
* @return {Promise.<{ title: string; description: string; metadata: object; content: object }>}
* @returns {Promise.<{ title: string, description: string, metadata: object, content: object }>}
*/
getChannel(id: string): Promise<{
title: string;
@@ -161,39 +153,42 @@ declare class Innertube {
}>;
/**
* Retrieves watch history.
* @returns {Promise.<{ items: { date: string; videos: object[] }[] }>}
*
* @returns {Promise.<{ items: Array.<{ date: string, videos: object[] }>}>}
*/
getHistory(): Promise<{
items: {
items: Array<{
date: string;
videos: object[];
}[];
}>;
}>;
/**
* Retrieves home feed (aka recommendations).
* @returns {Promise.<{ videos: { id: string; title: string; description: string; channel: string; metadata: object }[] }>}
*
* @returns {Promise.<{ videos: Array.<{ id: string, title: string, description: string, channel: string, metadata: object }>}>}
*/
getHomeFeed(): Promise<{
videos: {
videos: Array<{
id: string;
title: string;
description: string;
channel: string;
metadata: object;
}[];
}>;
}>;
/**
* Retrieves trending content.
* @returns {Promise.<{ now: { content: { title: string; videos: object[]; }[] };
* music: { getVideos: Promise.<Array.<object>>; }; gaming: { getVideos: Promise.<Array.<object>>; };
* movies: { getVideos: Promise.<Array.<object>>; } }>}
*
* @returns {Promise.<{ now: { content: Array.<{ title: string, videos: object[] }> },
* music: { getVideos: Promise.<Array.<object>> }, gaming: { getVideos: Promise.<Array.<object>> },
* movies: { getVideos: Promise.<Array.<object>> } }>}
*/
getTrending(): Promise<{
now: {
content: {
content: Array<{
title: string;
videos: object[];
}[];
}>;
};
music: {
getVideos: Promise<Array<object>>;
@@ -212,20 +207,22 @@ declare class Innertube {
getLibrary(): Promise<any>;
/**
* Retrieves subscriptions feed.
* @returns {Promise.<{ items: { date: string; videos: object[] }[] }>}
*
* @returns {Promise.<{ items: Array.<{ date: string, videos: object[] }>}>}
*/
getSubscriptionsFeed(): Promise<{
items: {
items: Array<{
date: string;
videos: object[];
}[];
}>;
}>;
/**
* Retrieves notifications.
* @returns {Promise.<{ items: { title: string; sent_time: string; channel_name: string; channel_thumbnail: object; video_thumbnail: object; video_url: string; read: boolean; notification_id: string }[] }>}
*
* @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: {
items: Array<{
title: string;
sent_time: string;
channel_name: string;
@@ -234,10 +231,11 @@ declare class Innertube {
video_url: string;
read: boolean;
notification_id: string;
}[];
}>;
}>;
/**
* Retrieves unseen notifications count.
*
* @returns {Promise.<number>}
*/
getUnseenNotificationsCount(): Promise<number>;
@@ -254,10 +252,9 @@ declare class Innertube {
* @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: [] } |
* { title: string; description: string; total_items: number; duration: string; year: string; items: [] }>}
* { 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;
@@ -267,14 +264,14 @@ declare class Innertube {
total_items: string;
last_updated: string;
views: string;
items: [];
items: object[];
} | {
title: string;
description: string;
total_items: number;
duration: string;
year: string;
items: [];
items: object[];
}>;
/**
* An alternative to {@link download}.
@@ -285,8 +282,7 @@ declare class Innertube {
* @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[] }>}
* @returns {Promise.<{ selected_format: object, formats: object[] }>}
*/
getStreamingData(video_id: string, options?: {
quality: string;
@@ -307,8 +303,7 @@ declare class Innertube {
* @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.
*
* @return {Stream.PassThrough}
* @returns {Stream.PassThrough}
*/
download(video_id: string, options?: {
quality?: string;

View File

@@ -2,17 +2,21 @@ export = AccountManager;
/** @namespace */
declare class AccountManager {
/**
* @param {Actions} actions
* @constructor
* @param {import('./Actions')} actions
*/
constructor(actions: import('./Actions'));
/**
* API response.
*
* @typedef {{ success: boolean, status_code: number, data: object }} Response
*/
constructor(actions: Actions);
/** @namespace */
channel: {
/**
* Edits channel name.
*
* @param {string} new_name
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
editName: (new_name: string) => Promise<{
success: boolean;
@@ -23,7 +27,7 @@ declare class AccountManager {
* Edits channel description.
*
* @param {string} new_description
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
editDescription: (new_description: string) => Promise<{
success: boolean;
@@ -32,7 +36,8 @@ declare class AccountManager {
}>;
/**
* Retrieves basic channel analytics.
* @borrows AccountManager#getAnalytics as getBasicAnalytics
*
* @borrows getAnalytics as getBasicAnalytics
*/
getBasicAnalytics: () => Promise<Analytics>;
};
@@ -43,7 +48,7 @@ declare class AccountManager {
* Notify about activity from the channels you're subscribed to.
*
* @param {boolean} option - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
setSubscriptions: (option: boolean) => Promise<{
success: boolean;
@@ -54,7 +59,7 @@ declare class AccountManager {
* Recommended content notifications.
*
* @param {boolean} option - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
setRecommendedVideos: (option: boolean) => Promise<{
success: boolean;
@@ -65,7 +70,7 @@ declare class AccountManager {
* Notify about activity on your channel.
*
* @param {boolean} option - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
setChannelActivity: (option: boolean) => Promise<{
success: boolean;
@@ -76,7 +81,7 @@ declare class AccountManager {
* Notify about replies to your comments.
*
* @param {boolean} option - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
setCommentReplies: (option: boolean) => Promise<{
success: boolean;
@@ -87,7 +92,7 @@ declare class AccountManager {
* Notify when others mention your channel.
*
* @param {boolean} option - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
setMentions: (option: boolean) => Promise<{
success: boolean;
@@ -98,7 +103,7 @@ declare class AccountManager {
* Notify when others share your content on their channels.
*
* @param {boolean} option - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
setSharedContent: (option: boolean) => Promise<{
success: boolean;
@@ -111,7 +116,7 @@ declare class AccountManager {
* If set to true, your subscriptions won't be visible to others.
*
* @param {boolean} option - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
setSubscriptionsPrivate: (option: boolean) => Promise<{
success: boolean;
@@ -122,8 +127,8 @@ declare class AccountManager {
* If set to true, saved playlists won't appear on your channel.
*
* @param {boolean} option - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
* @returns {Promise.<Response>}
*/
setSavedPlaylistsPrivate: (option: boolean) => Promise<{
success: boolean;
status_code: number;
@@ -133,7 +138,8 @@ declare class AccountManager {
};
/**
* Retrieves channel info.
* @returns {Promise.<{ name: string; email: string; channel_id: string; subscriber_count: string; photo: object[]; }>}
*
* @returns {Promise.<{ name: string, email: string, channel_id: string, subscriber_count: string, photo: object[] }>}
*/
getInfo(): Promise<{
name: string;
@@ -144,19 +150,22 @@ declare class AccountManager {
}>;
/**
* Retrieves time watched statistics.
* @returns {Promise.<{ title: string; time: string; }[]>}
*
* @returns {Promise.<Array.<{ title: string, time: string }>>}
*/
getTimeWatched(): Promise<{
getTimeWatched(): Promise<Array<{
title: string;
time: string;
}[]>;
}>>;
/**
* Retrieves basic channel analytics.
*
* @returns {Promise.<Analytics>}
*/
getAnalytics(): Promise<Analytics>;
/**
* Returns the account's library.
*
* @returns {Promise.<Library>}
*/
getLibrary(): Promise<Library>;

View File

@@ -1,15 +1,15 @@
export = Actions;
/**
* API response.
* @typedef {Promise.<{ success: boolean; status_code: number; data: object; }>} Response
*/
/** namespace **/
/** @namespace */
declare class Actions {
/**
* @param {Innertube} session
* @constructor
* @param {import('../Innertube')} session
*/
constructor(session: import('../Innertube'));
/**
* API response.
*
* @typedef {{ success: boolean, status_code: number, data: object }} Response
*/
constructor(session: Innertube);
/**
* Covers `/browse` endpoint, mostly used to access
* YouTube's sections such as the home feed, etc
@@ -21,15 +21,18 @@ declare class Actions {
* @param {boolean} [args.is_ytm]
* @param {boolean} [args.is_ctoken]
* @param {string} [args.client]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
browse(id: string, args?: {
params?: string;
is_ytm?: boolean;
is_ctoken?: boolean;
client?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Covers endpoints used to perform direct interactions
* on YouTube.
@@ -40,15 +43,18 @@ declare class Actions {
* @param {string} [args.channel_id]
* @param {string} [args.comment_id]
* @param {string} [args.comment_action]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
engage(action: string, args?: {
video_id?: string;
channel_id?: string;
comment_id?: string;
comment_action?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Covers endpoints related to account management.
*
@@ -56,13 +62,16 @@ declare class Actions {
* @param {object} args
* @param {string} [args.new_value]
* @param {string} [args.setting_item_id]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
account(action: string, args?: {
new_value?: string;
setting_item_id?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Endpoint used for search.
*
@@ -74,8 +83,7 @@ declare class Actions {
* @param {string} [args.options.order]
* @param {string} [args.client]
* @param {string} [args.ctoken]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
search(args?: {
query?: string;
@@ -86,18 +94,25 @@ declare class Actions {
};
client?: string;
ctoken?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Endpoint used fo Shorts' sound search.
*
* @param {object} args
* @param {string} args.query
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
searchSound(args?: {
query: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Channel management endpoints.
*
@@ -105,13 +120,16 @@ declare class Actions {
* @param {object} args
* @param {string} [args.new_name]
* @param {string} [args.new_description]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
channel(action: string, args?: {
new_name?: string;
new_description?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Covers endpoints used for playlist management.
*
@@ -121,15 +139,18 @@ declare class Actions {
* @param {string} [args.ids]
* @param {string} [args.playlist_id]
* @param {string} [args.action]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
playlist(action: string, args?: {
title?: string;
ids?: string;
playlist_id?: string;
action?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Covers endpoints used for notifications management.
*
@@ -138,14 +159,17 @@ declare class Actions {
* @param {string} [args.pref]
* @param {string} [args.channel_id]
* @param {string} [args.ctoken]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
notifications(action: string, args?: {
pref?: string;
channel_id?: string;
ctoken?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Covers livechat endpoints.
*
@@ -156,8 +180,7 @@ declare class Actions {
* @param {string} [args.channel_id]
* @param {string} [args.ctoken]
* @param {string} [args.params]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
livechat(action: string, args?: {
text?: string;
@@ -165,18 +188,25 @@ declare class Actions {
channel_id?: string;
ctoken?: string;
params?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Endpoint used to retrieve video thumbnails.
*
* @param {object} args
* @param {string} args.video_id
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
thumbnails(args?: {
video_id: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Place Autocomplete endpoint, found it in the APK but
* doesn't seem to be used anywhere on YouTube (maybe for ads?).
@@ -190,12 +220,15 @@ declare class Actions {
* @param {string} action
* @param {object} args
* @param {string} args.input
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
geo(action: string, args?: {
input: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Covers endpoints used to report content.
*
@@ -203,22 +236,31 @@ declare class Actions {
* @param {object} args
* @param {object} [args.action]
* @param {string} [args.params]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
flag(action: string, args: {
action?: object;
params?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Covers specific YouTube Music endpoints.
*
* @param {string} action
* @param {string} args.input
*
* @returns {Response}
* @param {object} args
* @param {string} [args.input]
* @returns {Promise.<Response>}
*/
music(action: string, args: any): Response;
music(action: string, args: {
input?: string;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Mostly used for pagination and specific operations.
*
@@ -226,53 +268,55 @@ declare class Actions {
* @param {string} [args.video_id]
* @param {string} [args.ctoken]
* @param {string} [args.client]
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
next(args?: {
video_id?: string;
ctoken?: string;
client?: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Used to retrieve video info.
*
* @param {string} id
* @param {string} [cpn]
*
* @returns {Response}
* @param {string} [client]
* @returns {Promise.<Response>}
*/
getVideoInfo(id: string, cpn?: string, client: any): Response;
getVideoInfo(id: string, cpn?: string, client?: string): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Covers search suggestion endpoints.
*
* @param {string} client
* @param {string} input
*
* @returns {Response}
* @param {string} query
* @returns {Promise.<Response>}
*/
getSearchSuggestions(client: string, query: any): Response;
getSearchSuggestions(client: string, query: string): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
/**
* Endpoint used to retrieve user mention suggestions.
*
* @param {object} args
* @param {string} args.input
*
* @returns {Response}
* @returns {Promise.<Response>}
*/
getUserMentionSuggestions(args?: {
input: string;
}): Response;
}): Promise<{
success: boolean;
status_code: number;
data: object;
}>;
#private;
}
declare namespace Actions {
export { Response };
}
/**
* API response.
*/
type Response = Promise<{
success: boolean;
status_code: number;
data: object;
}>;

View File

@@ -2,14 +2,19 @@ export = InteractionManager;
/** @namespace */
declare class InteractionManager {
/**
* @param {Actions} actions
* @constructor
* @param {import('../Actions')} actions
*/
constructor(actions: any);
/**
* API response.
*
* @typedef {{ success: boolean, status_code: number, data: object }} Response
*/
constructor(actions: Actions);
/**
* Likes a given video.
*
* @param {string} video_id
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
like(video_id: string): Promise<{
success: boolean;
@@ -18,8 +23,9 @@ declare class InteractionManager {
}>;
/**
* Dislikes a given video.
*
* @param {string} video_id
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
dislike(video_id: string): Promise<{
success: boolean;
@@ -28,8 +34,9 @@ declare class InteractionManager {
}>;
/**
* Removes a like/dislike.
*
* @param {string} video_id
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
removeLike(video_id: string): Promise<{
success: boolean;
@@ -38,8 +45,9 @@ declare class InteractionManager {
}>;
/**
* Subscribes to a given channel.
*
* @param {string} channel_id
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
subscribe(channel_id: string): Promise<{
success: boolean;
@@ -48,8 +56,9 @@ declare class InteractionManager {
}>;
/**
* Unsubscribes from a given channel.
*
* @param {string} channel_id
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
unsubscribe(channel_id: string): Promise<{
success: boolean;
@@ -61,8 +70,7 @@ declare class InteractionManager {
*
* @param {string} video_id
* @param {string} text
*
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
comment(video_id: string, text: string): Promise<{
success: boolean;
@@ -77,8 +85,7 @@ declare class InteractionManager {
* @param {object} [args] - optional arguments
* @param {string} [args.video_id]
* @param {string} [args.comment_id]
*
* @returns {Promise.<{ success: boolean; status_code: number; translated_content: string; data: object; }>}
* @returns {Promise.<{ success: boolean, status_code: number, translated_content: string, data: object }>}
*/
translate(text: string, target_language: string, args?: {
video_id?: string;
@@ -95,8 +102,7 @@ declare class InteractionManager {
*
* @param {string} channel_id
* @param {string} type - `PERSONALIZED` | `ALL` | `NONE`
*
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
* @returns {Promise.<Response>}
*/
setNotificationPreferences(channel_id: string, type: string): Promise<{
success: boolean;

View File

@@ -1,4 +1,5 @@
export = Livechat;
/** @namespace */
declare class Livechat extends EventEmitter {
constructor(session: any, token: any, channel_id: any, video_id: any);
ctoken: any;
@@ -14,6 +15,7 @@ declare class Livechat extends EventEmitter {
sendMessage(text: any): Promise<any>;
/**
* Blocks a user.
*
* @todo Implement this method
*/
blockUser(): Promise<void>;

View File

@@ -2,17 +2,15 @@ export = Music;
/** @namespace */
declare class Music {
/**
* @param {Innertube} session
* @constructor
* @param {import('../Innertube')} session
*/
constructor(session: Innertube);
constructor(session: import('../Innertube'));
/**
* Search on YouTube Music.
* Searches on YouTube Music.
*
* @param {string} query
* @param {object} filters - search filters
* @param {string} [filters.type] - all | song | video | album | playlist | artist
*
* @returns {Promise.<Search>}
*/
search(query: string, filters: {
@@ -20,21 +18,24 @@ declare class Music {
}): Promise<Search>;
/**
* Retrieves YouTube Music home feed.
*
* @returns {Promise.<HomeFeed>}
*/
getHomeFeed(): Promise<HomeFeed>;
/**
* Retrieves song lyrics.
*
* @param {string} video_id
*/
getLyrics(video_id: string): Promise<{
/** @type {string} */
text: string;
/** @type {Text} */
footer: Text;
/** @type {import('../parser/contents/classes/Text')} */
footer: import('../parser/contents/classes/Text');
}>;
/**
* Retrieves up next.
*
* @param {string} video_id
*/
getUpNext(video_id: string): Promise<{
@@ -49,10 +50,11 @@ declare class Music {
}>;
/**
* Retrieves related content.
*
* @param {string} video_id
*/
getRelated(video_id: string): Promise<{
/** @type {{ header: import('../parser/contents/classes/MusicCarouselShelfBasicHeader'); items: object[]; }[]} */
/** @type {Array.<{ header: import('../parser/contents/classes/MusicCarouselShelfBasicHeader'), items: object[] }>} */
sections: {
header: import('../parser/contents/classes/MusicCarouselShelfBasicHeader');
items: object[];

View File

@@ -4,43 +4,57 @@ declare class OAuth {
/**
* @param {EventEmitter} ev
* @param {AxiosInstance} axios
* @constructor
*/
constructor(ev: EventEmitter, axios: AxiosInstance);
/**
* Starts the auth flow in case no valid credentials are available.
*
* @param {object} auth_info
* @param {string} auth_info.access_token
* @param {string} auth_info.refresh_token
* @param {Date} auth_info.expires_in
* @returns {Promise.<void>}
*/
init(auth_info: any): Promise<void>;
init(auth_info: {
access_token: string;
refresh_token: string;
expires_in: Date;
}): Promise<void>;
client_id: string;
client_secret: string;
/**
* Refreshes the access token if necessary.
*
* @returns {Promise.<void>}
*/
checkTokenValidity(): Promise<void>;
/**
* Revokes access token (note that the refresh token will also be revoked).
*
* @returns {Promise.<void>}
*/
revokeAccessToken(): Promise<void>;
/**
* Returns the access token.
*
* @returns {string}
*/
getAccessToken(): string;
/**
* Returns the refresh token.
*
* @returns {string}
*/
getRefreshToken(): string;
/**
* Checks if the auth info format is valid.
*
* @returns {boolean} true | false
*/
isValidAuthInfo(): boolean;
/**
* Checks access token validity.
*
* @returns {boolean} true | false
*/
shouldRefreshToken(): boolean;

View File

@@ -3,36 +3,45 @@ export = Player;
declare class Player {
/**
* Represents the YouTube Web player script.
*
* @param {string} id - the id of the player.
* @param {AxiosInstance} axios
* @constructor
*/
constructor(id: string, axios: AxiosInstance);
init(): Promise<Player>;
/**
* Returns the current player's url.
* Js player url.
*
* @readonly
* @returns {string}
*/
readonly get url(): string;
/**
* Returns the signature timestamp.
* Signature timestamp.
*
* @readonly
* @returns {string}
*/
readonly get sts(): string;
/**
* Returns the n-token decipher algorithm.
* N-Token decipher algorithm.
*
* @readonly
* @returns {string}
*/
readonly get ntoken_decipher(): string;
/**
* Returns the signature decipher algorithm.
* Signature decipher algorithm.
*
* @readonly
* @returns {string}
*/
readonly get signature_decipher(): string;
/**
* Checks if the player script is cached.
*
* @returns {boolean}
*/
isCached(): boolean;
#private;
}

View File

@@ -2,19 +2,22 @@ export = PlaylistManager;
/** @namespace */
declare class PlaylistManager {
/**
* @param {Actions} actions
* @constructor
* @param {import('../Actions')} actions
*/
constructor(actions: any);
/**
* API
*
* @typedef {{ success: boolean, status_code: number, playlist_id: string, data: object }} Response
*/
constructor(actions: Actions);
/**
* Creates a playlist.
*
* @param {string} title
* @param {Array.<string>} video_ids
*
* @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>}
* @param {string[]} video_ids
* @returns {Promise.<Response>}
*/
create(title: string, video_ids: Array<string>): Promise<{
create(title: string, video_ids: string[]): Promise<{
success: boolean;
status_code: number;
playlist_id: string;
@@ -22,8 +25,9 @@ declare class PlaylistManager {
}>;
/**
* Deletes a given playlist.
*
* @param {string} playlist_id
* @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>}
* @returns {Promise.<Response>}
*/
delete(playlist_id: string): Promise<{
success: boolean;
@@ -36,8 +40,7 @@ declare class PlaylistManager {
*
* @param {string} playlist_id
* @param {Array.<string>} video_ids
*
* @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>}
* @returns {Promise.<Response>}
*/
addVideos(playlist_id: string, video_ids: Array<string>): Promise<{
success: boolean;
@@ -50,8 +53,7 @@ declare class PlaylistManager {
*
* @param {string} playlist_id
* @param {Array.<string>} video_ids
*
* @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>}
* @returns {Promise.<Response>}
*/
removeVideos(playlist_id: string, video_ids: Array<string>): Promise<{
success: boolean;

View File

@@ -3,12 +3,18 @@ export = SessionBuilder;
declare class SessionBuilder {
/**
* @param {object} config
* @constructor
* @param {object} [config.proxy]
* @param {object} [config.http_agent]
* @param {object} [config.https_agent]
*/
constructor(config: object);
constructor(config: {
proxy?: object;
http_agent?: object;
https_agent?: object;
});
build(): Promise<SessionBuilder>;
/** @readonly */
readonly get axios(): AxiosInstance;
readonly get axios(): typeof Axios;
/** @readonly */
readonly get key(): any;
/** @readonly */
@@ -23,3 +29,4 @@ declare class SessionBuilder {
readonly get player(): any;
#private;
}
import Axios = require("axios");

View File

@@ -5,6 +5,7 @@ declare class NToken {
raw_code: any;
/**
* Solves throttling challange by transforming the n token.
*
* @returns {string}
*/
transform(): string;

View File

@@ -6,6 +6,7 @@ declare class Signature {
decipherBeta(): any;
/**
* Deciphers signature.
*
* @returns {string}
*/
decipher(): string;

View File

@@ -1,5 +1,4 @@
export = Parser;
/** @namespace */
declare class Parser {
static parseResponse(data: any): {
contents: any;
@@ -57,7 +56,6 @@ declare class Parser {
static shouldIgnore(classname: any): boolean;
}
import VideoDetails = require("./classes/VideoDetails");
/** @namespace */
declare class SectionListContinuation {
constructor(data: any);
type: string;

View File

@@ -5,7 +5,7 @@ declare class History {
* @param {object} page - parsed data.
* @param {import('../../core/Actions')} actions
* @param {boolean} is_continuation
* @constructor
* @function Object() { [native code] }
*/
constructor(page: object, actions: import('../../core/Actions'), is_continuation: boolean);
sections: any;

View File

@@ -6,7 +6,6 @@ declare class Search {
* @param {import('../../core/Actions')} actions
* @param {object} [args]
* @param {boolean} [args.is_continuation]
* @constructor
*/
constructor(response: object, actions: import('../../core/Actions'), args?: {
is_continuation?: boolean;
@@ -15,7 +14,7 @@ declare class Search {
results: object[];
refinements: any;
estimated_results: any;
/** @type {{ sections: { title: string; items: object[]; }[] }} */
/** @type {{ sections: { title: string, items: object[] }[] }} */
sections: {
sections: {
title: string;
@@ -30,15 +29,17 @@ declare class Search {
};
/**
* Retrieves next batch of results.
*
* @returns {Promise.<Search>}
*/
getContinuation(): Promise<Search>;
/**
* Applies given refinement card and returns a new {@link Search} object.
* @param {SearchRefinementCard | string} card - refinement card object or query
*
* @param {import('../contents/classes/SearchRefinementCard') | string} card - refinement card object or query
* @returns {Promise.<Search>}
*/
selectRefinementCard(card: SearchRefinementCard | string): Promise<Search>;
selectRefinementCard(card: import('../contents/classes/SearchRefinementCard') | string): Promise<Search>;
/** @type {boolean} */
get has_continuation(): boolean;
/** @type {string[]} */

View File

@@ -71,22 +71,28 @@ declare class VideoInfo {
comments_entry_point_header: import('../contents/classes/CommentsEntryPointHeader');
/**
* Applies given filter to the watch next feed.
*
* @param {string} name
* @returns {Promise.<VideoInfo>}
*/
selectFilter(name: string): Promise<VideoInfo>;
/** @typedef {import('../contents/classes/CompactVideo')} CompactVideo */
/** @typedef {import('../contents/classes/CompactMix')} CompactMix */
/**
* Retrieves watch next feed continuation.
*
* @returns {Promise.<CompactVideo[] | CompactMix[]>}
*/
getWatchNextContinuation(): Promise<CompactVideo[] | CompactMix[]>;
getWatchNextContinuation(): Promise<import("../contents/classes/CompactVideo")[] | import("../contents/classes/CompactMix")[]>;
/**
* API response.
* @typedef {Promise.<{ success: boolean; status_code: number; data: object; }>} Response
*
* @typedef {{ success: boolean, status_code: number, data: object }} Response
*/
/**
* Likes the video.
* @returns {Response}
*
* @returns {Promise.<Response>}
*/
like(): Promise<{
success: boolean;
@@ -95,7 +101,8 @@ declare class VideoInfo {
}>;
/**
* Dislikes the video.
* @returns {Response}
*
* @returns {Promise.<Response>}
*/
dislike(): Promise<{
success: boolean;
@@ -104,7 +111,8 @@ declare class VideoInfo {
}>;
/**
* Removes like/dislike.
* @returns {Response}
*
* @returns {Promise.<Response>}
*/
removeLike(): Promise<{
success: boolean;
@@ -120,13 +128,8 @@ declare class VideoInfo {
on_response_received_commands: any;
continuation_contents: any;
metadata: any;
/**
* @type {import('../contents/classes/VideoSecondaryInfo')}
*/
header: any;
microformat: import("../contents/classes/PlayerMicroformat"); /**
* @type {import('../contents/classes/MerchandiseShelf')}
*/
microformat: import("../contents/classes/PlayerMicroformat");
sidebar: any;
overlay: any;
refinements: any;

View File

@@ -15,6 +15,7 @@ declare class HomeFeed {
};
/**
* Retrieves home feed continuation.
*
* @returns {Promise.<HomeFeed>}
*/
getContinuation(): Promise<HomeFeed>;

View File

@@ -7,7 +7,7 @@ declare class Search {
* @param {object} args
* @param {boolean} args.is_continuation
* @param {boolean} args.is_filtered
* @constructor
* @function Object() { [native code] }
*/
constructor(response: object, actions: import('../../core/Actions'), args?: {
is_continuation: boolean;
@@ -30,14 +30,16 @@ declare class Search {
};
/**
* Retrieves continuation, only works for individual sections or filtered results.
*
* @returns {Promise.<Search>}
*/
getContinuation(): Promise<Search>;
/**
* Applies given filter to the search.
* @param {string} name
* @returns {Promise.<Search>}
*/
* Applies given filter to the search.
*
* @param {string} name
* @returns {Promise.<Search>}
*/
selectFilter(name: string): Promise<Search>;
/** @type {boolean} */
get has_continuation(): boolean;

View File

@@ -5,7 +5,6 @@ declare class Proto {
*
* @param {string} id
* @param {number} timestamp
*
* @returns {string}
*/
static encodeVisitorData(id: string, timestamp: number): string;
@@ -24,7 +23,6 @@ declare class Proto {
* @param {string} [filters.type] - all | video | channel | playlist | movie
* @param {string} [filters.duration] - all | short | medium | long
* @param {string} [filters.sort_by] - relevance | rating | upload_date | view_count
*
* @returns {string}
*/
static encodeSearchFilters(filters: {
@@ -38,7 +36,6 @@ declare class Proto {
*
* @param {object} filters
* @param {string} filters.type - all | song | video | album | playlist | artist
*
* @returns {string}
*/
static encodeMusicSearchFilters(filters?: {
@@ -49,7 +46,6 @@ declare class Proto {
*
* @param {string} channel_id
* @param {string} video_id
*
* @returns {string}
*/
static encodeMessageParams(channel_id: string, video_id: string): string;
@@ -60,7 +56,6 @@ declare class Proto {
* @param {object} options
* @param {string} options.type
* @param {string} options.sort_by
*
* @returns {string}
*/
static encodeCommentsSectionParams(video_id: string, options?: {
@@ -72,7 +67,6 @@ declare class Proto {
*
* @param {string} video_id
* @param {string} comment_id
*
* @returns {string}
*/
static encodeCommentRepliesParams(video_id: string, comment_id: string): string;
@@ -88,28 +82,31 @@ declare class Proto {
*
* @param {string} comment_id
* @param {string} video_id
*
* @return {string}
* @returns {string}
*/
static encodeCommentReplyParams(comment_id: string, video_id: string): string;
/**
* Encodes comment action parameters.
*
* @param {string} type
* @param {string} comment_id
* @param {string} video_id
* @param {string} [text]
* @param {string} [target_language]
*
* @param {object} [args]
* @param {string} [args.comment_id]
* @param {string} [args.video_id]
* @param {string} [args.text]
* @param {string} [args.target_language]
* @returns {string}
*/
static encodeCommentActionParams(type: string, args?: {}): string;
static encodeCommentActionParams(type: string, args?: {
comment_id?: string;
video_id?: string;
text?: string;
target_language?: string;
}): string;
/**
* Encodes notification preference parameters.
*
* @param {string} channel_id
* @param {number} index
*
* @returns {string}
*/
static encodeNotificationPref(channel_id: string, index: number): string;

View File

@@ -2,11 +2,10 @@ export = Request;
/** @namespace */
declare class Request {
/**
* @param {Innertube} session
* @constructor
* @param {import('../Innertube')} session
*/
constructor(session: Innertube);
session: Innertube;
constructor(session: import('../Innertube'));
session: import("../Innertube");
instance: any;
#private;
}

View File

@@ -1,4 +1,3 @@
/** @namespace */
export class InnertubeError extends Error {
constructor(message: any, info: any);
info: any;
@@ -23,18 +22,17 @@ export class NoStreamingDataError extends InnertubeError {
* @param {string} target - anything that might be inside of the property.
* @param {number} depth - maximum number of nested objects to flatten.
* @param {boolean} safe - if set to true arrays will be preserved.
*
* @returns {object|Array.<any>}
* @returns {object|object[]}
*/
export function findNode(obj: object, key: string, target: string, depth: number, safe?: boolean): object | Array<any>;
export function findNode(obj: object, key: string, target: string, depth: number, safe?: boolean): object | object[];
/**
* Creates a trap to intercept property access
* and add utilities to an object.
*
* @param {object} obj
* @returns
* @returns {object}
*/
export function observe(obj: object): any;
export function observe(obj: object): object;
/**
* Returns a random user agent.
*
@@ -62,7 +60,6 @@ export function generateRandomString(length: number): string;
* @param {string} data - the data.
* @param {string} start_string - start string.
* @param {string} end_string - end string.
*
* @returns {string}
*/
export function getStringBetweenStrings(data: string, start_string: string, end_string: string): string;
@@ -84,7 +81,7 @@ export function isValidClient(client: string): boolean;
* Throws an error if given parameters are undefined.
*
* @param {object} params
* @returns
* @returns {void}
*/
export function throwIfMissing(params: object): void;
/**