From d54fc282ade090e580ce20fb32e4aa693898d7f2 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Thu, 16 Jun 2022 14:59:58 -0300 Subject: [PATCH] chore: remove a few deprecated methods --- lib/Innertube.js | 81 ++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 58 deletions(-) diff --git a/lib/Innertube.js b/lib/Innertube.js index 7be445d0..8ab7e93e 100644 --- a/lib/Innertube.js +++ b/lib/Innertube.js @@ -132,28 +132,6 @@ class Innertube { response.success && (this.logged_in = false); return response; } - - /** - * Retrieves search suggestions for a given query. - * - * @param {string} query - the search query. - * @param {object} [options] - search options. - * @param {string} [options.client='YOUTUBE'] - client used to retrieve search suggestions, can be: `YOUTUBE` or `YTMUSIC`. - * @returns {Promise.<{ query: string, results: string[] }>} - */ - async getSearchSuggestions(query, options = { client: 'YOUTUBE' }) { - Utils.throwIfMissing({ query }); - - const response = await this.actions.getSearchSuggestions(options.client, query); - if (options.client === 'YTMUSIC' && !response.data.contents) return []; - - const suggestions = new Parser(this, response.data, { - client: options.client, - data_type: 'SEARCH_SUGGESTIONS' - }).parse(); - - return suggestions; - } /** * Retrieves video info. @@ -204,7 +182,29 @@ class Innertube { const response = await this.actions.search({ query, filters }); return new Search(this.actions, response.data); } + + /** + * Retrieves search suggestions for a given query. + * + * @param {string} query - the search query. + * @param {object} [options] - search options. + * @param {string} [options.client='YOUTUBE'] - client used to retrieve search suggestions, can be: `YOUTUBE` or `YTMUSIC`. + * @returns {Promise.<{ query: string, results: string[] }>} + */ + async getSearchSuggestions(query, options = { client: 'YOUTUBE' }) { + Utils.throwIfMissing({ query }); + + const response = await this.actions.getSearchSuggestions(options.client, query); + if (options.client === 'YTMUSIC' && !response.data.contents) return []; + const suggestions = new Parser(this, response.data, { + client: options.client, + data_type: 'SEARCH_SUGGESTIONS' + }).parse(); + + return suggestions; + } + /** * Retrieves video info. * @@ -282,7 +282,7 @@ class Innertube { /** * Retrieves watch history. - * + * * @returns {Promise.<{ items: Array.<{ date: string, videos: object[] }>}>} */ async getHistory() { @@ -319,21 +319,6 @@ class Innertube { return new TabbedFeed(this.actions, response.data); } - - /** - * @todo finish this - * WIP - */ - async getLibrary() { - const response = await this.actions.browse('FElibrary'); - - const library = new Parser(this, response.data, { - client: 'YOUTUBE', - data_type: 'LIBRARY' - }).parse(); - - return library; - } /** * Retrieves subscriptions feed. @@ -377,25 +362,6 @@ class Innertube { return response.data.unseenCount; } - /** - * Retrieves lyrics for a given song if available. - * - * @param {string} video_id - * @returns {Promise.} - */ - async getLyrics(video_id) { - Utils.throwIfMissing({ video_id }); - - const continuation = await this.actions.next({ video_id: video_id, client: 'YTMUSIC' }); - const lyrics_tab = Utils.findNode(continuation, 'contents', 'Lyrics', 8, false); - - const response = await this.actions.browse(lyrics_tab.endpoint?.browseEndpoint.browseId, { client: 'YTMUSIC' }); - if (!response.data?.contents?.sectionListRenderer) throw new Utils.UnavailableContentError('Lyrics not available', { video_id }); - - const lyrics = Utils.findNode(response.data, 'contents', 'runs', 6, false); - return lyrics.runs[0].text; - } - /** * Retrieves the contents of a given playlist. * @@ -428,7 +394,6 @@ class Innertube { */ async getStreamingData(video_id, options = {}) { const info = await this.getBasicInfo(video_id); - return info.chooseFormat(options); }