diff --git a/docs/YTMusic.html b/docs/YTMusic.html index 364a2bd..a48e524 100644 --- a/docs/YTMusic.html +++ b/docs/YTMusic.html @@ -83,7 +83,7 @@ @@ -457,7 +457,7 @@

diff --git a/docs/index.html b/docs/index.html index 4513a4c..8db053b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -83,7 +83,7 @@ @@ -121,12 +121,11 @@ Latest release Commits since latest release

ytmusicapiJS: Unofficial API for YouTube Music

-

ytmusicapiJS is a JS/TS implementation of the Python 3 library ytmusicapi

+

ytmusicapiJS is a TypeScript implementation of the Python 3 library ytmusicapi

It emulates YouTube Music web client requests using the user's cookie data for authentication.

This library is intended to carry the same functionality as the library it is inspired by. As such, unless the need becomes great enough for a specific feature in this library, I recommend all API specific changes be directed to ytmusicapi instead.

Features

See API here https://codyduong.github.io/ytmusicapiJS/

-

More comprehensive list and explanation here in the original repo or check out the docs for the original repo

Feature Parity

✅ - Implemented

@@ -277,7 +276,7 @@

Acknowledgements

diff --git a/docs/index.js.html b/docs/index.js.html index 28e14ff..91e2176 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -83,7 +83,7 @@ @@ -165,7 +165,7 @@

diff --git a/docs/mixins_browsing.js.html b/docs/mixins_browsing.js.html index aba703c..e237f2a 100644 --- a/docs/mixins_browsing.js.html +++ b/docs/mixins_browsing.js.html @@ -83,7 +83,7 @@ @@ -134,78 +134,78 @@

