diff --git a/typings/lib/Innertube.d.ts b/typings/lib/Innertube.d.ts index 262a7b76..21895cdd 100644 --- a/typings/lib/Innertube.d.ts +++ b/typings/lib/Innertube.d.ts @@ -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.} */ 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.} */ - getInfo(video_id: any): Promise; + getInfo(video_id: string): Promise; /** * 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(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.>; }; gaming: { getVideos: Promise.>; }; - * movies: { getVideos: Promise.>; } }>} + * + * @returns {Promise.<{ now: { content: Array.<{ title: string, videos: object[] }> }, + * music: { getVideos: Promise.> }, gaming: { getVideos: Promise.> }, + * movies: { getVideos: Promise.> } }>} */ getTrending(): Promise<{ now: { - content: { + content: Array<{ title: string; videos: object[]; - }[]; + }>; }; music: { getVideos: Promise>; @@ -212,20 +207,22 @@ declare class Innertube { getLibrary(): Promise; /** * 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.} */ getUnseenNotificationsCount(): Promise; @@ -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; diff --git a/typings/lib/core/AccountManager.d.ts b/typings/lib/core/AccountManager.d.ts index ac32c700..7b29b594 100644 --- a/typings/lib/core/AccountManager.d.ts +++ b/typings/lib/core/AccountManager.d.ts @@ -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.} */ 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.} */ 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; }; @@ -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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} + */ 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.>} */ - getTimeWatched(): Promise<{ + getTimeWatched(): Promise; + }>>; /** * Retrieves basic channel analytics. + * * @returns {Promise.} */ getAnalytics(): Promise; /** * Returns the account's library. + * * @returns {Promise.} */ getLibrary(): Promise; diff --git a/typings/lib/core/Actions.d.ts b/typings/lib/core/Actions.d.ts index c5aa5abc..0bd402be 100644 --- a/typings/lib/core/Actions.d.ts +++ b/typings/lib/core/Actions.d.ts @@ -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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ - 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.} */ 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.} */ - 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.} */ - 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.} */ 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; -}>; diff --git a/typings/lib/core/InteractionManager.d.ts b/typings/lib/core/InteractionManager.d.ts index 6ac52468..14526809 100644 --- a/typings/lib/core/InteractionManager.d.ts +++ b/typings/lib/core/InteractionManager.d.ts @@ -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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ 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.} */ setNotificationPreferences(channel_id: string, type: string): Promise<{ success: boolean; diff --git a/typings/lib/core/Livechat.d.ts b/typings/lib/core/Livechat.d.ts index be410877..42e45afe 100644 --- a/typings/lib/core/Livechat.d.ts +++ b/typings/lib/core/Livechat.d.ts @@ -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; /** * Blocks a user. + * * @todo Implement this method */ blockUser(): Promise; diff --git a/typings/lib/core/Music.d.ts b/typings/lib/core/Music.d.ts index 4045fe90..9c11fea1 100644 --- a/typings/lib/core/Music.d.ts +++ b/typings/lib/core/Music.d.ts @@ -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(query: string, filters: { @@ -20,21 +18,24 @@ declare class Music { }): Promise; /** * Retrieves YouTube Music home feed. + * * @returns {Promise.} */ getHomeFeed(): Promise; /** * 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[]; diff --git a/typings/lib/core/OAuth.d.ts b/typings/lib/core/OAuth.d.ts index 3e5f72d1..cd45ae4b 100644 --- a/typings/lib/core/OAuth.d.ts +++ b/typings/lib/core/OAuth.d.ts @@ -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.} */ - init(auth_info: any): Promise; + init(auth_info: { + access_token: string; + refresh_token: string; + expires_in: Date; + }): Promise; client_id: string; client_secret: string; /** * Refreshes the access token if necessary. + * * @returns {Promise.} */ checkTokenValidity(): Promise; /** * Revokes access token (note that the refresh token will also be revoked). + * * @returns {Promise.} */ revokeAccessToken(): Promise; /** * 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; diff --git a/typings/lib/core/Player.d.ts b/typings/lib/core/Player.d.ts index 8e8282cd..501c31bc 100644 --- a/typings/lib/core/Player.d.ts +++ b/typings/lib/core/Player.d.ts @@ -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; /** - * 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; } diff --git a/typings/lib/core/PlaylistManager.d.ts b/typings/lib/core/PlaylistManager.d.ts index 1e58e914..ec8e4448 100644 --- a/typings/lib/core/PlaylistManager.d.ts +++ b/typings/lib/core/PlaylistManager.d.ts @@ -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.} video_ids - * - * @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>} + * @param {string[]} video_ids + * @returns {Promise.} */ - create(title: string, video_ids: Array): 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.} */ delete(playlist_id: string): Promise<{ success: boolean; @@ -36,8 +40,7 @@ declare class PlaylistManager { * * @param {string} playlist_id * @param {Array.} video_ids - * - * @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>} + * @returns {Promise.} */ addVideos(playlist_id: string, video_ids: Array): Promise<{ success: boolean; @@ -50,8 +53,7 @@ declare class PlaylistManager { * * @param {string} playlist_id * @param {Array.} video_ids - * - * @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>} + * @returns {Promise.} */ removeVideos(playlist_id: string, video_ids: Array): Promise<{ success: boolean; diff --git a/typings/lib/core/SessionBuilder.d.ts b/typings/lib/core/SessionBuilder.d.ts index 152075b5..00131e3f 100644 --- a/typings/lib/core/SessionBuilder.d.ts +++ b/typings/lib/core/SessionBuilder.d.ts @@ -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; /** @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"); diff --git a/typings/lib/deciphers/NToken.d.ts b/typings/lib/deciphers/NToken.d.ts index 6068d357..ad695b97 100644 --- a/typings/lib/deciphers/NToken.d.ts +++ b/typings/lib/deciphers/NToken.d.ts @@ -5,6 +5,7 @@ declare class NToken { raw_code: any; /** * Solves throttling challange by transforming the n token. + * * @returns {string} */ transform(): string; diff --git a/typings/lib/deciphers/Signature.d.ts b/typings/lib/deciphers/Signature.d.ts index e86028b5..699d9629 100644 --- a/typings/lib/deciphers/Signature.d.ts +++ b/typings/lib/deciphers/Signature.d.ts @@ -6,6 +6,7 @@ declare class Signature { decipherBeta(): any; /** * Deciphers signature. + * * @returns {string} */ decipher(): string; diff --git a/typings/lib/parser/contents/index.d.ts b/typings/lib/parser/contents/index.d.ts index 2009cb6c..300bafa2 100644 --- a/typings/lib/parser/contents/index.d.ts +++ b/typings/lib/parser/contents/index.d.ts @@ -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; diff --git a/typings/lib/parser/youtube/History.d.ts b/typings/lib/parser/youtube/History.d.ts index 10dd1e02..b2dcb74f 100644 --- a/typings/lib/parser/youtube/History.d.ts +++ b/typings/lib/parser/youtube/History.d.ts @@ -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; diff --git a/typings/lib/parser/youtube/Search.d.ts b/typings/lib/parser/youtube/Search.d.ts index a7a4031b..8bbc635a 100644 --- a/typings/lib/parser/youtube/Search.d.ts +++ b/typings/lib/parser/youtube/Search.d.ts @@ -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.} */ getContinuation(): Promise; /** * 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.} */ - selectRefinementCard(card: SearchRefinementCard | string): Promise; + selectRefinementCard(card: import('../contents/classes/SearchRefinementCard') | string): Promise; /** @type {boolean} */ get has_continuation(): boolean; /** @type {string[]} */ diff --git a/typings/lib/parser/youtube/VideoInfo.d.ts b/typings/lib/parser/youtube/VideoInfo.d.ts index 87c64dcb..a624ec44 100644 --- a/typings/lib/parser/youtube/VideoInfo.d.ts +++ b/typings/lib/parser/youtube/VideoInfo.d.ts @@ -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.} */ selectFilter(name: string): Promise; + /** @typedef {import('../contents/classes/CompactVideo')} CompactVideo */ + /** @typedef {import('../contents/classes/CompactMix')} CompactMix */ /** * Retrieves watch next feed continuation. + * * @returns {Promise.} */ - getWatchNextContinuation(): Promise; + getWatchNextContinuation(): Promise; /** * 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.} */ like(): Promise<{ success: boolean; @@ -95,7 +101,8 @@ declare class VideoInfo { }>; /** * Dislikes the video. - * @returns {Response} + * + * @returns {Promise.} */ dislike(): Promise<{ success: boolean; @@ -104,7 +111,8 @@ declare class VideoInfo { }>; /** * Removes like/dislike. - * @returns {Response} + * + * @returns {Promise.} */ 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; diff --git a/typings/lib/parser/ytmusic/HomeFeed.d.ts b/typings/lib/parser/ytmusic/HomeFeed.d.ts index 595ad8cf..a052c7ec 100644 --- a/typings/lib/parser/ytmusic/HomeFeed.d.ts +++ b/typings/lib/parser/ytmusic/HomeFeed.d.ts @@ -15,6 +15,7 @@ declare class HomeFeed { }; /** * Retrieves home feed continuation. + * * @returns {Promise.} */ getContinuation(): Promise; diff --git a/typings/lib/parser/ytmusic/Search.d.ts b/typings/lib/parser/ytmusic/Search.d.ts index e7df391e..678e268b 100644 --- a/typings/lib/parser/ytmusic/Search.d.ts +++ b/typings/lib/parser/ytmusic/Search.d.ts @@ -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.} */ getContinuation(): Promise; /** - * Applies given filter to the search. - * @param {string} name - * @returns {Promise.} - */ + * Applies given filter to the search. + * + * @param {string} name + * @returns {Promise.} + */ selectFilter(name: string): Promise; /** @type {boolean} */ get has_continuation(): boolean; diff --git a/typings/lib/proto/index.d.ts b/typings/lib/proto/index.d.ts index 01d46f4a..b5524d34 100644 --- a/typings/lib/proto/index.d.ts +++ b/typings/lib/proto/index.d.ts @@ -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; diff --git a/typings/lib/utils/Request.d.ts b/typings/lib/utils/Request.d.ts index d848246f..9ca6c36c 100644 --- a/typings/lib/utils/Request.d.ts +++ b/typings/lib/utils/Request.d.ts @@ -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; } diff --git a/typings/lib/utils/Utils.d.ts b/typings/lib/utils/Utils.d.ts index 0f453dcd..2e4964f3 100644 --- a/typings/lib/utils/Utils.d.ts +++ b/typings/lib/utils/Utils.d.ts @@ -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.} + * @returns {object|object[]} */ -export function findNode(obj: object, key: string, target: string, depth: number, safe?: boolean): object | Array; +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; /**