chore: update type definitions

This commit is contained in:
LuanRT
2022-05-09 18:47:17 -03:00
parent a08580eeee
commit ffa243bc07
5 changed files with 120 additions and 72 deletions

View File

@@ -52,84 +52,92 @@ declare class Innertube {
/**
* Notify about activity from the channels you're subscribed to.
*
* @param {boolean} new_value
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @param {boolean} new_value - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setSubscriptions: (new_value: boolean) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Recommended content notifications.
*
* @param {boolean} new_value
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @param {boolean} new_value - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setRecommendedVideos: (new_value: boolean) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Notify about activity on your channel.
*
* @param {boolean} new_value
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @param {boolean} new_value - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setChannelActivity: (new_value: boolean) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Notify about replies to your comments.
*
* @param {boolean} new_value
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @param {boolean} new_value - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setCommentReplies: (new_value: boolean) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Notify when others mention your channel.
*
* @param {boolean} new_value
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @param {boolean} new_value - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setMentions: (new_value: boolean) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Notify when others share your content on their channels.
*
* @param {boolean} new_value
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @param {boolean} new_value - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setSharedContent: (new_value: boolean) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
};
privacy: {
/**
* If set to true, your subscriptions won't be visible to others.
*
* @param {boolean} new_value
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @param {boolean} new_value - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setSubscriptionsPrivate: (new_value: boolean) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* If set to true, saved playlists won't appear on your channel.
*
* @param {boolean} new_value
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @param {boolean} new_value - ON | OFF
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setSavedPlaylistsPrivate: (new_value: boolean) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
};
};
@@ -139,42 +147,46 @@ declare class Innertube {
* Likes a given video.
*
* @param {string} video_id
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
like: (video_id: string) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Diskes a given video.
*
* @param {string} video_id
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
dislike: (video_id: string) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Removes a like/dislike.
*
* @param {string} video_id
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
removeLike: (video_id: string) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Posts a comment on a given video.
*
* @param {string} video_id
* @param {string} text
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
comment: (video_id: string, text: string) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Translates a given text using YouTube's comment translate feature.
@@ -185,34 +197,38 @@ declare class Innertube {
* @param {string} [args.video_id]
* @param {string} [args.comment_id]
*
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; translated_content: string; data: object; }>}
*/
translate: (text: string, target_language: string, args?: {
video_id?: string;
comment_id?: string;
}) => Promise<{
success: boolean;
status_code: string;
status_code: number;
translated_content: string;
data: object;
}>;
/**
* Subscribes to a given channel.
*
* @param {string} channel_id
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
subscribe: (channel_id: string) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Unsubscribes from a given channel.
*
* @param {string} channel_id
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
unsubscribe: (channel_id: string) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
/**
* Changes notification preferences for a given channel.
@@ -220,11 +236,12 @@ declare class Innertube {
*
* @param {string} channel_id
* @param {string} type PERSONALIZED | ALL | NONE
* @returns {Promise.<{ success: boolean; status_code: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; data: object; }>}
*/
setNotificationPreferences: (channel_id: string, type: string) => Promise<{
success: boolean;
status_code: string;
status_code: number;
data: object;
}>;
};
playlist: {
@@ -232,49 +249,54 @@ declare class Innertube {
* Creates a playlist.
*
* @param {string} title
* @param {string} video_ids
* @param {Array.<string>} video_ids
*
* @returns {Promise.<{ success: boolean; status_code: string; playlist_id: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>}
*/
create: (title: string, video_ids: string) => Promise<{
create: (title: string, video_ids: Array<string>) => Promise<{
success: boolean;
status_code: string;
status_code: number;
playlist_id: string;
data: object;
}>;
/**
* Deletes a given playlist.
*
* @param {string} playlist_id
* @returns {Promise.<{ success: boolean; status_code: string; playlist_id: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>}
*/
delete: (playlist_id: string) => Promise<{
success: boolean;
status_code: string;
status_code: number;
playlist_id: string;
data: object;
}>;
/**
* Adds an array of videos to a given playlist.
*
* @param {string} playlist_id
* @param {Array.<string>} video_ids
* @returns {Promise.<{ success: boolean; status_code: string; playlist_id: string; }>}
* @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>}
*/
addVideos: (playlist_id: string, video_ids: Array<string>) => Promise<{
success: boolean;
status_code: string;
status_code: number;
playlist_id: string;
data: object;
}>;
/**
* Removes videos from a given playlist.
*
* @param {string} playlist_id
* @param {Array.<string>} video_ids
* @returns {Promise.<{ success: boolean; status_code: string; playlist_id: string; }>}
*
* @returns {Promise.<{ success: boolean; status_code: number; playlist_id: string; data: object; }>}
*/
removeVideos: (playlist_id: string, video_ids: Array<string>) => Promise<{
success: boolean;
status_code: string;
status_code: number;
playlist_id: string;
data: object;
}>;
};
/**
@@ -317,17 +339,17 @@ declare class Innertube {
* @param {string} query - search query.
* @param {object} options - search options.
* @param {string} options.client - client used to perform the search, can be: `YTMUSIC` or `YOUTUBE`.
* @param {string} options.period - filter videos uploaded within a period, can be: any | hour | day | week | month | year
* @param {string} options.order - filter results by order, can be: relevance | rating | age | views
* @param {string} options.period - filter videos uploaded within a period, can be: any | hour | day | week | month | year
* @param {string} options.duration - filter video results by duration, can be: any | short | long
*
* @returns {Promise.<{ query: string; corrected_query: string; estimated_results: number; videos: [] } |
* { results: { songs: []; videos: []; albums: []; community_playlists: [] } }>}
*/
search(query: string, options?: {
search(query: string, options: {
client: string;
period: string;
order: string;
period: string;
duration: string;
}): Promise<{
query: string;
@@ -513,7 +535,7 @@ declare class Innertube {
* An alternative to {@link download}.
* Returns deciphered streaming data.
*
* @param {string} id - video id
* @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
@@ -521,7 +543,7 @@ declare class Innertube {
*
* @returns {Promise.<{ selected_format: {}; formats: [] }>}
*/
getStreamingData(id: string, options?: {
getStreamingData(video_id: string, options?: {
quality: string;
type: string;
format: string;
@@ -532,7 +554,7 @@ declare class Innertube {
/**
* Downloads a given video. If you only need the direct download link take a look at {@link getStreamingData}.
*
* @param {string} id - video id
* @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
@@ -540,12 +562,14 @@ declare class Innertube {
*
* @return {Stream.PassThrough}
*/
download(id: string, options?: {
download(video_id: string, options?: {
quality?: string;
type?: string;
format?: string;
}): Stream.PassThrough;
#private;
}
import EventEmitter = require("events");
import Request = require("./utils/Request");
import Actions = require("./core/Actions");
import Stream = require("stream");

View File

@@ -1,5 +1,5 @@
export = Livechat;
declare class Livechat {
declare class Livechat extends EventEmitter {
constructor(session: any, token: any, channel_id: any, video_id: any);
ctoken: any;
session: any;
@@ -10,7 +10,7 @@ declare class Livechat {
poll_intervals_ms: number;
running: boolean;
metadata_ctoken: any;
livechat_poller: any;
livechat_poller: NodeJS.Timeout;
sendMessage(text: any): Promise<any>;
/**
* Blocks a user.
@@ -21,3 +21,4 @@ declare class Livechat {
stop(): void;
#private;
}
import EventEmitter = require("events");

View File

@@ -8,7 +8,6 @@ declare class OAuth {
init(auth_info: any): Promise<void>;
client_id: string;
client_secret: string;
refresh_interval: any;
/**
* Refreshes the access token if necessary.
* @returns {Promise.<void>}

View File

@@ -6,6 +6,6 @@ declare class Player {
get sts(): any;
get ntoken_decipher(): any;
get signature_decipher(): any;
isCached(): any;
isCached(): boolean;
#private;
}

View File

@@ -17,13 +17,15 @@ export class NoStreamingDataError extends InnertubeError {
/**
* Utility to help access deep properties of an object.
*
* @param {object} obj - The object.
* @param {string} key - Key of the property being accessed.
* @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.
* @param {object} obj - the object.
* @param {string} key - key of the property being accessed.
* @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>}
*/
export function findNode(obj: object, key: string, target: string, depth: number, safe?: boolean): any;
export function findNode(obj: object, key: string, target: string, depth: number, safe?: boolean): object | Array<any>;
/**
* Returns a random user agent.
*
@@ -38,13 +40,21 @@ export function getRandomUserAgent(type: string): object;
* @returns {string}
*/
export function generateSidAuth(sid: string): string;
export function generateRandomString(length: any): string;
/**
* Gets a string between two delimiters.
* Generates a random string with a given length.
*
* @param {string} data - The data.
* @param {string} start_string - Start string.
* @param {string} end_string - End string.
* @param {number} length
* @returns {string}
*/
export function generateRandomString(length: number): string;
/**
* Finds a string between two delimiters.
*
* @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;
/**
@@ -54,6 +64,20 @@ export function getStringBetweenStrings(data: string, start_string: string, end_
* @returns {string}
*/
export function camelToSnake(string: string): string;
/**
* Checks if a given client is valid.
*
* @param {string} client
* @returns {boolean}
*/
export function isValidClient(client: string): boolean;
/**
* Throws an error if given parameters are undefined.
*
* @param {object} params
* @returns
*/
export function throwIfMissing(params: object): void;
/**
* Converts time (h:m:s) to seconds.
*