* @param {number} [limit=3] Number of rows to return * @returns List of objects keyed with 'title' text and 'contents' array * @example - * [ - * { - * "title": "Your morning music", - * "contents": [ - * { //album result - * "title": "Sentiment", - * "year": "Said The Sky", - * "browseId": "MPREb_QtqXtd2xZMR", - * "thumbnails": [...] - * }, - * { //playlist result - * "title": "r/EDM top submissions 01/28/2022", - * "playlistId": "PLz7-xrYmULdSLRZGk-6GKUtaBZcgQNwel", - * "thumbnails": [...], - * "description": "redditEDM • 161 songs", - * "count": "161", - * "author": [ - * { - * "name": "redditEDM", - * "id": "UCaTrZ9tPiIGHrkCe5bxOGwA" - * } - * ] - * } - * ] - * }, - * { - * "title": "Your favorites", - * "contents": [ - * { //artist result - * "title": "Chill Satellite", - * "browseId": "UCrPLFBWdOroD57bkqPbZJog", - * "subscribers": "374", - * "thumbnails": [...] - * } - * { //album result - * "title": "Dragon", - * "year": "Two Steps From Hell", - * "browseId": "MPREb_M9aDqLRbSeg", - * "thumbnails": [...] - * } - * ] - * }, - * { - * "title": "Quick picks", - * "contents": [ - * { //song quick pick - * "title": "Gravity", - * "videoId": "EludZd6lfts", - * "artists": [{ - * "name": "yetep", - * "id": "UCSW0r7dClqCoCvQeqXiZBlg" - * }], - * "thumbnails": [...], - * "album": { - * "title": "Gravity", - * "browseId": "MPREb_D6bICFcuuRY" - * } - * }, - * { //video quick pick - * "title": "Gryffin & Illenium (feat. Daya) - Feel Good (L3V3LS Remix)", - * "videoId": "bR5l0hJDnX8", - * "artists": [ - * { - * "name": "L3V3LS", - * "id": "UCCVNihbOdkOWw_-ajIYhAbQ" - * } - * ], - * "thumbnails": [...], - * "views": "10M" - * } - * ] - * } + * [ + * { + * "title": "Your morning music", + * "contents": [ + * { //album result + * "title": "Sentiment", + * "year": "Said The Sky", + * "browseId": "MPREb_QtqXtd2xZMR", + * "thumbnails": [...] + * }, + * { //playlist result + * "title": "r/EDM top submissions 01/28/2022", + * "playlistId": "PLz7-xrYmULdSLRZGk-6GKUtaBZcgQNwel", + * "thumbnails": [...], + * "description": "redditEDM • 161 songs", + * "count": "161", + * "author": [ + * { + * "name": "redditEDM", + * "id": "UCaTrZ9tPiIGHrkCe5bxOGwA" + * } + * ] + * } + * ] + * }, + * { + * "title": "Your favorites", + * "contents": [ + * { //artist result + * "title": "Chill Satellite", + * "browseId": "UCrPLFBWdOroD57bkqPbZJog", + * "subscribers": "374", + * "thumbnails": [...] + * } + * { //album result + * "title": "Dragon", + * "year": "Two Steps From Hell", + * "browseId": "MPREb_M9aDqLRbSeg", + * "thumbnails": [...] + * } + * ] + * }, + * { + * "title": "Quick picks", + * "contents": [ + * { //song quick pick + * "title": "Gravity", + * "videoId": "EludZd6lfts", + * "artists": [{ + * "name": "yetep", + * "id": "UCSW0r7dClqCoCvQeqXiZBlg" + * }], + * "thumbnails": [...], + * "album": { + * "title": "Gravity", + * "browseId": "MPREb_D6bICFcuuRY" + * } + * }, + * { //video quick pick + * "title": "Gryffin & Illenium (feat. Daya) - Feel Good (L3V3LS Remix)", + * "videoId": "bR5l0hJDnX8", + * "artists": [ + * { + * "name": "L3V3LS", + * "id": "UCCVNihbOdkOWw_-ajIYhAbQ" + * } + * ], + * "thumbnails": [...], + * "views": "10M" + * } + * ] + * } * ] */ async getHome(limit = 3) { @@ -228,108 +228,6 @@

} return home; } - /** - * Search YouTube music. - * Returns results within the provided category. - * @param {string} query Query string, i.e. 'Oasis Wonderwall' - * @param {options} [options=] - * @param {'songs'|'videos'|'albums'|'artists'|'playlists'|'community_playlists'|'featured_playlists'} [options.filter=] Filter for item types. - * @default: Default search, including all types of items. - * @param {'libary'|'uploads'} [options.scope=] Search scope. - * @default: Search the public YouTube Music catalogue. - * @param {number} [options.limit=20] Number of search results to return - * @param {boolean} [ignoreSpelling=false] Whether to ignore YTM spelling suggestions. - * If true, the exact search term will be searched for, and will not be corrected. - * This does not have any effect when the filter is set to ``uploads``. - * Default: false, will use YTM's default behavior of autocorrecting the search. - * @return List of results depending on filter. - * resultType specifies the type of item (important for default search). - * albums, artists and playlists additionally contain a browseId, corresponding to - * albumId, channelId and playlistId (browseId=``VL``+playlistId) - * @example <caption> list for default search with one result per resultType for brevity. Normally - * there are 3 results per resultType and an additional ``thumbnails`` key. </caption> - * [ - * { - * "category": "Top result", - * "resultType": "video", - * "videoId": "vU05Eksc_iM", - * "title": "Wonderwall", - * "artists": [ - * { - * "name": "Oasis", - * "id": "UCmMUZbaYdNH0bEd1PAlAqsA" - * } - * ], - * "views": "1.4M", - * "duration": "4:38", - * "duration_seconds": 278 - * }, - * { - * "category": "Songs", - * "resultType": "song", - * "videoId": "ZrOKjDZOtkA", - * "title": "Wonderwall", - * "artists": [ - * { - * "name": "Oasis", - * "id": "UCmMUZbaYdNH0bEd1PAlAqsA" - * } - * ], - * "album": { - * "name": "(What's The Story) Morning Glory? (Remastered)", - * "id": "MPREb_9nqEki4ZDpp" - * }, - * "duration": "4:19", - * "duration_seconds": 259 - * "isExplicit": false, - * "feedbackTokens": { - * "add": null, - * "remove": null - * } - * }, - * { - * "category": "Albums", - * "resultType": "album", - * "browseId": "MPREb_9nqEki4ZDpp", - * "title": "(What's The Story) Morning Glory? (Remastered)", - * "type": "Album", - * "artist": "Oasis", - * "year": "1995", - * "isExplicit": false - * }, - * { - * "category": "Community playlists", - * "resultType": "playlist", - * "browseId": "VLPLK1PkWQlWtnNfovRdGWpKffO1Wdi2kvDx", - * "title": "Wonderwall - Oasis", - * "author": "Tate Henderson", - * "itemCount": "174" - * }, - * { - * "category": "Videos", - * "resultType": "video", - * "videoId": "bx1Bh8ZvH84", - * "title": "Wonderwall", - * "artists": [ - * { - * "name": "Oasis", - * "id": "UCmMUZbaYdNH0bEd1PAlAqsA" - * } - * ], - * "views": "386M", - * "duration": "4:38", - * "duration_seconds": 278 - * }, - * { - * "category": "Artists", - * "resultType": "artist", - * "browseId": "UCmMUZbaYdNH0bEd1PAlAqsA", - * "artist": "Oasis", - * "shuffleId": "RDAOkjHYJjL1a3xspEyVkhHAsg", - * "radioId": "RDEMkjHYJjL1a3xspEyVkhHAsg" - * } - * ] - */ async search(query, options) { const _options = options ?? {}; let { filter } = _options; @@ -542,6 +440,7 @@

...NAVIGATION_BROWSE_ID, ]); } + //@ts-expect-error: We're overriding the shape here artist['songs']['results'] = parsePlaylistItems(musicShelf['contents']); } artist = { ...artist, ...this.parser.parseArtistContents(results) }; @@ -613,15 +512,15 @@

const endpoint = 'browse'; const body = { browseId: channelId }; const response = await this._sendRequest(endpoint, body); - let user = { + const results = nav(response, [...SINGLE_COLUMN_TAB, ...SECTION_LIST]); + const user = { name: nav(response, [ 'header', 'musicVisualHeaderRenderer', ...TITLE_TEXT, ]), + ...this.parser.parseArtistContents(results), }; - const results = nav(response, [...SINGLE_COLUMN_TAB, ...SECTION_LIST]); - user = { ...user, ...this.parser.parseArtistContents(results) }; return user; } /** @@ -711,13 +610,17 @@

const body = { browseId: browseId }; const endpoint = 'browse'; const response = await this._sendRequest(endpoint, body); - const album = parseAlbumHeader(response); const results = nav(response, [ ...SINGLE_COLUMN_TAB, ...SECTION_LIST_ITEM, ...MUSIC_SHELF, ]); - album['tracks'] = parsePlaylistItems(results['contents']); + const album = { + ...parseAlbumHeader(response), + //@ts-expect-error: We'll swap this out proper later. + tracks: parsePlaylistItems(results['contents']), + duration_seconds: undefined, + }; album['duration_seconds'] = helpers.sumTotalDuration(album); for (const [i, _track] of album['tracks'].entries()) { album['tracks'][i]['album'] = album['title']; @@ -729,7 +632,7 @@

* Returns metadata and streaming information about a song or video. * @param {string} [videoId] Video id * @param {number} [signatureTimestamp] Provide the current YouTube signatureTimestamp. - If not provided a default value will be used, which might result in invalid streaming URLs + * If not provided a default value will be used, which might result in invalid streaming URLs * @return Object with song metadata * @example * { @@ -983,7 +886,7 @@

diff --git a/docs/mixins_explore.js.html b/docs/mixins_explore.js.html index 3301fa7..76ab9a9 100644 --- a/docs/mixins_explore.js.html +++ b/docs/mixins_explore.js.html @@ -83,7 +83,7 @@ @@ -124,41 +124,41 @@

* * @return Object of sections and categories * @example - { - 'For you': [ - { - 'params': 'ggMPOg1uX1ZwN0pHT2NBT1Fk', - 'title': '1980s' - }, - { - 'params': 'ggMPOg1uXzZQbDB5eThLRTQ3', - 'title': 'Feel Good' - }, - ... - ], - 'Genres': [ - { - 'params': 'ggMPOg1uXzVLbmZnaWI4STNs', - 'title': 'Dance & Electronic' - }, - { - 'params': 'ggMPOg1uX3NjZllsNGVEMkZo', - 'title': 'Decades' - }, - ... - ], - 'Moods & moments': [ - { - 'params': 'ggMPOg1uXzVuc0dnZlhpV3Ba', - 'title': 'Chill' - }, - { - 'params': 'ggMPOg1uX2ozUHlwbWM3ajNq', - 'title': 'Commute' - }, - ... - ], - } + * { + * 'For you': [ + * { + * 'params': 'ggMPOg1uX1ZwN0pHT2NBT1Fk', + * 'title': '1980s' + * }, + * { + * 'params': 'ggMPOg1uXzZQbDB5eThLRTQ3', + * 'title': 'Feel Good' + * }, + * ... + * ], + * 'Genres': [ + * { + * 'params': 'ggMPOg1uXzVLbmZnaWI4STNs', + * 'title': 'Dance & Electronic' + * }, + * { + * 'params': 'ggMPOg1uX3NjZllsNGVEMkZo', + * 'title': 'Decades' + * }, + * ... + * ], + * 'Moods & moments': [ + * { + * 'params': 'ggMPOg1uXzVuc0dnZlhpV3Ba', + * 'title': 'Chill' + * }, + * { + * 'params': 'ggMPOg1uX2ozUHlwbWM3ajNq', + * 'title': 'Commute' + * }, + * ... + * ], + * } */ async getMoodCategories() { const sections = {}; @@ -190,7 +190,7 @@

* @returns List of playlists in the format of `getLibraryPlaylists` */ async getMoodPlaylists(params) { - const playlists = []; + let playlists = []; const response = await this._sendRequest('browse', { browseId: 'FEmusic_moods_and_genres_category', params: params, @@ -208,7 +208,10 @@

} if (path.length) { const results = nav(section, path); - playlists.push(parseContentList(results, parsePlaylist)); + playlists = [ + ...playlists, + ...parseContentList(results, parsePlaylist), + ]; } } return playlists; @@ -219,93 +222,93 @@

* @param {string} [country = 'ZZ'] ISO 3166-1 Alpha-2 country code. * @returns Dictionary containing chart songs (only if authenticated), chart videos, chart artists and trending videos. * @example - { - "countries": { - "selected": { - "text": "United States" - }, - "options": ["DE", - "ZZ", - "ZW"] - }, - "songs": { - "playlist": "VLPL4fGSI1pDJn6O1LS0XSdF3RyO0Rq_LDeI", - "items": [ - { - "title": "Outside (Better Days)", - "videoId": "oT79YlRtXDg", - "artists": [ - { - "name": "MO3", - "id": "UCdFt4Cvhr7Okaxo6hZg5K8g" - }, - { - "name": "OG Bobby Billions", - "id": "UCLusb4T2tW3gOpJS1fJ-A9g" - } - ], - "thumbnails": [...], - "isExplicit": true, - "album": { - "name": "Outside (Better Days)", - "id": "MPREb_fX4Yv8frUNv" - }, - "rank": "1", - "trend": "up" - } - ] - }, - "videos": { - "playlist": "VLPL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc", - "items": [ - { - "title": "EVERY CHANCE I GET (Official Music Video) (feat. Lil Baby & Lil Durk)", - "videoId": "BTivsHlVcGU", - "playlistId": "PL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc", - "thumbnails": [], - "views": "46M" - } - ] - }, - "artists": { - "playlist": null, - "items": [ - { - "title": "YoungBoy Never Broke Again", - "browseId": "UCR28YDxjDE3ogQROaNdnRbQ", - "subscribers": "9.62M", - "thumbnails": [], - "rank": "1", - "trend": "neutral" - } - ] - }, - "genres": [ - { - "title": "Top 50 Pop Music Videos United States", - "playlistId": "PL4fGSI1pDJn77aK7sAW2AT0oOzo5inWY8", - "thumbnails": [] - } - ], - "trending": { - "playlist": "VLPLrEnWoR732-DtKgaDdnPkezM_nDidBU9H", - "items": [ - { - "title": "Permission to Dance", - "videoId": "CuklIb9d3fI", - "playlistId": "PLrEnWoR732-DtKgaDdnPkezM_nDidBU9H", - "artists": [ - { - "name": "BTS", - "id": "UC9vrvNSL3xcWGSkV86REBSg" - } - ], - "thumbnails": [], - "views": "108M" - } - ] - } - } + * { + * "countries": { + * "selected": { + * "text": "United States" + * }, + * "options": ["DE", + * "ZZ", + * "ZW"] + * }, + * "songs": { + * "playlist": "VLPL4fGSI1pDJn6O1LS0XSdF3RyO0Rq_LDeI", + * "items": [ + * { + * "title": "Outside (Better Days)", + * "videoId": "oT79YlRtXDg", + * "artists": [ + * { + * "name": "MO3", + * "id": "UCdFt4Cvhr7Okaxo6hZg5K8g" + * }, + * { + * "name": "OG Bobby Billions", + * "id": "UCLusb4T2tW3gOpJS1fJ-A9g" + * } + * ], + * "thumbnails": [...], + * "isExplicit": true, + * "album": { + * "name": "Outside (Better Days)", + * "id": "MPREb_fX4Yv8frUNv" + * }, + * "rank": "1", + * "trend": "up" + * } + * ] + * }, + * "videos": { + * "playlist": "VLPL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc", + * "items": [ + * { + * "title": "EVERY CHANCE I GET (Official Music Video) (feat. Lil Baby & Lil Durk)", + * "videoId": "BTivsHlVcGU", + * "playlistId": "PL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc", + * "thumbnails": [], + * "views": "46M" + * } + * ] + * }, + * "artists": { + * "playlist": null, + * "items": [ + * { + * "title": "YoungBoy Never Broke Again", + * "browseId": "UCR28YDxjDE3ogQROaNdnRbQ", + * "subscribers": "9.62M", + * "thumbnails": [], + * "rank": "1", + * "trend": "neutral" + * } + * ] + * }, + * "genres": [ + * { + * "title": "Top 50 Pop Music Videos United States", + * "playlistId": "PL4fGSI1pDJn77aK7sAW2AT0oOzo5inWY8", + * "thumbnails": [] + * } + * ], + * "trending": { + * "playlist": "VLPLrEnWoR732-DtKgaDdnPkezM_nDidBU9H", + * "items": [ + * { + * "title": "Permission to Dance", + * "videoId": "CuklIb9d3fI", + * "playlistId": "PLrEnWoR732-DtKgaDdnPkezM_nDidBU9H", + * "artists": [ + * { + * "name": "BTS", + * "id": "UC9vrvNSL3xcWGSkV86REBSg" + * } + * ], + * "thumbnails": [], + * "views": "108M" + * } + * ] + * } + * } */ async getCharts(country = 'ZZ') { const body = { browseId: 'FEmusic_charts' }; @@ -315,7 +318,9 @@

const endpoint = 'browse'; const response = await this._sendRequest(endpoint, body); const results = nav(response, [...SINGLE_COLUMN_TAB, ...SECTION_LIST]); - const charts = { countries: {} }; + const charts = { + countries: {}, + }; const menu = nav(results[0], [ ...MUSIC_SHELF, 'subheaders', @@ -347,6 +352,7 @@

return parseContentList(nav(results[i + (hasSongs ? 1 : 0)], CAROUSEL_CONTENTS, true), parseFunc, key).filter((x) => x); }; for (const [i, c] of chartsCategories.entries()) { + //@ts-expect-error, we'll set the items later... charts[c] = { playlist: nav(results[1 + i], [...CAROUSEL, ...CAROUSEL_TITLE, ...NAVIGATION_BROWSE_ID], true), }; @@ -362,6 +368,7 @@

charts['videos']['items'] = parseChart(1, parseVideo, MTRIR); charts['artists']['items'] = parseChart(2, parseChartArtist, MRLIR); if (hasGenres) { + //@ts-expect-error: TS didn't detect this control flow discrimination... charts['genres'] = parseChart(3, parsePlaylist, MTRIR); } if (hasTrending) { @@ -396,7 +403,7 @@

diff --git a/docs/mixins_library.js.html b/docs/mixins_library.js.html index 078653b..c431347 100644 --- a/docs/mixins_library.js.html +++ b/docs/mixins_library.js.html @@ -83,7 +83,7 @@ @@ -143,6 +143,7 @@

let playlists = parseContentList(results['items'].slice(1), parsePlaylist); if ('continuations' in results) { const requestFunc = async (additionalParams) => await this._sendRequest(endpoint, body, additionalParams); + // eslint-disable-next-line @typescript-eslint/explicit-function-return-type const parseFunc = (contents) => parseContentList(contents, parsePlaylist); playlists = [ ...playlists, @@ -419,7 +420,7 @@

diff --git a/docs/mixins_playlists.js.html b/docs/mixins_playlists.js.html index 06d4714..d2e45ed 100644 --- a/docs/mixins_playlists.js.html +++ b/docs/mixins_playlists.js.html @@ -83,7 +83,7 @@ @@ -159,8 +159,8 @@

* "isAvailable": True, * "isExplicit": False, * "feedbackTokens": { - * "add": "AB9zfpJxtvrU...", - * "remove": "AB9zfpKTyZ..." + * "add": "AB9zfpJxtvrU...", + * "remove": "AB9zfpKTyZ..." * } * ] * } @@ -177,7 +177,9 @@

...SECTION_LIST_ITEM, 'musicPlaylistShelfRenderer', ]); - const playlist = { id: results['playlistId'] }; + const playlist = { + id: results['playlistId'], + }; const ownPlaylist = 'musicEditablePlaylistDetailHeaderRenderer' in response['header']; let header; if (!ownPlaylist) { @@ -486,7 +488,7 @@

diff --git a/docs/mixins_uploads.js.html b/docs/mixins_uploads.js.html index 191252f..e24db96 100644 --- a/docs/mixins_uploads.js.html +++ b/docs/mixins_uploads.js.html @@ -83,7 +83,7 @@ @@ -282,7 +282,7 @@

*/ async uploadSong(filepath) { this._checkAuth(); - if (existsSync(filepath)) { + if (!existsSync(filepath)) { throw new Error('The provided file does not exist.'); } const supportedFiletypes = ['mp3', 'm4a', 'wma', 'flac', 'ogg']; @@ -294,11 +294,11 @@

let uploadUrl = `https://upload.youtube.com/upload/usermusic/http?authuser=${headers['x-goog-authuser']}`; const filesize = statSync(filepath).size; const body = 'filename=' + utf8.encode(basename(filepath)); - headers.pop('content-encoding', null); + delete headers['content-encoding']; headers['content-type'] = 'application/x-www-form-urlencoded;charset=utf-8'; headers['X-Goog-Upload-Command'] = 'start'; - headers['X-Goog-Upload-Header-Content-Length'] = String(filesize); + headers['X-Goog-Upload-Header-Content-Length'] = filesize; headers['X-Goog-Upload-Protocol'] = 'resumable'; const response = await axios.post(uploadUrl, body, { headers: headers, @@ -306,17 +306,19 @@

}); headers['X-Goog-Upload-Command'] = 'upload, finalize'; headers['X-Goog-Upload-Offset'] = '0'; - uploadUrl = response.headers['X-Goog-Upload-URL']; + uploadUrl = + response.headers['X-Goog-Upload-URL'] ?? + response.headers['x-goog-upload-url']; const data = readFileSync(filepath); - const response2 = axios.post(uploadUrl, data, { + const response2 = await axios.post(uploadUrl, data, { headers: headers, proxy: this.proxies, }); - if (response2.status_code == 200) { + if (response2.status == 200) { return 'STATUS_SUCCEEDED'; } else { - return response; + return response2; } } /** @@ -367,7 +369,7 @@

diff --git a/docs/mixins_watch.js.html b/docs/mixins_watch.js.html index 21ba946..c821ea2 100644 --- a/docs/mixins_watch.js.html +++ b/docs/mixins_watch.js.html @@ -83,7 +83,7 @@ @@ -301,7 +301,7 @@

diff --git a/docs/module-Browsing.html b/docs/module-Browsing.html index ba867a1..be21281 100644 --- a/docs/module-Browsing.html +++ b/docs/module-Browsing.html @@ -83,7 +83,7 @@ @@ -254,7 +254,7 @@

@@ -432,7 +432,7 @@

@@ -587,7 +587,7 @@

@@ -776,7 +776,7 @@

@@ -880,7 +880,7 @@

@@ -1112,7 +1112,7 @@

Example
-
[
   {
       "title": "Your morning music",
       "contents": [
           { //album result
               "title": "Sentiment",
               "year": "Said The Sky",
               "browseId": "MPREb_QtqXtd2xZMR",
               "thumbnails": [...]
           },
           { //playlist result
               "title": "r/EDM top submissions 01/28/2022",
               "playlistId": "PLz7-xrYmULdSLRZGk-6GKUtaBZcgQNwel",
               "thumbnails": [...],
               "description": "redditEDM • 161 songs",
               "count": "161",
               "author": [
                   {
                       "name": "redditEDM",
                       "id": "UCaTrZ9tPiIGHrkCe5bxOGwA"
                   }
               ]
           }
       ]
   },
   {
       "title": "Your favorites",
       "contents": [
           { //artist result
               "title": "Chill Satellite",
               "browseId": "UCrPLFBWdOroD57bkqPbZJog",
               "subscribers": "374",
               "thumbnails": [...]
           }
           { //album result
               "title": "Dragon",
               "year": "Two Steps From Hell",
               "browseId": "MPREb_M9aDqLRbSeg",
               "thumbnails": [...]
           }
       ]
   },
   {
       "title": "Quick picks",
       "contents": [
           { //song quick pick
               "title": "Gravity",
               "videoId": "EludZd6lfts",
               "artists": [{
                       "name": "yetep",
                       "id": "UCSW0r7dClqCoCvQeqXiZBlg"
                   }],
               "thumbnails": [...],
               "album": {
                   "title": "Gravity",
                   "browseId": "MPREb_D6bICFcuuRY"
               }
           },
           { //video quick pick
               "title": "Gryffin & Illenium (feat. Daya) - Feel Good (L3V3LS Remix)",
               "videoId": "bR5l0hJDnX8",
               "artists": [
                   {
                       "name": "L3V3LS",
                       "id": "UCCVNihbOdkOWw_-ajIYhAbQ"
                   }
               ],
               "thumbnails": [...],
               "views": "10M"
           }
       ]
   }
]
+
[
  {
    "title": "Your morning music",
    "contents": [
      { //album result
        "title": "Sentiment",
        "year": "Said The Sky",
        "browseId": "MPREb_QtqXtd2xZMR",
        "thumbnails": [...]
      },
      { //playlist result
        "title": "r/EDM top submissions 01/28/2022",
        "playlistId": "PLz7-xrYmULdSLRZGk-6GKUtaBZcgQNwel",
        "thumbnails": [...],
        "description": "redditEDM • 161 songs",
        "count": "161",
        "author": [
          {
            "name": "redditEDM",
            "id": "UCaTrZ9tPiIGHrkCe5bxOGwA"
          }
        ]
      }
    ]
  },
  {
    "title": "Your favorites",
    "contents": [
      { //artist result
        "title": "Chill Satellite",
        "browseId": "UCrPLFBWdOroD57bkqPbZJog",
        "subscribers": "374",
        "thumbnails": [...]
      }
      { //album result
        "title": "Dragon",
        "year": "Two Steps From Hell",
        "browseId": "MPREb_M9aDqLRbSeg",
        "thumbnails": [...]
      }
    ]
  },
  {
    "title": "Quick picks",
    "contents": [
      { //song quick pick
        "title": "Gravity",
        "videoId": "EludZd6lfts",
        "artists": [{
            "name": "yetep",
            "id": "UCSW0r7dClqCoCvQeqXiZBlg"
          }],
        "thumbnails": [...],
        "album": {
          "title": "Gravity",
          "browseId": "MPREb_D6bICFcuuRY"
        }
      },
      { //video quick pick
        "title": "Gryffin & Illenium (feat. Daya) - Feel Good (L3V3LS Remix)",
        "videoId": "bR5l0hJDnX8",
        "artists": [
          {
              "name": "L3V3LS",
              "id": "UCCVNihbOdkOWw_-ajIYhAbQ"
          }
        ],
        "thumbnails": [...],
        "views": "10M"
      }
    ]
  }
]
@@ -1228,7 +1228,7 @@

@@ -1389,7 +1389,7 @@

@@ -1544,8 +1544,7 @@

- Provide the current YouTube signatureTimestamp. - If not provided a default value will be used, which might result in invalid streaming URLs + Provide the current YouTube signatureTimestamp. If not provided a default value will be used, which might result in invalid streaming URLs @@ -1590,7 +1589,7 @@

@@ -1756,7 +1755,7 @@

@@ -1967,7 +1966,7 @@

@@ -2010,400 +2009,6 @@

- - - - -

- - - - - -
- Search YouTube music. Returns results within the provided category. -
- - - - - - - - - -
- Parameters: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
query - - -string - - - - - - - - - - - - Query string, i.e. 'Oasis Wonderwall'
options= - - -options - - - - - - <optional>
- - - - - -
- -
options.filter= - - -'songs' -| - -'videos' -| - -'albums' -| - -'artists' -| - -'playlists' -| - -'community_playlists' -| - -'featured_playlists' - - - - - - <optional>
- - - - - -
- - Filter for item types.
options.scope= - - -'libary' -| - -'uploads' - - - - - - <optional>
- - - - - -
- - Search scope.
options.limit - - -number - - - - - - <optional>
- - - - - -
- - 20 - - Number of search results to return
ignoreSpelling - - -boolean - - - - - - <optional>
- - - - - -
- - false - - Whether to ignore YTM spelling suggestions. If true, the exact search term will be searched for, and will not be corrected. This does not have any effect when the filter is set to ``uploads``. Default: false, will use YTM's default behavior of autocorrecting the search.
- -
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
Source:
-
-
- - - - - - - -
- - - - - - - - - - - - - - - -
- Returns: - - -
- List of results depending on filter. resultType specifies the type of item (important for default search). albums, artists and playlists additionally contain a browseId, corresponding to albumId, channelId and playlistId (browseId=``VL``+playlistId) -
- - - - -
- - - -
- Example - -

list for default search with one result per resultType for brevity. Normally there are 3 results per resultType and an additional ``thumbnails`` key.

- -
-
[
  {
    "category": "Top result",
    "resultType": "video",
    "videoId": "vU05Eksc_iM",
    "title": "Wonderwall",
    "artists": [
      {
        "name": "Oasis",
        "id": "UCmMUZbaYdNH0bEd1PAlAqsA"
      }
    ],
    "views": "1.4M",
    "duration": "4:38",
    "duration_seconds": 278
  },
  {
    "category": "Songs",
    "resultType": "song",
    "videoId": "ZrOKjDZOtkA",
    "title": "Wonderwall",
    "artists": [
      {
        "name": "Oasis",
        "id": "UCmMUZbaYdNH0bEd1PAlAqsA"
      }
    ],
    "album": {
      "name": "(What's The Story) Morning Glory? (Remastered)",
      "id": "MPREb_9nqEki4ZDpp"
    },
    "duration": "4:19",
    "duration_seconds": 259
    "isExplicit": false,
    "feedbackTokens": {
      "add": null,
      "remove": null
    }
  },
  {
    "category": "Albums",
    "resultType": "album",
    "browseId": "MPREb_9nqEki4ZDpp",
    "title": "(What's The Story) Morning Glory? (Remastered)",
    "type": "Album",
    "artist": "Oasis",
    "year": "1995",
    "isExplicit": false
  },
  {
    "category": "Community playlists",
    "resultType": "playlist",
    "browseId": "VLPLK1PkWQlWtnNfovRdGWpKffO1Wdi2kvDx",
    "title": "Wonderwall - Oasis",
    "author": "Tate Henderson",
    "itemCount": "174"
  },
  {
    "category": "Videos",
    "resultType": "video",
    "videoId": "bx1Bh8ZvH84",
    "title": "Wonderwall",
    "artists": [
      {
        "name": "Oasis",
        "id": "UCmMUZbaYdNH0bEd1PAlAqsA"
      }
    ],
    "views": "386M",
    "duration": "4:38",
    "duration_seconds": 278
  },
  {
    "category": "Artists",
    "resultType": "artist",
    "browseId": "UCmMUZbaYdNH0bEd1PAlAqsA",
    "artist": "Oasis",
    "shuffleId": "RDAOkjHYJjL1a3xspEyVkhHAsg",
    "radioId": "RDEMkjHYJjL1a3xspEyVkhHAsg"
  }
]
- - -
- -
- - - @@ -2434,7 +2039,7 @@

@@ -319,93 +319,7 @@

Example
-
{
-      "countries": {
-        "selected": {
-          "text": "United States"
-        },
-        "options": ["DE",
-          "ZZ",
-          "ZW"]
-      },
-      "songs": {
-        "playlist": "VLPL4fGSI1pDJn6O1LS0XSdF3RyO0Rq_LDeI",
-        "items": [
-          {
-            "title": "Outside (Better Days)",
-            "videoId": "oT79YlRtXDg",
-            "artists": [
-              {
-                "name": "MO3",
-                "id": "UCdFt4Cvhr7Okaxo6hZg5K8g"
-              },
-              {
-                "name": "OG Bobby Billions",
-                "id": "UCLusb4T2tW3gOpJS1fJ-A9g"
-              }
-            ],
-            "thumbnails": [...],
-            "isExplicit": true,
-            "album": {
-              "name": "Outside (Better Days)",
-              "id": "MPREb_fX4Yv8frUNv"
-            },
-            "rank": "1",
-            "trend": "up"
-          }
-        ]
-      },
-      "videos": {
-        "playlist": "VLPL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc",
-        "items": [
-          {
-            "title": "EVERY CHANCE I GET (Official Music Video) (feat. Lil Baby & Lil Durk)",
-            "videoId": "BTivsHlVcGU",
-            "playlistId": "PL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc",
-            "thumbnails": [],
-            "views": "46M"
-          }
-        ]
-      },
-      "artists": {
-        "playlist": null,
-        "items": [
-          {
-            "title": "YoungBoy Never Broke Again",
-            "browseId": "UCR28YDxjDE3ogQROaNdnRbQ",
-            "subscribers": "9.62M",
-            "thumbnails": [],
-            "rank": "1",
-            "trend": "neutral"
-          }
-        ]
-      },
-      "genres": [
-        {
-          "title": "Top 50 Pop Music Videos United States",
-          "playlistId": "PL4fGSI1pDJn77aK7sAW2AT0oOzo5inWY8",
-          "thumbnails": []
-        }
-      ],
-      "trending": {
-        "playlist": "VLPLrEnWoR732-DtKgaDdnPkezM_nDidBU9H",
-        "items": [
-          {
-            "title": "Permission to Dance",
-            "videoId": "CuklIb9d3fI",
-            "playlistId": "PLrEnWoR732-DtKgaDdnPkezM_nDidBU9H",
-            "artists": [
-              {
-                "name": "BTS",
-                "id": "UC9vrvNSL3xcWGSkV86REBSg"
-              }
-            ],
-            "thumbnails": [],
-            "views": "108M"
-          }
-        ]
-      }
-      }
+
{
  "countries": {
    "selected": {
      "text": "United States"
    },
    "options": ["DE",
      "ZZ",
      "ZW"]
  },
  "songs": {
    "playlist": "VLPL4fGSI1pDJn6O1LS0XSdF3RyO0Rq_LDeI",
    "items": [
      {
        "title": "Outside (Better Days)",
        "videoId": "oT79YlRtXDg",
        "artists": [
          {
            "name": "MO3",
            "id": "UCdFt4Cvhr7Okaxo6hZg5K8g"
          },
          {
            "name": "OG Bobby Billions",
            "id": "UCLusb4T2tW3gOpJS1fJ-A9g"
          }
        ],
        "thumbnails": [...],
        "isExplicit": true,
        "album": {
          "name": "Outside (Better Days)",
          "id": "MPREb_fX4Yv8frUNv"
        },
        "rank": "1",
        "trend": "up"
      }
    ]
  },
  "videos": {
    "playlist": "VLPL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc",
    "items": [
      {
        "title": "EVERY CHANCE I GET (Official Music Video) (feat. Lil Baby & Lil Durk)",
        "videoId": "BTivsHlVcGU",
        "playlistId": "PL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc",
        "thumbnails": [],
        "views": "46M"
      }
    ]
  },
  "artists": {
    "playlist": null,
    "items": [
      {
        "title": "YoungBoy Never Broke Again",
        "browseId": "UCR28YDxjDE3ogQROaNdnRbQ",
        "subscribers": "9.62M",
        "thumbnails": [],
        "rank": "1",
        "trend": "neutral"
      }
    ]
  },
  "genres": [
    {
      "title": "Top 50 Pop Music Videos United States",
      "playlistId": "PL4fGSI1pDJn77aK7sAW2AT0oOzo5inWY8",
      "thumbnails": []
    }
  ],
  "trending": {
    "playlist": "VLPLrEnWoR732-DtKgaDdnPkezM_nDidBU9H",
    "items": [
      {
        "title": "Permission to Dance",
        "videoId": "CuklIb9d3fI",
        "playlistId": "PLrEnWoR732-DtKgaDdnPkezM_nDidBU9H",
        "artists": [
          {
            "name": "BTS",
            "id": "UC9vrvNSL3xcWGSkV86REBSg"
          }
        ],
        "thumbnails": [],
        "views": "108M"
      }
    ]
  }
}
@@ -520,41 +434,7 @@

Example
-
{
-      'For you': [
-        {
-        'params': 'ggMPOg1uX1ZwN0pHT2NBT1Fk',
-        'title': '1980s'
-        },
-        {
-        'params': 'ggMPOg1uXzZQbDB5eThLRTQ3',
-        'title': 'Feel Good'
-        },
-        ...
-      ],
-      'Genres': [
-        {
-        'params': 'ggMPOg1uXzVLbmZnaWI4STNs',
-        'title': 'Dance & Electronic'
-        },
-        {
-        'params': 'ggMPOg1uX3NjZllsNGVEMkZo',
-        'title': 'Decades'
-        },
-        ...
-      ],
-      'Moods & moments': [
-        {
-        'params': 'ggMPOg1uXzVuc0dnZlhpV3Ba',
-        'title': 'Chill'
-        },
-        {
-        'params': 'ggMPOg1uX2ozUHlwbWM3ajNq',
-        'title': 'Commute'
-        },
-        ...
-      ],
-    }
+
{
  'For you': [
    {
    'params': 'ggMPOg1uX1ZwN0pHT2NBT1Fk',
    'title': '1980s'
    },
    {
    'params': 'ggMPOg1uXzZQbDB5eThLRTQ3',
    'title': 'Feel Good'
    },
    ...
  ],
  'Genres': [
    {
    'params': 'ggMPOg1uXzVLbmZnaWI4STNs',
    'title': 'Dance & Electronic'
    },
    {
    'params': 'ggMPOg1uX3NjZllsNGVEMkZo',
    'title': 'Decades'
    },
    ...
  ],
  'Moods & moments': [
    {
    'params': 'ggMPOg1uXzVuc0dnZlhpV3Ba',
    'title': 'Chill'
    },
    {
    'params': 'ggMPOg1uX2ozUHlwbWM3ajNq',
    'title': 'Commute'
    },
    ...
  ],
}
@@ -743,7 +623,7 @@

diff --git a/docs/module-Library.html b/docs/module-Library.html index bde73fd..cd0bab0 100644 --- a/docs/module-Library.html +++ b/docs/module-Library.html @@ -83,7 +83,7 @@ @@ -266,7 +266,7 @@

@@ -370,7 +370,7 @@

@@ -619,7 +619,7 @@

@@ -881,7 +881,7 @@

@@ -1370,7 +1370,7 @@

@@ -1626,7 +1626,7 @@

Properties
Source:
@@ -1801,7 +1801,7 @@

@@ -2013,7 +2013,7 @@

@@ -2225,7 +2225,7 @@

@@ -2375,7 +2375,7 @@

@@ -2525,7 +2525,7 @@

@@ -2675,7 +2675,7 @@

@@ -2748,7 +2748,7 @@

diff --git a/docs/module-Playlists.html b/docs/module-Playlists.html index ad29c6f..7289672 100644 --- a/docs/module-Playlists.html +++ b/docs/module-Playlists.html @@ -83,7 +83,7 @@ @@ -378,7 +378,7 @@

@@ -737,7 +737,7 @@

Properties
Source:
@@ -904,7 +904,7 @@

@@ -1265,7 +1265,7 @@

Properties
Source:
@@ -1511,7 +1511,7 @@

Each item is in the following format

-
{
  "id": "PLQwVIlKxHM6qv-o99iX9R85og7IzF9YS_",
  "privacy": "PUBLIC",
  "title": "New EDM This Week 03/13/2020",
  "thumbnails": [...]
  "description": "Weekly r/EDM new release roundup. Created with github.com/sigma67/spotifyplaylist_to_gmusic",
  "author": "sigmatics",
  "year": "2020",
  "duration": "6+ hours",
  "duration_seconds": 52651,
  "trackCount": 237,
  "tracks": [
    {
      "videoId": "bjGppZKiuFE",
      "title": "Lost",
      "artists": [
        {
          "name": "Guest Who",
          "id": "UCkgCRdnnqWnUeIH7EIc3dBg"
        },
        {
          "name": "Kate Wild",
          "id": "UCwR2l3JfJbvB6aq0RnnJfWg"
        }
      ],
      "album": {
      "name": "Lost",
      "id": "MPREb_PxmzvDuqOnC"
    },
    "duration": "2:58",
    "likeStatus": "INDIFFERENT",
    "thumbnails": [...],
    "isAvailable": True,
    "isExplicit": False,
    "feedbackTokens": {
    "add": "AB9zfpJxtvrU...",
    "remove": "AB9zfpKTyZ..."
    }
  ]
}
+
{
  "id": "PLQwVIlKxHM6qv-o99iX9R85og7IzF9YS_",
  "privacy": "PUBLIC",
  "title": "New EDM This Week 03/13/2020",
  "thumbnails": [...]
  "description": "Weekly r/EDM new release roundup. Created with github.com/sigma67/spotifyplaylist_to_gmusic",
  "author": "sigmatics",
  "year": "2020",
  "duration": "6+ hours",
  "duration_seconds": 52651,
  "trackCount": 237,
  "tracks": [
    {
      "videoId": "bjGppZKiuFE",
      "title": "Lost",
      "artists": [
        {
          "name": "Guest Who",
          "id": "UCkgCRdnnqWnUeIH7EIc3dBg"
        },
        {
          "name": "Kate Wild",
          "id": "UCwR2l3JfJbvB6aq0RnnJfWg"
        }
      ],
      "album": {
      "name": "Lost",
      "id": "MPREb_PxmzvDuqOnC"
    },
    "duration": "2:58",
    "likeStatus": "INDIFFERENT",
    "thumbnails": [...],
    "isAvailable": True,
    "isExplicit": False,
    "feedbackTokens": {
      "add": "AB9zfpJxtvrU...",
      "remove": "AB9zfpKTyZ..."
    }
  ]
}
@@ -1627,7 +1627,7 @@

@@ -1795,7 +1795,7 @@

@@ -1855,7 +1855,7 @@

diff --git a/docs/module-Uploads.html b/docs/module-Uploads.html index c8cd1ac..443ca98 100644 --- a/docs/module-Uploads.html +++ b/docs/module-Uploads.html @@ -83,7 +83,7 @@ @@ -249,7 +249,7 @@

@@ -860,7 +860,7 @@

diff --git a/docs/module-Watch.html b/docs/module-Watch.html index a02dc2d..e1e2530 100644 --- a/docs/module-Watch.html +++ b/docs/module-Watch.html @@ -83,7 +83,7 @@ @@ -603,7 +603,7 @@

diff --git a/package.json b/package.json index c8006db..947e04c 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "@codyduong/ytmusicapi", - "version": "0.1.2", + "version": "0.2.0", "description": "Unofficial API for YouTube Music", - "main": "dist/ytmusic.js", - "types": "dist/ytmusic.d.ts", + "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { "test": "yarn jest --verbose", "test:pylib": "yarn jest pylib --verbose",