From c712f2d8c601a7e1752f337d8335472016fe800d Mon Sep 17 00:00:00 2001 From: watchdogsrox Date: Thu, 29 Apr 2021 04:38:15 -0400 Subject: [PATCH 01/65] Fixed spotify album/playlist loading Utilizing map which results in a much faster spotify playlist/album loading --- src/Player.ts | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index a46af6e..cf067b5 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -175,17 +175,15 @@ export class Player extends EventEmitter { } break; - // todo: make spotify playlist/album load faster - case 'spotify_album': - case 'spotify_playlist': { - this.emit(PlayerEvents.PLAYLIST_PARSE_START, null, message); - const playlist = await spotify.getData(query); - if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); + // todo: make spotify playlist/album load faster + case 'spotify_album': + case 'spotify_playlist': { + this.emit(PlayerEvents.PLAYLIST_PARSE_START, null, message); + const playlist = await spotify.getData(query); + if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); - // tslint:disable:no-shadowed-variable - const tracks = []; - - for (const item of playlist.tracks.items) { + //Much faster loading + const tracks = await Promise.all(playlist.tracks.items.map(async (track) => { const sq = queryType === 'spotify_album' ? `${item.artists[0].name} - ${item.name}` @@ -197,8 +195,26 @@ export class Player extends EventEmitter { pl: true }); - if (data[0]) tracks.push(data[0]); - } + return results[0]; + })); + +// // tslint:disable:no-shadowed-variable +// const tracks = []; + +// for (const item of playlist.tracks.items) { +// const sq = +// queryType === 'spotify_album' +// ? `${item.artists[0].name} - ${item.name}` +// : `${item.track.artists[0].name} - ${item.name}`; +// const data = await Util.ytSearch(sq, { +// limit: 1, +// player: this, +// user: message.author, +// pl: true +// }); + +// if (data[0]) tracks.push(data[0]); +// } if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); From fd0450bf18e1a2132478e8a24a76b730a566df37 Mon Sep 17 00:00:00 2001 From: watchdogsrox Date: Thu, 29 Apr 2021 04:49:31 -0400 Subject: [PATCH 02/65] Update Player.ts --- src/Player.ts | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index cf067b5..e204c87 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -182,7 +182,6 @@ export class Player extends EventEmitter { const playlist = await spotify.getData(query); if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); - //Much faster loading const tracks = await Promise.all(playlist.tracks.items.map(async (track) => { const sq = queryType === 'spotify_album' @@ -198,24 +197,6 @@ export class Player extends EventEmitter { return results[0]; })); -// // tslint:disable:no-shadowed-variable -// const tracks = []; - -// for (const item of playlist.tracks.items) { -// const sq = -// queryType === 'spotify_album' -// ? `${item.artists[0].name} - ${item.name}` -// : `${item.track.artists[0].name} - ${item.name}`; -// const data = await Util.ytSearch(sq, { -// limit: 1, -// player: this, -// user: message.author, -// pl: true -// }); - -// if (data[0]) tracks.push(data[0]); -// } - if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); const pl = { From c428335a56827cd7e78d394af3504ee75558a5ab Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sat, 8 May 2021 15:32:46 +0545 Subject: [PATCH 03/65] remove --- src/Player.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index a48b96a..d1abeee 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -822,9 +822,9 @@ export class Player extends EventEmitter { queue.tracks = queue.tracks.filter((t) => t !== trackFound); } } else { - trackFound = queue.tracks.find((s) => s === track); + trackFound = queue.tracks.find((s) => s.url === track.url); if (trackFound) { - queue.tracks = queue.tracks.filter((s) => s !== trackFound); + queue.tracks = queue.tracks.filter((s) => s.url !== trackFound.url); } } From a154f48582c4a490aeeb8b73707db457d84947ed Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sat, 8 May 2021 15:37:58 +0545 Subject: [PATCH 04/65] bump deps --- package.json | 6 +++--- src/Player.ts | 4 +++- yarn.lock | 28 ++++++++++++++-------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 7e94075..aab60bc 100644 --- a/package.json +++ b/package.json @@ -50,11 +50,11 @@ }, "homepage": "https://github.com/Androz2091/discord-player#readme", "dependencies": { - "discord-ytdl-core": "^5.0.2", + "discord-ytdl-core": "^5.0.3", "soundcloud-scraper": "^4.0.3", "spotify-url-info": "^2.2.0", - "youtube-sr": "^4.0.4", - "ytdl-core": "^4.5.0" + "youtube-sr": "^4.0.6", + "ytdl-core": "^4.7.0" }, "devDependencies": { "@babel/cli": "^7.13.16", diff --git a/src/Player.ts b/src/Player.ts index d1abeee..85242d3 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -82,11 +82,13 @@ export class Player extends EventEmitter { */ this.filters = AudioFilters; - this.client.on('voiceStateUpdate', (o, n) => void this._handleVoiceStateUpdate(o, n)); + this.client.on('voiceStateUpdate', this._handleVoiceStateUpdate.bind(this)); // auto detect @discord-player/extractor if (!this.options.disableAutoRegister) { let nv: any; + + // tslint:disable:no-conditional-assignment if ((nv = Util.require('@discord-player/extractor'))) { ['Attachment', 'Facebook', 'Reverbnation', 'Vimeo'].forEach((ext) => void this.use(ext, nv[ext])); } diff --git a/yarn.lock b/yarn.lock index 8b2d9c3..14800c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1785,12 +1785,12 @@ diff@^4.0.1: resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== -discord-ytdl-core@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/discord-ytdl-core/-/discord-ytdl-core-5.0.2.tgz#28fb8712af8b5fda34f20800d2226b556e700422" - integrity sha512-tuu+skr0cA89Li7sCH+L1p3TwdfSOunmC9BFzSa0Jj567B1F2leVVbjKQ5ZKpsW1cXKv0fh0PdQA2/Fnu6WcQA== +discord-ytdl-core@^5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/discord-ytdl-core/-/discord-ytdl-core-5.0.3.tgz#a31560f0bede41d6fc969377083ae958deac2b72" + integrity sha512-q4GOEFiV19l0OcPezXnkDWualf+n96LcbTEWReceiDHdx4xxn5CXZX9PR4iDTXQR3Kv2VUkwB8RO8dI50d88vQ== dependencies: - prism-media "^1.2.7" + prism-media "^1.2.9" discord.js-docgen@discordjs/docgen#ts-patch: version "0.9.0" @@ -3476,7 +3476,7 @@ prettier@^2.2.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== -prism-media@^1.2.7, prism-media@^1.2.9: +prism-media@^1.2.9: version "1.2.9" resolved "https://registry.yarnpkg.com/prism-media/-/prism-media-1.2.9.tgz#8d4f97b36efdfc82483eb8d3db64020767866f36" integrity sha512-UHCYuqHipbTR1ZsXr5eg4JUmHER8Ss4YEb9Azn+9zzJ7/jlTtD1h0lc4g6tNx3eMlB8Mp6bfll0LPMAV4R6r3Q== @@ -4627,18 +4627,18 @@ yargs@^14.0.0: y18n "^4.0.0" yargs-parser "^15.0.1" -youtube-sr@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/youtube-sr/-/youtube-sr-4.0.4.tgz#48369b0cb1c53bd84c366a5420bb8f35b1db2329" - integrity sha512-Wf6YlANcCjAweY2MQuqJqusmMcGzaSDWE6ZTD8vifb9i9oFyKQpWuV58fnebJCFJE8G8pTLidmj5aRV7x384EQ== +youtube-sr@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/youtube-sr/-/youtube-sr-4.0.6.tgz#e27c8fadb51361a6223ba0552b300f131c903fe9" + integrity sha512-nRrqgWl0xYfMhwLTqjF7G6s+36IHIdOMtZaSrz0Cpk4uSIqoeKEJgLiAZrYIGWGNYtS8/mzZYRzYxaIA/gW1Ig== dependencies: node-fetch "^2.6.1" simple-youtube-api "^5.2.1" -ytdl-core@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.5.0.tgz#f07733387c548e5c3a5614c93ef55bde666eeaf4" - integrity sha512-e8r6skrakWNixsVlNPBMoRM1HrdW1swE97If9nenDUjF65uogYk4DvxIuqlmqRfBWKe+6aIZwqedNxUU9XLYJA== +ytdl-core@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.7.0.tgz#2c92023536484d8a2760d1aa504df2778f87ae21" + integrity sha512-G09HeYsyLMsUCPEuK2asDqmLnOx+n5SxVV3QqGJd+iYuw5Z/qiwx7x0gxZTiAkHBsbG3WuluJWBPswZyrygKmQ== dependencies: m3u8stream "^0.8.3" miniget "^4.0.0" From 9b1d0e72d0befdde96f440df98f2731c35425bca Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sat, 8 May 2021 15:53:38 +0545 Subject: [PATCH 05/65] docs --- docs/faq/custom_filters.md | 11 +++++++++++ docs/faq/live_video.md | 10 ++++++++++ docs/faq/pause_resume.md | 13 +++++++++++++ docs/index.yml | 8 ++++++++ 4 files changed, 42 insertions(+) create mode 100644 docs/faq/custom_filters.md create mode 100644 docs/faq/live_video.md create mode 100644 docs/faq/pause_resume.md diff --git a/docs/faq/custom_filters.md b/docs/faq/custom_filters.md new file mode 100644 index 0000000..bf7dbda --- /dev/null +++ b/docs/faq/custom_filters.md @@ -0,0 +1,11 @@ +# How to add custom audio filters +Audio filters in **Discord Player** are **[FFmpeg audio filters](http://ffmpeg.org/ffmpeg-all.html#Audio-Filters)**. You can add your own audio filter like this: + +```js +const { AudioFilters } = require("discord-player"); + +AudioFilters.define("3D", "apulsator=hz=0.128"); + +// later, it can be used like this +player.setFilters(message, { "3D": true }); +``` \ No newline at end of file diff --git a/docs/faq/live_video.md b/docs/faq/live_video.md new file mode 100644 index 0000000..c8966b3 --- /dev/null +++ b/docs/faq/live_video.md @@ -0,0 +1,10 @@ +# How to play live videos +You cannot play live videos by default. If you need to play the live video, just add this option: + +```js +const player = new Player(client, { + enableLive: true // enables livestream +}); +``` + +However, you cannot use audio filters with livestreams using this library! \ No newline at end of file diff --git a/docs/faq/pause_resume.md b/docs/faq/pause_resume.md new file mode 100644 index 0000000..6334d0a --- /dev/null +++ b/docs/faq/pause_resume.md @@ -0,0 +1,13 @@ +# Pause and Resume is not working properly +This is a bug in **[discord.js#5300](https://github.com/discordjs/discord.js/issues/5300)**. + +# Fix +You have to update your command something like this: + +```diff +- client.player.resume(message); + ++ client.player.resume(message); ++ client.player.pause(message); ++ client.player.resume(message); +``` \ No newline at end of file diff --git a/docs/index.yml b/docs/index.yml index f367636..3ab6cd4 100644 --- a/docs/index.yml +++ b/docs/index.yml @@ -6,6 +6,14 @@ files: - name: Extractors API path: extractor.md +- name: FAQ + files: + - name: Custom Filters + path: custom_filters.md + - name: Livestreams + path: live_video.md + - name: Pause & Resume + path: pause_resume.md - name: YouTube files: - name: Using Cookies From ba040fc5a1b20c43c845170d7259bf1d40364445 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sat, 8 May 2021 15:57:27 +0545 Subject: [PATCH 06/65] v4.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aab60bc..69cea7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player", - "version": "4.0.5", + "version": "4.0.6", "description": "Complete framework to facilitate music commands using discord.js", "main": "lib/index.js", "types": "lib/index.d.ts", From cdd182f67419cbdae5753bf436fa96d6f2ad2560 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sat, 8 May 2021 16:16:00 +0545 Subject: [PATCH 07/65] formatting --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- docs/faq/custom_filters.md | 1 + docs/faq/live_video.md | 1 + docs/faq/pause_resume.md | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 325fe93..fb7e111 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -25,7 +25,7 @@ Steps to reproduce the behavior: **Please complete the following information:** - Node Version: [x.x.x] - - Library Version: [x.x.x] + - Discord Player Version: [x.x.x] - Discord.js Version: [x.x.x] **Additional context** diff --git a/docs/faq/custom_filters.md b/docs/faq/custom_filters.md index bf7dbda..35b39e5 100644 --- a/docs/faq/custom_filters.md +++ b/docs/faq/custom_filters.md @@ -1,4 +1,5 @@ # How to add custom audio filters + Audio filters in **Discord Player** are **[FFmpeg audio filters](http://ffmpeg.org/ffmpeg-all.html#Audio-Filters)**. You can add your own audio filter like this: ```js diff --git a/docs/faq/live_video.md b/docs/faq/live_video.md index c8966b3..1882bd4 100644 --- a/docs/faq/live_video.md +++ b/docs/faq/live_video.md @@ -1,4 +1,5 @@ # How to play live videos + You cannot play live videos by default. If you need to play the live video, just add this option: ```js diff --git a/docs/faq/pause_resume.md b/docs/faq/pause_resume.md index 6334d0a..d0cbc54 100644 --- a/docs/faq/pause_resume.md +++ b/docs/faq/pause_resume.md @@ -1,7 +1,9 @@ # Pause and Resume is not working properly + This is a bug in **[discord.js#5300](https://github.com/discordjs/discord.js/issues/5300)**. # Fix + You have to update your command something like this: ```diff From 892fc29a1806224e3c094c0a2b528b06f3b2d89d Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 18:09:06 +0545 Subject: [PATCH 08/65] spotify --- src/Player.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index a12b9e2..8cc97ad 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -177,18 +177,18 @@ export class Player extends EventEmitter { } break; - // todo: make spotify playlist/album load faster case 'spotify_album': case 'spotify_playlist': { this.emit(PlayerEvents.PLAYLIST_PARSE_START, null, message); const playlist = await spotify.getData(query); if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); - const tracks = await Promise.all(playlist.tracks.items.map(async (track) => { + const tracks = await Promise.all(playlist.tracks.items.map(async (item: any) => { const sq = queryType === 'spotify_album' ? `${item.artists[0].name} - ${item.name}` : `${item.track.artists[0].name} - ${item.name}`; + const data = await Util.ytSearch(sq, { limit: 1, player: this, @@ -196,7 +196,7 @@ export class Player extends EventEmitter { pl: true }); - return results[0]; + return data[0]; })); if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); From 3a09c172480c30f635f84e3bb3f084b896893591 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 18:09:20 +0545 Subject: [PATCH 09/65] formatting --- src/Player.ts | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 8cc97ad..1c55cc5 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -177,27 +177,29 @@ export class Player extends EventEmitter { } break; - case 'spotify_album': - case 'spotify_playlist': { - this.emit(PlayerEvents.PLAYLIST_PARSE_START, null, message); - const playlist = await spotify.getData(query); - if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); + case 'spotify_album': + case 'spotify_playlist': { + this.emit(PlayerEvents.PLAYLIST_PARSE_START, null, message); + const playlist = await spotify.getData(query); + if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); - const tracks = await Promise.all(playlist.tracks.items.map(async (item: any) => { - const sq = - queryType === 'spotify_album' - ? `${item.artists[0].name} - ${item.name}` - : `${item.track.artists[0].name} - ${item.name}`; + const tracks = await Promise.all( + playlist.tracks.items.map(async (item: any) => { + const sq = + queryType === 'spotify_album' + ? `${item.artists[0].name} - ${item.name}` + : `${item.track.artists[0].name} - ${item.name}`; - const data = await Util.ytSearch(sq, { - limit: 1, - player: this, - user: message.author, - pl: true - }); + const data = await Util.ytSearch(sq, { + limit: 1, + player: this, + user: message.author, + pl: true + }); - return data[0]; - })); + return data[0]; + }) + ); if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); From ea4dc26671d08f49beba7ae79b78f888c5bd34c9 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 18:19:25 +0545 Subject: [PATCH 10/65] jsdoc --- src/Player.ts | 53 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 1c55cc5..ed2bf8e 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -131,6 +131,14 @@ export class Player extends EventEmitter { return this.Extractors.delete(extractorName); } + /** + * Internal method to search tracks + * @param {DiscordMessage} message The message + * @param {string} query The query + * @param {boolean} [firstResult=false] If it should return the first result + * @returns {Promise} + * @private + */ private _searchTracks(message: Message, query: string, firstResult?: boolean): Promise { return new Promise(async (resolve) => { let tracks: Track[] = []; @@ -379,7 +387,7 @@ export class Player extends EventEmitter { * Play a song * @param {DiscordMessage} message The discord.js message object * @param {string|Track} query Search query, can be `Player.Track` instance - * @param {Boolean} [firstResult] If it should play the first result + * @param {Boolean} [firstResult=false] If it should play the first result * @example await player.play(message, "never gonna give you up", true) * @returns {Promise} */ @@ -990,6 +998,13 @@ export class Player extends EventEmitter { return this.skip(message); } + /** + * Internal method to handle VoiceStateUpdate events + * @param {DiscordVoiceState} oldState The old voice state + * @param {DiscordVoiceState} newState The new voice state + * @returns {void} + * @private + */ private _handleVoiceStateUpdate(oldState: VoiceState, newState: VoiceState): void { const queue = this.queues.find((g) => g.guildID === oldState.guild.id); if (!queue) return; @@ -1023,7 +1038,14 @@ export class Player extends EventEmitter { } } - private _addTrackToQueue(message: Message, track: Track): Queue { + /** + * Internal method used to add tracks to the queue + * @param {DiscordMessage} message The discord message + * @param {Track} track The track + * @returns {Queue} + * @private + */ + _addTrackToQueue(message: Message, track: Track): Queue { const queue = this.getQueue(message); if (!queue) this.emit( @@ -1037,7 +1059,14 @@ export class Player extends EventEmitter { return queue; } - private _addTracksToQueue(message: Message, tracks: Track[]): Queue { + /** + * Same as `_addTrackToQueue` but used for multiple tracks + * @param {DiscordMessage} message Discord message + * @param {Track[]} tracks The tracks + * @returns {Queue} + * @private + */ + _addTracksToQueue(message: Message, tracks: Track[]): Queue { const queue = this.getQueue(message); if (!queue) throw new PlayerError( @@ -1085,6 +1114,13 @@ export class Player extends EventEmitter { }); } + /** + * Internal method used to init stream playing + * @param {Queue} queue The queue + * @param {boolean} firstPlay If this is a first play + * @returns {Promise} + * @private + */ private async _playTrack(queue: Queue, firstPlay: boolean): Promise { if (queue.stopped) return; @@ -1139,6 +1175,14 @@ export class Player extends EventEmitter { }); } + /** + * Internal method to play audio + * @param {Queue} queue The queue + * @param {boolean} updateFilter If this method was called for audio filter update + * @param {number} [seek] Time in ms to seek to + * @returns {Promise} + * @private + */ private _playStream(queue: Queue, updateFilter: boolean, seek?: number): Promise { return new Promise(async (resolve) => { const ffmpeg = Util.checkFFmpeg(); @@ -1323,7 +1367,8 @@ export default Player; */ /** - * Emitted when an error is triggered + * Emitted when an error is triggered. + * This event should handled properly by the users otherwise it might crash the process! * @event Player#error * @param {String} error It can be `NotConnected`, `UnableToJoin`, `NotPlaying`, `ParseError`, `LiveVideo` or `VideoUnavailable`. * @param {DiscordMessage} message The message From 5b8b6e0c0d4763474255860a84603677637850b4 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 18:26:54 +0545 Subject: [PATCH 11/65] jsdoc --- src/Player.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Player.ts b/src/Player.ts index ed2bf8e..42b8837 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -39,7 +39,19 @@ export class Player extends EventEmitter { * @type {DiscordCollection} */ public queues = new Collection(); + + /** + * Collection of results collectors + * @type {DiscordCollection>} + * @private + */ private _resultsCollectors = new Collection>(); + + /** + * Collection of cooldowns timeout + * @type {DiscordCollection} + * @private + */ private _cooldownsTimeout = new Collection(); /** From f5a48bc433423ccf5f25a071af34dd51e9f5a7f6 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 18:31:18 +0545 Subject: [PATCH 12/65] soundcloud link --- src/utils/Util.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 7826f5d..86d28c6 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -65,6 +65,8 @@ export class Util { * @returns {QueryType} */ static getQueryType(query: string): QueryType { + // @todo: better validation + if (query.match(/soundcloud.app.goo.gl/)) return 'soundcloud_track'; if (SoundcloudValidateURL(query) && !query.includes('/sets/')) return 'soundcloud_track'; if (SoundcloudValidateURL(query) && query.includes('/sets/')) return 'soundcloud_playlist'; if (spotifySongRegex.test(query)) return 'spotify_song'; From 903bfaae46f9434f1f14df70d794327b35d77a38 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 18:50:36 +0545 Subject: [PATCH 13/65] bump soundcloud-scraper --- package.json | 2 +- src/utils/Util.ts | 2 -- yarn.lock | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 69cea7b..e894ace 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "homepage": "https://github.com/Androz2091/discord-player#readme", "dependencies": { "discord-ytdl-core": "^5.0.3", - "soundcloud-scraper": "^4.0.3", + "soundcloud-scraper": "^4.0.4", "spotify-url-info": "^2.2.0", "youtube-sr": "^4.0.6", "ytdl-core": "^4.7.0" diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 86d28c6..7826f5d 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -65,8 +65,6 @@ export class Util { * @returns {QueryType} */ static getQueryType(query: string): QueryType { - // @todo: better validation - if (query.match(/soundcloud.app.goo.gl/)) return 'soundcloud_track'; if (SoundcloudValidateURL(query) && !query.includes('/sets/')) return 'soundcloud_track'; if (SoundcloudValidateURL(query) && query.includes('/sets/')) return 'soundcloud_playlist'; if (spotifySongRegex.test(query)) return 'spotify_song'; diff --git a/yarn.lock b/yarn.lock index 14800c2..cf8a6a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3917,10 +3917,10 @@ sort-array@^2.0.0: object-get "^2.1.0" typical "^2.6.0" -soundcloud-scraper@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/soundcloud-scraper/-/soundcloud-scraper-4.0.3.tgz#cd7ed1d7b6ed1d7729fd7580c011281f652b920f" - integrity sha512-A0a6sVJ2wkkWIX8Ft3L63sfHBlFDRAaPFif+SWi07KCNLh8YTcylw45pts76pndxlupKwV2NgOTIYeF/F9tg8w== +soundcloud-scraper@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/soundcloud-scraper/-/soundcloud-scraper-4.0.4.tgz#dfd6a45dc6e63fac7d6b31f2ba1d23a199ca4fb6" + integrity sha512-ei3KuPsVZRiq9j2GN580gQwVGZUWMdkmDAANSPm8qweUa4/UnKAnYiUsc/6volZsQiGsnJAP9+8HECDxNcTg6A== dependencies: cheerio "^1.0.0-rc.3" m3u8stream "^0.8.0" From 4184dcb6f9b401197c8e0d714247cc96ff8c63c4 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 18:57:50 +0545 Subject: [PATCH 14/65] fix soundcloud duration --- src/Player.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 42b8837..40158ed 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -164,7 +164,7 @@ export class Player extends EventEmitter { const track = new Track(this, { title: data.title, url: data.url, - duration: Util.buildTimeCode(Util.parseMS(data.duration / 1000)), + duration: Util.buildTimeCode(Util.parseMS(data.duration)), description: data.description, thumbnail: data.thumbnail, views: data.playCount, @@ -317,7 +317,7 @@ export class Player extends EventEmitter { const r = new Track(this, { title: song.title, url: song.url, - duration: Util.buildTimeCode(Util.parseMS(song.duration / 1000)), + duration: Util.buildTimeCode(Util.parseMS(song.duration)), description: song.description, thumbnail: song.thumbnail ?? 'https://soundcloud.com/pwa-icon-192.png', views: song.playCount ?? 0, From aff8a5ac29a52bdf39e01e202408e0d8ad0ad2af Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 19:01:11 +0545 Subject: [PATCH 15/65] make linter happy --- src/Player.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Player.ts b/src/Player.ts index 40158ed..f72c0cb 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -203,6 +203,7 @@ export class Player extends EventEmitter { const playlist = await spotify.getData(query); if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); + // tslint:disable-next-line:no-shadowed-variable const tracks = await Promise.all( playlist.tracks.items.map(async (item: any) => { const sq = @@ -280,6 +281,7 @@ export class Player extends EventEmitter { this.emit(PlayerEvents.PLAYLIST_PARSE_END, playlist, message); // @ts-ignore + // tslint:disable-next-line:no-shadowed-variable const tracks = playlist.videos as Track[]; if (this.isPlaying(message)) { @@ -968,6 +970,7 @@ export class Player extends EventEmitter { return { uptime: this.client.uptime, connections: this.client.voice.connections.size, + // tslint:disable:no-shadowed-variable users: this.client.voice.connections.reduce( (a, c) => a + c.channel.members.filter((a) => a.user.id !== this.client.user.id).size, 0 From 18e64801e81fb25ec1f174929c5b4a83649ac1e9 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 19:01:49 +0545 Subject: [PATCH 16/65] homepage --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e894ace..4d254d1 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "bugs": { "url": "https://github.com/Androz2091/discord-player/issues" }, - "homepage": "https://github.com/Androz2091/discord-player#readme", + "homepage": "https://discord-player.js.org", "dependencies": { "discord-ytdl-core": "^5.0.3", "soundcloud-scraper": "^4.0.4", From 3582f1c2ad2b8117596d02a5bc1982ba46194b2c Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 22:02:01 +0545 Subject: [PATCH 17/65] jsdoc --- src/Player.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Player.ts b/src/Player.ts index f72c0cb..56279e7 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -1091,6 +1091,13 @@ export class Player extends EventEmitter { return queue; } + /** + * Internal method used to create queue + * @param {DiscordMessage} message The message + * @param {Track} track The track + * @returns {Promise} + * @private + */ private _createQueue(message: Message, track: Track): Promise { return new Promise((resolve) => { const channel = message.member.voice ? message.member.voice.channel : null; From 49087bcec13d696edfbb23075a483c1751d1b59a Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 10:56:28 +0545 Subject: [PATCH 18/65] spotify --- .gitattributes | 1 + src/Player.ts | 18 +++++++++++++++--- src/types/types.ts | 1 + src/utils/Util.ts | 6 +++--- 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94f480d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/src/Player.ts b/src/Player.ts index 56279e7..bc4bfa5 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -187,7 +187,10 @@ export class Player extends EventEmitter { if (matchSpotifyURL) { const spotifyData = await spotify.getPreview(query).catch(() => {}); if (spotifyData) { - tracks = await Util.ytSearch(`${spotifyData.artist} - ${spotifyData.title}`, { + const searchString = this.options.disableArtistSearch + ? spotifyData.title + : `${spotifyData.artist} - ${spotifyData.title}`; + tracks = await Util.ytSearch(searchString, { user: message.author, player: this, limit: 1 @@ -208,8 +211,16 @@ export class Player extends EventEmitter { playlist.tracks.items.map(async (item: any) => { const sq = queryType === 'spotify_album' - ? `${item.artists[0].name} - ${item.name}` - : `${item.track.artists[0].name} - ${item.name}`; + ? `${ + this.options.disableArtistSearch + ? item.artists[0].name + : `${item.artists[0].name} - ` + }${item.name}` + : `${ + this.options.disableArtistSearch + ? item.track.artists[0].name + : `${item.track.artists[0].name} - ` + }${item.name}`; const data = await Util.ytSearch(sq, { limit: 1, @@ -1422,6 +1433,7 @@ export default Player; * @property {YTDLDownloadOptions} [ytdlDownloadOptions={}] The download options passed to `ytdl-core` * @property {Boolean} [useSafeSearch=false] If it should use `safe search` method for youtube searches * @property {Boolean} [disableAutoRegister=false] If it should disable auto-registeration of `@discord-player/extractor` + * @property {Boolean} [disableArtistSearch=false] If it should disable artist search for spotify */ /** diff --git a/src/types/types.ts b/src/types/types.ts index 9e57e90..629188d 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -13,6 +13,7 @@ export interface PlayerOptions { ytdlDownloadOptions?: downloadOptions; useSafeSearch?: boolean; disableAutoRegister?: boolean; + disableArtistSearch?: boolean; } export type FiltersName = keyof QueueFilters; diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 7826f5d..c444c84 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -4,7 +4,7 @@ import YouTube from 'youtube-sr'; import { Track } from '../Structures/Track'; // @ts-ignore import { validateURL as SoundcloudValidateURL } from 'soundcloud-scraper'; -import { VoiceChannel } from 'discord.js'; +import { StageChannel, VoiceChannel } from 'discord.js'; const spotifySongRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/; const spotifyPlaylistRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:playlist\/|\?uri=spotify:playlist:)((\w|-){22})/; @@ -190,10 +190,10 @@ export class Util { /** * Checks if the given voice channel is empty - * @param {DiscordVoiceChannel} channel The voice channel + * @param {DiscordVoiceChannel|DiscordStageChannel} channel The voice channel * @returns {Boolean} */ - static isVoiceEmpty(channel: VoiceChannel): boolean { + static isVoiceEmpty(channel: VoiceChannel | StageChannel): boolean { return channel.members.filter((member) => !member.user.bot).size === 0; } From e16811b4c8dd78252346148b33cab9ed13b7d9c1 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 11:00:24 +0545 Subject: [PATCH 19/65] remove stage channels for now --- src/Player.ts | 8 +++++--- src/utils/Util.ts | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index bc4bfa5..ad5730a 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -1046,15 +1046,17 @@ export class Player extends EventEmitter { if (!oldState.channelID || newState.channelID) { const emptyTimeout = this._cooldownsTimeout.get(`empty_${oldState.guild.id}`); - const channelEmpty = Util.isVoiceEmpty(queue.voiceConnection.channel); + + // @todo: stage channels + const channelEmpty = Util.isVoiceEmpty(queue.voiceConnection.channel as VoiceChannel); if (!channelEmpty && emptyTimeout) { clearTimeout(emptyTimeout); this._cooldownsTimeout.delete(`empty_${oldState.guild.id}`); } } else { - if (!Util.isVoiceEmpty(queue.voiceConnection.channel)) return; + if (!Util.isVoiceEmpty(queue.voiceConnection.channel as VoiceChannel)) return; const timeout = setTimeout(() => { - if (!Util.isVoiceEmpty(queue.voiceConnection.channel)) return; + if (!Util.isVoiceEmpty(queue.voiceConnection.channel as VoiceChannel)) return; if (!this.queues.has(queue.guildID)) return; queue.voiceConnection.channel.leave(); this.queues.delete(queue.guildID); diff --git a/src/utils/Util.ts b/src/utils/Util.ts index c444c84..7826f5d 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -4,7 +4,7 @@ import YouTube from 'youtube-sr'; import { Track } from '../Structures/Track'; // @ts-ignore import { validateURL as SoundcloudValidateURL } from 'soundcloud-scraper'; -import { StageChannel, VoiceChannel } from 'discord.js'; +import { VoiceChannel } from 'discord.js'; const spotifySongRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/; const spotifyPlaylistRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:playlist\/|\?uri=spotify:playlist:)((\w|-){22})/; @@ -190,10 +190,10 @@ export class Util { /** * Checks if the given voice channel is empty - * @param {DiscordVoiceChannel|DiscordStageChannel} channel The voice channel + * @param {DiscordVoiceChannel} channel The voice channel * @returns {Boolean} */ - static isVoiceEmpty(channel: VoiceChannel | StageChannel): boolean { + static isVoiceEmpty(channel: VoiceChannel): boolean { return channel.members.filter((member) => !member.user.bot).size === 0; } From d5e29d7cddc9da524e1761729445c1a8e4682b60 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 11:16:10 +0545 Subject: [PATCH 20/65] some update --- package.json | 1 + src/Player.ts | 4 ++-- yarn.lock | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4d254d1..9648526 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "@discordjs/opus": "^0.5.0", "@types/node": "^14.14.41", "@types/ws": "^7.4.1", + "discord-api-types": "^0.18.1", "discord.js": "^12.5.3", "discord.js-docgen": "discordjs/docgen#ts-patch", "jsdoc-babel": "^0.5.0", diff --git a/src/Player.ts b/src/Player.ts index ad5730a..0676862 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -229,7 +229,7 @@ export class Player extends EventEmitter { pl: true }); - return data[0]; + if (data.length) return data[0]; }) ); @@ -238,7 +238,7 @@ export class Player extends EventEmitter { const pl = { ...playlist, tracks, - duration: tracks.reduce((a, c) => a + c.durationMS, 0), + duration: tracks?.reduce((a, c) => a + (c?.durationMS ?? 0), 0) ?? 0, thumbnail: playlist.images[0]?.url ?? tracks[0].thumbnail }; diff --git a/yarn.lock b/yarn.lock index cf8a6a4..936db89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1785,6 +1785,11 @@ diff@^4.0.1: resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== +discord-api-types@^0.18.1: + version "0.18.1" + resolved "https://registry.yarnpkg.com/discord-api-types/-/discord-api-types-0.18.1.tgz#5d08ed1263236be9c21a22065d0e6b51f790f492" + integrity sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg== + discord-ytdl-core@^5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/discord-ytdl-core/-/discord-ytdl-core-5.0.3.tgz#a31560f0bede41d6fc969377083ae958deac2b72" From 5386bbc91427bc727986996d7e0215f1930c4c16 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 13:49:30 +0545 Subject: [PATCH 21/65] fix spotify track name --- src/Player.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 0676862..8221bb6 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -209,18 +209,19 @@ export class Player extends EventEmitter { // tslint:disable-next-line:no-shadowed-variable const tracks = await Promise.all( playlist.tracks.items.map(async (item: any) => { + const sq = queryType === 'spotify_album' ? `${ this.options.disableArtistSearch ? item.artists[0].name : `${item.artists[0].name} - ` - }${item.name}` + }${item.name ?? item.track.name}` : `${ this.options.disableArtistSearch ? item.track.artists[0].name : `${item.track.artists[0].name} - ` - }${item.name}`; + }${item.name ?? item.track.name}`; const data = await Util.ytSearch(sq, { limit: 1, From 4d0fa222b29391a1823f476449f896ae288149a5 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 13:56:03 +0545 Subject: [PATCH 22/65] enums --- src/Player.ts | 3 +-- src/utils/Constants.ts | 54 +++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 8221bb6..b23647c 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -209,14 +209,13 @@ export class Player extends EventEmitter { // tslint:disable-next-line:no-shadowed-variable const tracks = await Promise.all( playlist.tracks.items.map(async (item: any) => { - const sq = queryType === 'spotify_album' ? `${ this.options.disableArtistSearch ? item.artists[0].name : `${item.artists[0].name} - ` - }${item.name ?? item.track.name}` + }${item.name ?? item.track.name}` : `${ this.options.disableArtistSearch ? item.track.artists[0].name diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index ef5eb1b..afa41d5 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -1,33 +1,33 @@ import { PlayerOptions as DP_OPTIONS } from '../types/types'; -export const PlayerEvents = { - BOT_DISCONNECT: 'botDisconnect', - CHANNEL_EMPTY: 'channelEmpty', - CONNECTION_CREATE: 'connectionCreate', - ERROR: 'error', - MUSIC_STOP: 'musicStop', - NO_RESULTS: 'noResults', - PLAYLIST_ADD: 'playlistAdd', - PLAYLIST_PARSE_END: 'playlistParseEnd', - PLAYLIST_PARSE_START: 'playlistParseStart', - QUEUE_CREATE: 'queueCreate', - QUEUE_END: 'queueEnd', - SEARCH_CANCEL: 'searchCancel', - SEARCH_INVALID_RESPONSE: 'searchInvalidResponse', - SEARCH_RESULTS: 'searchResults', - TRACK_ADD: 'trackAdd', - TRACK_START: 'trackStart' -}; +export enum PlayerEvents { + BOT_DISCONNECT = 'botDisconnect', + CHANNEL_EMPTY = 'channelEmpty', + CONNECTION_CREATE = 'connectionCreate', + ERROR = 'error', + MUSIC_STOP = 'musicStop', + NO_RESULTS = 'noResults', + PLAYLIST_ADD = 'playlistAdd', + PLAYLIST_PARSE_END = 'playlistParseEnd', + PLAYLIST_PARSE_START = 'playlistParseStart', + QUEUE_CREATE = 'queueCreate', + QUEUE_END = 'queueEnd', + SEARCH_CANCEL = 'searchCancel', + SEARCH_INVALID_RESPONSE = 'searchInvalidResponse', + SEARCH_RESULTS = 'searchResults', + TRACK_ADD = 'trackAdd', + TRACK_START = 'trackStart' +} -export const PlayerErrorEventCodes = { - LIVE_VIDEO: 'LiveVideo', - NOT_CONNECTED: 'NotConnected', - UNABLE_TO_JOIN: 'UnableToJoin', - NOT_PLAYING: 'NotPlaying', - PARSE_ERROR: 'ParseError', - VIDEO_UNAVAILABLE: 'VideoUnavailable', - MUSIC_STARTING: 'MusicStarting' -}; +export enum PlayerErrorEventCodes { + LIVE_VIDEO = 'LiveVideo', + NOT_CONNECTED = 'NotConnected', + UNABLE_TO_JOIN = 'UnableToJoin', + NOT_PLAYING = 'NotPlaying', + PARSE_ERROR = 'ParseError', + VIDEO_UNAVAILABLE = 'VideoUnavailable', + MUSIC_STARTING = 'MusicStarting' +} export const PlayerOptions: DP_OPTIONS = { leaveOnEnd: true, From de40d183a65f1453a14c5bb84359937c7486708c Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 14:28:23 +0545 Subject: [PATCH 23/65] fix spotify playlist list --- src/Player.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index b23647c..e43139e 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -207,7 +207,7 @@ export class Player extends EventEmitter { if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); // tslint:disable-next-line:no-shadowed-variable - const tracks = await Promise.all( + let tracks = await Promise.all( playlist.tracks.items.map(async (item: any) => { const sq = queryType === 'spotify_album' @@ -232,7 +232,8 @@ export class Player extends EventEmitter { if (data.length) return data[0]; }) ); - + + tracks = tracks.filter(f => !!f); if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); const pl = { From c2ff70955f0d9b74550a1bfd0d09a081d4308c74 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 14:54:35 +0545 Subject: [PATCH 24/65] stream time --- src/Structures/Queue.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index 1cee68b..0a173f2 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -156,7 +156,12 @@ export class Queue extends EventEmitter { * @type {Number} */ get currentStreamTime(): number { - return this.voiceConnection?.dispatcher?.streamTime + this.additionalStreamTime || 0; + const NC = this.filters.nightcore ? 1.25 : null; + const VW = this.filters.vaporwave ? 0.8 : null; + const streamTime = this.voiceConnection?.dispatcher?.streamTime + this.additionalStreamTime || 0; + + if (NC && VW) return streamTime * (NC + VW); + return NC ? streamTime * NC : VW ? (streamTime * VW) : streamTime; } /** From 9e187a4d2bc1c2e833bc1620ffbd304fa3aa4192 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 14:57:10 +0545 Subject: [PATCH 25/65] prettier --- src/Player.ts | 4 ++-- src/Structures/Queue.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index e43139e..c91d60d 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -232,8 +232,8 @@ export class Player extends EventEmitter { if (data.length) return data[0]; }) ); - - tracks = tracks.filter(f => !!f); + + tracks = tracks.filter((f) => !!f); if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); const pl = { diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index 0a173f2..a8fa7a5 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -161,7 +161,7 @@ export class Queue extends EventEmitter { const streamTime = this.voiceConnection?.dispatcher?.streamTime + this.additionalStreamTime || 0; if (NC && VW) return streamTime * (NC + VW); - return NC ? streamTime * NC : VW ? (streamTime * VW) : streamTime; + return NC ? streamTime * NC : VW ? streamTime * VW : streamTime; } /** From c6830f87c0a34ad220e5c76b28197879fcb81adb Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 15:38:24 +0545 Subject: [PATCH 26/65] fix: youtube playlists being undefined --- src/Player.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Player.ts b/src/Player.ts index c91d60d..44f44f2 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -290,6 +290,10 @@ export class Player extends EventEmitter { // @ts-ignore playlist.requestedBy = message.author; + Object.defineProperty(playlist, "tracks", { + get: () => playlist.videos ?? [] + }); + this.emit(PlayerEvents.PLAYLIST_PARSE_END, playlist, message); // @ts-ignore From 29b54029e6d4816f7dc6ab85c8b5e3bc1363f186 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 15:44:05 +0545 Subject: [PATCH 27/65] spotify playlists data --- src/Player.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Player.ts b/src/Player.ts index 44f44f2..1a8d84e 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -240,7 +240,8 @@ export class Player extends EventEmitter { ...playlist, tracks, duration: tracks?.reduce((a, c) => a + (c?.durationMS ?? 0), 0) ?? 0, - thumbnail: playlist.images[0]?.url ?? tracks[0].thumbnail + thumbnail: playlist.images[0]?.url ?? tracks[0].thumbnail, + title: playlist.title ?? playlist.name ?? "" }; this.emit(PlayerEvents.PLAYLIST_PARSE_END, pl, message); @@ -254,6 +255,7 @@ export class Player extends EventEmitter { (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); + this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); this._addTracksToQueue(message, tracks); } From f27cf860384872a99f98e41a2c73a1308eafe54f Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 15:45:13 +0545 Subject: [PATCH 28/65] emit PlaylistAdd before TrackStart --- src/Player.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Player.ts b/src/Player.ts index 1a8d84e..be209e5 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -254,8 +254,8 @@ export class Player extends EventEmitter { const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; - this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); + this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); this._addTracksToQueue(message, tracks); } From 5602a4c360a2a6e8d566ba4540095df683aff315 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 15:47:05 +0545 Subject: [PATCH 29/65] prettier --- src/Player.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index be209e5..d10b4f0 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -241,7 +241,7 @@ export class Player extends EventEmitter { tracks, duration: tracks?.reduce((a, c) => a + (c?.durationMS ?? 0), 0) ?? 0, thumbnail: playlist.images[0]?.url ?? tracks[0].thumbnail, - title: playlist.title ?? playlist.name ?? "" + title: playlist.title ?? playlist.name ?? '' }; this.emit(PlayerEvents.PLAYLIST_PARSE_END, pl, message); @@ -292,7 +292,7 @@ export class Player extends EventEmitter { // @ts-ignore playlist.requestedBy = message.author; - Object.defineProperty(playlist, "tracks", { + Object.defineProperty(playlist, 'tracks', { get: () => playlist.videos ?? [] }); From dd325ffb3057ea10129726944857677f281e9306 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 15:52:43 +0545 Subject: [PATCH 30/65] v4.0.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9648526..7dbd47d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player", - "version": "4.0.6", + "version": "4.0.7", "description": "Complete framework to facilitate music commands using discord.js", "main": "lib/index.js", "types": "lib/index.d.ts", From a8668e0b3f719176ad7ba3e841096a53c7bf077a Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 16:07:52 +0545 Subject: [PATCH 31/65] remove useless dep --- package.json | 1 - yarn.lock | 5 ----- 2 files changed, 6 deletions(-) diff --git a/package.json b/package.json index 7dbd47d..8092060 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "@discordjs/opus": "^0.5.0", "@types/node": "^14.14.41", "@types/ws": "^7.4.1", - "discord-api-types": "^0.18.1", "discord.js": "^12.5.3", "discord.js-docgen": "discordjs/docgen#ts-patch", "jsdoc-babel": "^0.5.0", diff --git a/yarn.lock b/yarn.lock index 936db89..cf8a6a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1785,11 +1785,6 @@ diff@^4.0.1: resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== -discord-api-types@^0.18.1: - version "0.18.1" - resolved "https://registry.yarnpkg.com/discord-api-types/-/discord-api-types-0.18.1.tgz#5d08ed1263236be9c21a22065d0e6b51f790f492" - integrity sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg== - discord-ytdl-core@^5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/discord-ytdl-core/-/discord-ytdl-core-5.0.3.tgz#a31560f0bede41d6fc969377083ae958deac2b72" From 0c3dcbf3c730e059b35556a485b699ed74fd1daa Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 21:27:03 +0545 Subject: [PATCH 32/65] remove repl.it check --- src/Player.ts | 3 +-- src/utils/Util.ts | 22 ---------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index d10b4f0..6dfc19f 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -1281,8 +1281,7 @@ export class Player extends EventEmitter { queue.stream = newStream; queue.voiceConnection.play(newStream, { type: 'opus', - bitrate: 'auto', - volume: Util.isRepl() ? false : undefined + bitrate: 'auto' }); if (seekTime) { diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 7826f5d..2d8e7c5 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -166,28 +166,6 @@ export class Util { }); } - /** - * Checks if this system is running in replit.com - * @returns {Boolean} - */ - static isRepl(): boolean { - if ('DP_REPL_NOCHECK' in process.env) return false; - - const REPL_IT_PROPS = [ - 'REPL_SLUG', - 'REPL_OWNER', - 'REPL_IMAGE', - 'REPL_PUBKEYS', - 'REPL_ID', - 'REPL_LANGUAGE', - 'REPLIT_DB_URL' - ]; - - for (const prop of REPL_IT_PROPS) if (prop in process.env) return true; - - return false; - } - /** * Checks if the given voice channel is empty * @param {DiscordVoiceChannel} channel The voice channel From a502a2f17deef85531210c8ceb77cd603e65aa95 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 10 May 2021 21:27:31 +0545 Subject: [PATCH 33/65] bump youtube-sr --- package.json | 2 +- yarn.lock | 40 ++++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 8092060..ea217cd 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "discord-ytdl-core": "^5.0.3", "soundcloud-scraper": "^4.0.4", "spotify-url-info": "^2.2.0", - "youtube-sr": "^4.0.6", + "youtube-sr": "^4.0.7", "ytdl-core": "^4.7.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index cf8a6a4..e3126b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -940,6 +940,14 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== +"@types/node-fetch@^2.5.10": + version "2.5.10" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.10.tgz#9b4d4a0425562f9fcea70b12cb3fcdd946ca8132" + integrity sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ== + dependencies: + "@types/node" "*" + form-data "^3.0.0" + "@types/node@*", "@types/node@^14.14.41": version "14.14.41" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.41.tgz#d0b939d94c1d7bd53d04824af45f1139b8c45615" @@ -2225,6 +2233,15 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= +form-data@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" + integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + form-data@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" @@ -2724,11 +2741,6 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= -iso8601-duration@^1.2.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/iso8601-duration/-/iso8601-duration-1.3.0.tgz#29d7b69e0574e4acdee50c5e5e09adab4137ba5a" - integrity sha512-K4CiUBzo3YeWk76FuET/dQPH03WE04R94feo5TSKQCXpoXQt9E4yx2CnY737QZnSAI3PI4WlKo/zfqizGx52QQ== - isobject@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" @@ -3856,14 +3868,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== -simple-youtube-api@^5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/simple-youtube-api/-/simple-youtube-api-5.2.1.tgz#d1f6efb941ce404f50ce56e0c5e6bff249fcac6a" - integrity sha512-vmndP9Bkh35tifn2OwY+th2imSsfYtmDqczgdOW5yEARFzvSoR8VSQFsivJnctfV5QHQUL6VrOpNdbmDRLh9Bg== - dependencies: - iso8601-duration "^1.2.0" - node-fetch "^2.6.0" - slash@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" @@ -4627,13 +4631,13 @@ yargs@^14.0.0: y18n "^4.0.0" yargs-parser "^15.0.1" -youtube-sr@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/youtube-sr/-/youtube-sr-4.0.6.tgz#e27c8fadb51361a6223ba0552b300f131c903fe9" - integrity sha512-nRrqgWl0xYfMhwLTqjF7G6s+36IHIdOMtZaSrz0Cpk4uSIqoeKEJgLiAZrYIGWGNYtS8/mzZYRzYxaIA/gW1Ig== +youtube-sr@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/youtube-sr/-/youtube-sr-4.0.7.tgz#156137713a5df2d02c0698fd819fca2249f3a9f3" + integrity sha512-s05pA+NgD0iPw97XtRXiy5GaEbYyIVsfArmGO5UfvSO5etrG6DxAs1uKqTFbQH4IGTqMsb82M14iB5ohkOD2Mw== dependencies: + "@types/node-fetch" "^2.5.10" node-fetch "^2.6.1" - simple-youtube-api "^5.2.1" ytdl-core@^4.7.0: version "4.7.0" From 653ed064da194a2feca69618f66913ddc77b8f54 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 18:05:34 +0545 Subject: [PATCH 34/65] todo --- src/Player.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Player.ts b/src/Player.ts index 6dfc19f..54f8a3c 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -1054,7 +1054,7 @@ export class Player extends EventEmitter { if (!oldState.channelID || newState.channelID) { const emptyTimeout = this._cooldownsTimeout.get(`empty_${oldState.guild.id}`); - // @todo: stage channels + // @todo: make stage channels stable const channelEmpty = Util.isVoiceEmpty(queue.voiceConnection.channel as VoiceChannel); if (!channelEmpty && emptyTimeout) { clearTimeout(emptyTimeout); From 7a8ed2414e0ac3a24de6f3806e32c4d359162994 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 18:44:06 +0545 Subject: [PATCH 35/65] bump soundcloud-scraper --- package.json | 2 +- yarn.lock | 125 ++++++++++++++++++++++++++++++++++----------------- 2 files changed, 84 insertions(+), 43 deletions(-) diff --git a/package.json b/package.json index ea217cd..35a7a3f 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "homepage": "https://discord-player.js.org", "dependencies": { "discord-ytdl-core": "^5.0.3", - "soundcloud-scraper": "^4.0.4", + "soundcloud-scraper": "^5.0.0", "spotify-url-info": "^2.2.0", "youtube-sr": "^4.0.7", "ytdl-core": "^4.7.0" diff --git a/yarn.lock b/yarn.lock index e3126b9..85b3e7f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1413,29 +1413,29 @@ chardet@^0.7.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== -cheerio-select-tmp@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/cheerio-select-tmp/-/cheerio-select-tmp-0.1.1.tgz#55bbef02a4771710195ad736d5e346763ca4e646" - integrity sha512-YYs5JvbpU19VYJyj+F7oYrIE2BOll1/hRU7rEy/5+v9BzkSo3bK81iAeeQEMI92vRIxz677m72UmJUiVwwgjfQ== +cheerio-select@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/cheerio-select/-/cheerio-select-1.4.0.tgz#3a16f21e37a2ef0f211d6d1aa4eff054bb22cdc9" + integrity sha512-sobR3Yqz27L553Qa7cK6rtJlMDbiKPdNywtR95Sj/YgfpLfy0u6CGJuaBKe5YE/vTc23SCRKxWSdlon/w6I/Ew== dependencies: - css-select "^3.1.2" - css-what "^4.0.0" - domelementtype "^2.1.0" - domhandler "^4.0.0" - domutils "^2.4.4" + css-select "^4.1.2" + css-what "^5.0.0" + domelementtype "^2.2.0" + domhandler "^4.2.0" + domutils "^2.6.0" -cheerio@^1.0.0-rc.3: - version "1.0.0-rc.5" - resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.5.tgz#88907e1828674e8f9fee375188b27dadd4f0fa2f" - integrity sha512-yoqps/VCaZgN4pfXtenwHROTp8NG6/Hlt4Jpz2FEP0ZJQ+ZUkVDd0hAPDNKhj3nakpfPt/CNs57yEtxD1bXQiw== +cheerio@^1.0.0-rc.9: + version "1.0.0-rc.9" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.9.tgz#a3ae6b7ce7af80675302ff836f628e7cb786a67f" + integrity sha512-QF6XVdrLONO6DXRF5iaolY+odmhj2CLj+xzNod7INPWMi/x9X4SOylH0S/vaPpX+AUU6t04s34SQNh7DbkuCng== dependencies: - cheerio-select-tmp "^0.1.0" - dom-serializer "~1.2.0" - domhandler "^4.0.0" - entities "~2.1.0" - htmlparser2 "^6.0.0" - parse5 "^6.0.0" - parse5-htmlparser2-tree-adapter "^6.0.0" + cheerio-select "^1.4.0" + dom-serializer "^1.3.1" + domhandler "^4.2.0" + htmlparser2 "^6.1.0" + parse5 "^6.0.1" + parse5-htmlparser2-tree-adapter "^6.0.1" + tslib "^2.2.0" chokidar@^3.4.0: version "3.5.1" @@ -1667,11 +1667,27 @@ css-select@^3.1.2: domutils "^2.4.3" nth-check "^2.0.0" +css-select@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.1.2.tgz#8b52b6714ed3a80d8221ec971c543f3b12653286" + integrity sha512-nu5ye2Hg/4ISq4XqdLY2bEatAcLIdt3OYGFc9Tm9n7VSlFBcfRv0gBNksHRgSdUDQGtN3XrZ94ztW+NfzkFSUw== + dependencies: + boolbase "^1.0.0" + css-what "^5.0.0" + domhandler "^4.2.0" + domutils "^2.6.0" + nth-check "^2.0.0" + css-what@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/css-what/-/css-what-4.0.0.tgz#35e73761cab2eeb3d3661126b23d7aa0e8432233" integrity sha512-teijzG7kwYfNVsUh2H/YN62xW3KK9YhXEgSlbxMlcyjPNvdKJqFx5lrwlJgoFP1ZHlB89iGDlo/JyshKeRhv5A== +css-what@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.0.0.tgz#f0bf4f8bac07582722346ab243f6a35b512cfc47" + integrity sha512-qxyKHQvgKwzwDWC/rGbT821eJalfupxYW2qbSJSAtdSTimsr/MlaGONoNLllaUPZWf8QnbcKM/kPVYUQuEKAFA== + cssom@^0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.4.4.tgz#5a66cf93d2d0b661d80bf6a44fb65f5c2e4e0a10" @@ -1849,7 +1865,7 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -dom-serializer@^1.0.1, dom-serializer@~1.2.0: +dom-serializer@^1.0.1: version "1.2.0" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.2.0.tgz#3433d9136aeb3c627981daa385fc7f32d27c48f1" integrity sha512-n6kZFH/KlCrqs/1GHMOd5i2fd/beQHuehKdWvNNffbGHTr/almdhuVvTVFb3V7fglz+nC50fFusu3lY33h12pA== @@ -1858,7 +1874,16 @@ dom-serializer@^1.0.1, dom-serializer@~1.2.0: domhandler "^4.0.0" entities "^2.0.0" -domelementtype@^2.0.1, domelementtype@^2.1.0, domelementtype@^2.2.0: +dom-serializer@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.1.tgz#d845a1565d7c041a95e5dab62184ab41e3a519be" + integrity sha512-Pv2ZluG5ife96udGgEDovOOOA5UELkltfJpnIExPrAk1LTvecolUGn6lIaoLh86d83GiB86CjzciMd9BuRB71Q== + dependencies: + domelementtype "^2.0.1" + domhandler "^4.0.0" + entities "^2.0.0" + +domelementtype@^2.0.1, domelementtype@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57" integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A== @@ -1877,7 +1902,14 @@ domhandler@^4.0.0, domhandler@^4.1.0: dependencies: domelementtype "^2.2.0" -domutils@^2.4.3, domutils@^2.4.4: +domhandler@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.2.0.tgz#f9768a5f034be60a89a27c2e4d0f74eba0d8b059" + integrity sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA== + dependencies: + domelementtype "^2.2.0" + +domutils@^2.4.3: version "2.5.1" resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.5.1.tgz#9b8e84b5d9f788499ae77506ea832e9b4f9aa1c0" integrity sha512-hO1XwHMGAthA/1KL7c83oip/6UWo3FlUNIuWiWKltoiQ5oCOiqths8KknvY2jpOohUoUgnwa/+Rm7UpwpSbY/Q== @@ -1886,6 +1918,15 @@ domutils@^2.4.3, domutils@^2.4.4: domelementtype "^2.2.0" domhandler "^4.1.0" +domutils@^2.5.2, domutils@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.6.0.tgz#2e15c04185d43fb16ae7057cb76433c6edb938b7" + integrity sha512-y0BezHuy4MDYxh6OvolXYsH+1EMGmFbwv5FKW7ovwMG6zTPWqNPq3WF9ayZssFq+UlKdffGLbOEaghNdaOm1WA== + dependencies: + dom-serializer "^1.0.1" + domelementtype "^2.2.0" + domhandler "^4.2.0" + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -1919,11 +1960,6 @@ entities@~2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.3.tgz#5c487e5742ab93c15abb5da22759b8590ec03b7f" integrity sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ== -entities@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5" - integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w== - escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" @@ -2492,14 +2528,14 @@ html-encoding-sniffer@^2.0.1: dependencies: whatwg-encoding "^1.0.5" -htmlparser2@^6.0.0: - version "6.0.1" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.0.1.tgz#422521231ef6d42e56bd411da8ba40aa36e91446" - integrity sha512-GDKPd+vk4jvSuvCbyuzx/unmXkk090Azec7LovXP8as1Hn8q9p3hbjmDGbUqqhknw0ajwit6LiiWqfiTUPMK7w== +htmlparser2@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.1.0.tgz#c4d762b6c3371a05dbe65e94ae43a9f845fb8fb7" + integrity sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A== dependencies: domelementtype "^2.0.1" domhandler "^4.0.0" - domutils "^2.4.4" + domutils "^2.5.2" entities "^2.0.0" http-proxy-agent@^4.0.1: @@ -3026,7 +3062,7 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" -m3u8stream@^0.8.0, m3u8stream@^0.8.3: +m3u8stream@^0.8.3: version "0.8.3" resolved "https://registry.yarnpkg.com/m3u8stream/-/m3u8stream-0.8.3.tgz#c4624e92b4240eb356d040c4a5e155586cf58108" integrity sha512-0nAcdrF8YJKUkb6PzWdvGftTPyCVWgoiot1AkNVbPKTeIGsWs6DrOjifrJ0Zi8WQfQmD2SuVCjkYIOip12igng== @@ -3416,14 +3452,14 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse5-htmlparser2-tree-adapter@^6.0.0: +parse5-htmlparser2-tree-adapter@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz#2cdf9ad823321140370d4dbf5d3e92c7c8ddc6e6" integrity sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA== dependencies: parse5 "^6.0.1" -parse5@6.0.1, parse5@^6.0.0, parse5@^6.0.1: +parse5@6.0.1, parse5@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b" integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw== @@ -3921,13 +3957,13 @@ sort-array@^2.0.0: object-get "^2.1.0" typical "^2.6.0" -soundcloud-scraper@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/soundcloud-scraper/-/soundcloud-scraper-4.0.4.tgz#dfd6a45dc6e63fac7d6b31f2ba1d23a199ca4fb6" - integrity sha512-ei3KuPsVZRiq9j2GN580gQwVGZUWMdkmDAANSPm8qweUa4/UnKAnYiUsc/6volZsQiGsnJAP9+8HECDxNcTg6A== +soundcloud-scraper@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/soundcloud-scraper/-/soundcloud-scraper-5.0.0.tgz#3f4e9d9fc9ee79cbaf6cdd64f462ad6803e25ac1" + integrity sha512-8Rt7WbW85AqiFoKkemF5BKsGAThLGnhOi13ztctAI0Y/wso/iuR97yiVXK1eYRc2YqaD8gkpKUAjEY7bOxLxnw== dependencies: - cheerio "^1.0.0-rc.3" - m3u8stream "^0.8.0" + cheerio "^1.0.0-rc.9" + m3u8stream "^0.8.3" node-fetch "^2.6.1" source-map-resolve@^0.5.0: @@ -4266,6 +4302,11 @@ tslib@^1.13.0, tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslib@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" + integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w== + tslint-config-prettier@^1.18.0: version "1.18.0" resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz#75f140bde947d35d8f0d238e0ebf809d64592c37" From 59fdcbf0320ba8b14d5eba5625507518478eb584 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 18:46:07 +0545 Subject: [PATCH 36/65] validate url --- src/utils/Util.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 2d8e7c5..56e313f 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -65,8 +65,8 @@ export class Util { * @returns {QueryType} */ static getQueryType(query: string): QueryType { - if (SoundcloudValidateURL(query) && !query.includes('/sets/')) return 'soundcloud_track'; - if (SoundcloudValidateURL(query) && query.includes('/sets/')) return 'soundcloud_playlist'; + if (SoundcloudValidateURL(query, 'track')) return 'soundcloud_track'; + if (SoundcloudValidateURL(query, 'playlist') || query.includes('/sets/')) return 'soundcloud_playlist'; if (spotifySongRegex.test(query)) return 'spotify_song'; if (spotifyAlbumRegex.test(query)) return 'spotify_album'; if (spotifyPlaylistRegex.test(query)) return 'spotify_playlist'; From 262dbe23e7a744734f0ad27648cda543f66fb90f Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 19:48:11 +0545 Subject: [PATCH 37/65] bump extractors --- package.json | 2 +- src/Player.ts | 2 +- src/index.ts | 1 + src/utils/env.ts | 19 ++++++++++++++ yarn.lock | 64 ++++++++++-------------------------------------- 5 files changed, 35 insertions(+), 53 deletions(-) create mode 100644 src/utils/env.ts diff --git a/package.json b/package.json index 35a7a3f..e4d3251 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@babel/core": "^7.13.16", "@babel/preset-env": "^7.13.15", "@babel/preset-typescript": "^7.13.0", - "@discord-player/extractor": "^2.0.0", + "@discord-player/extractor": "^3.0.0", "@discordjs/opus": "^0.5.0", "@types/node": "^14.14.41", "@types/ws": "^7.4.1", diff --git a/src/Player.ts b/src/Player.ts index 54f8a3c..ae57ed2 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -959,7 +959,7 @@ export class Player extends EventEmitter { const extractor = Util.require('@discord-player/extractor'); if (!extractor) throw new PlayerError("Cannot call 'Player.lyrics()' without '@discord-player/extractor'"); - const data = await extractor.Lyrics(query); + const data = await extractor.Lyrics.init().search(query); if (Array.isArray(data)) return null; return data; diff --git a/src/index.ts b/src/index.ts index 4dd3a82..704ea54 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ export { AudioFilters } from './utils/AudioFilters'; export * as Constants from './utils/Constants'; +export { Env as env } from './utils/env'; export { ExtractorModel } from './Structures/ExtractorModel'; export { Player } from './Player'; export { Util } from './utils/Util'; diff --git a/src/utils/env.ts b/src/utils/env.ts new file mode 100644 index 0000000..dba993d --- /dev/null +++ b/src/utils/env.ts @@ -0,0 +1,19 @@ +// @ts-ignore +import { Store, Client } from 'soundcloud-scraper'; +import { YouTube } from 'youtube-sr'; + +export class Env { + static get SoundcloudClient() { + return Client; + } + + static get SoundcloudStore() { + const store = Store as Map; + const setAPIkey = (newKey: string) => store.set('SOUNDCLOUD_API_KEY', newKey); + return { setAPIkey }; + } + + static get youtube() { + return YouTube; + } +} diff --git a/yarn.lock b/yarn.lock index 85b3e7f..24d141b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -871,13 +871,13 @@ "@babel/helper-validator-identifier" "^7.12.11" to-fast-properties "^2.0.0" -"@discord-player/extractor@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@discord-player/extractor/-/extractor-2.0.0.tgz#3879e51d64b72d4dcee9338bdece5251d006c746" - integrity sha512-qNyF0dkLNRYvtVtLLO022RV8DzToCPJqbuAOqSWCSdkXiKSGoqTdKcZI9I/Lb87mchYuuakOXyPRvRwkAruX6w== +"@discord-player/extractor@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@discord-player/extractor/-/extractor-3.0.0.tgz#2baa733da054b991f83417054cad1575cf57c4ab" + integrity sha512-6A2QmrbQXTpv1oequiAYQMnWzvv1fu9Yg0GJwAMoLUXZjvb5Yoak2lnohsDI1Hc14LW//Z5xyLGtmFivTWTXDQ== dependencies: - genius-lyrics "^4.2.7" - jsdom "^16.5.2" + genius-lyrics "^4.2.9" + jsdom "^16.5.3" node-fetch "^2.6.1" reverbnation-scraper "^2.0.0" @@ -1656,17 +1656,6 @@ cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -css-select@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-3.1.2.tgz#d52cbdc6fee379fba97fb0d3925abbd18af2d9d8" - integrity sha512-qmss1EihSuBNWNNhHjxzxSfJoFBM/lERB/Q4EnsJQQC62R2evJDW481091oAdOr9uh46/0n4nrg0It5cAnj1RA== - dependencies: - boolbase "^1.0.0" - css-what "^4.0.0" - domhandler "^4.0.0" - domutils "^2.4.3" - nth-check "^2.0.0" - css-select@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.1.2.tgz#8b52b6714ed3a80d8221ec971c543f3b12653286" @@ -1678,11 +1667,6 @@ css-select@^4.1.2: domutils "^2.6.0" nth-check "^2.0.0" -css-what@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-4.0.0.tgz#35e73761cab2eeb3d3661126b23d7aa0e8432233" - integrity sha512-teijzG7kwYfNVsUh2H/YN62xW3KK9YhXEgSlbxMlcyjPNvdKJqFx5lrwlJgoFP1ZHlB89iGDlo/JyshKeRhv5A== - css-what@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.0.0.tgz#f0bf4f8bac07582722346ab243f6a35b512cfc47" @@ -1895,7 +1879,7 @@ domexception@^2.0.1: dependencies: webidl-conversions "^5.0.0" -domhandler@^4.0.0, domhandler@^4.1.0: +domhandler@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.1.0.tgz#c1d8d494d5ec6db22de99e46a149c2a4d23ddd43" integrity sha512-/6/kmsGlMY4Tup/nGVutdrK9yQi4YjWVcVeoQmixpzjOUK1U7pQkvAPHBJeUxOgxF0J8f8lwCJSlCfD0V4CMGQ== @@ -1909,15 +1893,6 @@ domhandler@^4.2.0: dependencies: domelementtype "^2.2.0" -domutils@^2.4.3: - version "2.5.1" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.5.1.tgz#9b8e84b5d9f788499ae77506ea832e9b4f9aa1c0" - integrity sha512-hO1XwHMGAthA/1KL7c83oip/6UWo3FlUNIuWiWKltoiQ5oCOiqths8KknvY2jpOohUoUgnwa/+Rm7UpwpSbY/Q== - dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.1.0" - domutils@^2.5.2, domutils@^2.6.0: version "2.6.0" resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.6.0.tgz#2e15c04185d43fb16ae7057cb76433c6edb938b7" @@ -2345,13 +2320,13 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" -genius-lyrics@^4.2.7: - version "4.2.7" - resolved "https://registry.yarnpkg.com/genius-lyrics/-/genius-lyrics-4.2.7.tgz#e85f65eb2de4ea2c0af1e11b13dda11e0c9744a9" - integrity sha512-laoeF2/P+Ed4uewuG6OeqymKTNdfGuymkCohMHIgr3g2DwziW49USXcEGCog1vnEDCpf2LhznNi3WOeLeSmAww== +genius-lyrics@^4.2.9: + version "4.2.9" + resolved "https://registry.yarnpkg.com/genius-lyrics/-/genius-lyrics-4.2.9.tgz#87d12946589d3e96df4e100c51805aa5046de2c7" + integrity sha512-BQm/gmaXEckLAc/Z9ZsGNWxh4CHudx0G1Key8Rnv0xFcqmrxIvssJIDBgDPJLqB6dpVas3uj6LQng1yMFtxfNA== dependencies: axios "^0.21.1" - node-html-parser "^3.0.4" + cheerio "^1.0.0-rc.9" gensync@^1.0.0-beta.2: version "1.0.0-beta.2" @@ -2511,11 +2486,6 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -he@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" - integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== - himalaya@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/himalaya/-/himalaya-1.1.0.tgz#31724ae9d35714cd7c6f4be94888953f3604606a" @@ -2892,7 +2862,7 @@ jsdoc@^3.6.3: taffydb "2.6.2" underscore "~1.10.2" -jsdom@^16.5.2: +jsdom@^16.5.3: version "16.5.3" resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.5.3.tgz#13a755b3950eb938b4482c407238ddf16f0d2136" integrity sha512-Qj1H+PEvUsOtdPJ056ewXM4UJPCi4hhLA8wpiz9F2YvsRBhuFsXxtrIFAgGBDynQA9isAMGE91PfUYbdMPXuTA== @@ -3278,14 +3248,6 @@ node-fetch@2.6.1, node-fetch@^2.6.0, node-fetch@^2.6.1: resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== -node-html-parser@^3.0.4: - version "3.1.5" - resolved "https://registry.yarnpkg.com/node-html-parser/-/node-html-parser-3.1.5.tgz#ffb62f2a336b6b634f41f3315487fe446fb9d7b5" - integrity sha512-/XKKdWbSUymlXTjtNBcDlmM7Jp8S/BqGMzLx7r2bd2NMjTXz+ofuLcz0Bl3VT0vTvVzF+N511FNLrZt4HVitXA== - dependencies: - css-select "^3.1.2" - he "1.2.0" - node-releases@^1.1.71: version "1.1.71" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.71.tgz#cb1334b179896b1c89ecfdd4b725fb7bbdfc7dbb" From 1ca22167efb4c66959b28485f2dfa016879db988 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 19:50:00 +0545 Subject: [PATCH 38/65] player env utils --- src/utils/env.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/utils/env.ts b/src/utils/env.ts index dba993d..b704d55 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -2,17 +2,30 @@ import { Store, Client } from 'soundcloud-scraper'; import { YouTube } from 'youtube-sr'; +/** + * Utility env + */ export class Env { + + /** + * The soundcloud client + */ static get SoundcloudClient() { return Client; } + /** + * The soundcloud store utils + */ static get SoundcloudStore() { const store = Store as Map; const setAPIkey = (newKey: string) => store.set('SOUNDCLOUD_API_KEY', newKey); return { setAPIkey }; } + /** + * The youtube search + */ static get youtube() { return YouTube; } From bc5249cc3710272aa9d3f561d06637340018bfa8 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 19:50:26 +0545 Subject: [PATCH 39/65] docs --- docs/faq/custom_filters.md | 2 +- docs/faq/live_video.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/faq/custom_filters.md b/docs/faq/custom_filters.md index 35b39e5..fd3cfa9 100644 --- a/docs/faq/custom_filters.md +++ b/docs/faq/custom_filters.md @@ -1,4 +1,4 @@ -# How to add custom audio filters +# How to add custom audio filters? Audio filters in **Discord Player** are **[FFmpeg audio filters](http://ffmpeg.org/ffmpeg-all.html#Audio-Filters)**. You can add your own audio filter like this: diff --git a/docs/faq/live_video.md b/docs/faq/live_video.md index 1882bd4..40eb4be 100644 --- a/docs/faq/live_video.md +++ b/docs/faq/live_video.md @@ -1,4 +1,4 @@ -# How to play live videos +# How to play live videos? You cannot play live videos by default. If you need to play the live video, just add this option: From 8d45b126749969d6956b8d53fd2d33e519f70721 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 19:54:13 +0545 Subject: [PATCH 40/65] env utils --- src/utils/env.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/env.ts b/src/utils/env.ts index b704d55..d658e52 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -6,21 +6,23 @@ import { YouTube } from 'youtube-sr'; * Utility env */ export class Env { - /** * The soundcloud client + * @example const sc = new (require("discord-player")).Env.SoundcloudClient.Client(); + * sc.search("faded").then(console.log); */ static get SoundcloudClient() { - return Client; + return { Client }; } /** * The soundcloud store utils + * @example const store = require("discord-player").Env.SoundcloudStore.setAPIkey("soundcloud_api_key") */ static get SoundcloudStore() { const store = Store as Map; const setAPIkey = (newKey: string) => store.set('SOUNDCLOUD_API_KEY', newKey); - return { setAPIkey }; + return { setAPIkey, store }; } /** From 76471b4fa8789f83b6783222bf45af7d5f67b022 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 20:08:57 +0545 Subject: [PATCH 41/65] fix documentaiton --- src/utils/env.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/utils/env.ts b/src/utils/env.ts index d658e52..c32798d 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -2,14 +2,20 @@ import { Store, Client } from 'soundcloud-scraper'; import { YouTube } from 'youtube-sr'; -/** - * Utility env - */ export class Env { + + /** + * Utility env + */ + constructor() { + throw new Error(`Cannot instantiate the class ${this.constructor.name}`); + } + /** * The soundcloud client * @example const sc = new (require("discord-player")).Env.SoundcloudClient.Client(); * sc.search("faded").then(console.log); + * @type {Object} */ static get SoundcloudClient() { return { Client }; @@ -18,6 +24,7 @@ export class Env { /** * The soundcloud store utils * @example const store = require("discord-player").Env.SoundcloudStore.setAPIkey("soundcloud_api_key") + * @type {Object} */ static get SoundcloudStore() { const store = Store as Map; @@ -27,6 +34,7 @@ export class Env { /** * The youtube search + * @type {YouTube} */ static get youtube() { return YouTube; From 912b3b49dd442f2b58aa3ddd65ece16d2cb777ef Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 20:09:22 +0545 Subject: [PATCH 42/65] docs --- src/utils/env.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/env.ts b/src/utils/env.ts index c32798d..a2cbe83 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -13,8 +13,8 @@ export class Env { /** * The soundcloud client - * @example const sc = new (require("discord-player")).Env.SoundcloudClient.Client(); - * sc.search("faded").then(console.log); + * @example const soundcloud = new (require("discord-player")).Env.SoundcloudClient.Client(); + * soundcloud.search("faded").then(console.log); * @type {Object} */ static get SoundcloudClient() { From 3c4b16a3b12ebe413827c2b2ee5ff631ffee2a7a Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Tue, 11 May 2021 20:17:52 +0545 Subject: [PATCH 43/65] env --- src/utils/env.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/env.ts b/src/utils/env.ts index a2cbe83..a328ce7 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -6,6 +6,7 @@ export class Env { /** * Utility env + * This feature is Experimental */ constructor() { throw new Error(`Cannot instantiate the class ${this.constructor.name}`); @@ -13,7 +14,6 @@ export class Env { /** * The soundcloud client - * @example const soundcloud = new (require("discord-player")).Env.SoundcloudClient.Client(); * soundcloud.search("faded").then(console.log); * @type {Object} */ @@ -23,7 +23,6 @@ export class Env { /** * The soundcloud store utils - * @example const store = require("discord-player").Env.SoundcloudStore.setAPIkey("soundcloud_api_key") * @type {Object} */ static get SoundcloudStore() { From 37f8dc67f8d6f3e406d35a2b2b413a8fc644d7a7 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 09:37:50 +0545 Subject: [PATCH 44/65] removed env --- src/index.ts | 1 - src/utils/env.ts | 41 ----------------------------------------- 2 files changed, 42 deletions(-) delete mode 100644 src/utils/env.ts diff --git a/src/index.ts b/src/index.ts index 704ea54..4dd3a82 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ export { AudioFilters } from './utils/AudioFilters'; export * as Constants from './utils/Constants'; -export { Env as env } from './utils/env'; export { ExtractorModel } from './Structures/ExtractorModel'; export { Player } from './Player'; export { Util } from './utils/Util'; diff --git a/src/utils/env.ts b/src/utils/env.ts deleted file mode 100644 index a328ce7..0000000 --- a/src/utils/env.ts +++ /dev/null @@ -1,41 +0,0 @@ -// @ts-ignore -import { Store, Client } from 'soundcloud-scraper'; -import { YouTube } from 'youtube-sr'; - -export class Env { - - /** - * Utility env - * This feature is Experimental - */ - constructor() { - throw new Error(`Cannot instantiate the class ${this.constructor.name}`); - } - - /** - * The soundcloud client - * soundcloud.search("faded").then(console.log); - * @type {Object} - */ - static get SoundcloudClient() { - return { Client }; - } - - /** - * The soundcloud store utils - * @type {Object} - */ - static get SoundcloudStore() { - const store = Store as Map; - const setAPIkey = (newKey: string) => store.set('SOUNDCLOUD_API_KEY', newKey); - return { setAPIkey, store }; - } - - /** - * The youtube search - * @type {YouTube} - */ - static get youtube() { - return YouTube; - } -} From aeb863e756bd806878c3a1779219151c05fc5e20 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 09:53:31 +0545 Subject: [PATCH 45/65] redo spotify track --- src/Player.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index ae57ed2..c46f158 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -185,11 +185,11 @@ export class Player extends EventEmitter { /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/ ); if (matchSpotifyURL) { - const spotifyData = await spotify.getPreview(query).catch(() => {}); + const spotifyData = await spotify.getData(query).catch(() => {}); if (spotifyData) { const searchString = this.options.disableArtistSearch - ? spotifyData.title - : `${spotifyData.artist} - ${spotifyData.title}`; + ? spotifyData.name + : `${spotifyData.name}${spotifyData.artists[0] ? ` - ${spotifyData.artists[0]?.name}` : ""}`; tracks = await Util.ytSearch(searchString, { user: message.author, player: this, From 0abfb26abc4005692992a40c58dae3b0bda2de3e Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 10:40:32 +0545 Subject: [PATCH 46/65] complete spotify update --- src/Player.ts | 122 ++++++++++++++++++++++++++++++++------------- src/types/types.ts | 2 +- 2 files changed, 87 insertions(+), 37 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index c46f158..baa9e7d 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -187,14 +187,23 @@ export class Player extends EventEmitter { if (matchSpotifyURL) { const spotifyData = await spotify.getData(query).catch(() => {}); if (spotifyData) { - const searchString = this.options.disableArtistSearch - ? spotifyData.name - : `${spotifyData.name}${spotifyData.artists[0] ? ` - ${spotifyData.artists[0]?.name}` : ""}`; - tracks = await Util.ytSearch(searchString, { - user: message.author, - player: this, - limit: 1 + const spotifyTrack = new Track(this, { + title: spotifyData.name, + description: spotifyData.description ?? '', + author: spotifyData.artists[0]?.name ?? 'Unknown Artist', + url: spotifyData.external_urls?.spotify ?? query, + thumbnail: + spotifyData.album?.images[0]?.url ?? spotifyData.preview_url?.length + ? `https://i.scdn.co/image/${spotifyData.preview_url?.split('?cid=')[1]}` + : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + duration: Util.buildTimeCode(Util.parseMS(spotifyData.duration_ms)), + views: 0, + requestedBy: message.author, + fromPlaylist: false, + source: 'spotify' }); + + tracks = [spotifyTrack]; } } } @@ -207,33 +216,49 @@ export class Player extends EventEmitter { if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query); // tslint:disable-next-line:no-shadowed-variable - let tracks = await Promise.all( - playlist.tracks.items.map(async (item: any) => { - const sq = - queryType === 'spotify_album' - ? `${ - this.options.disableArtistSearch - ? item.artists[0].name - : `${item.artists[0].name} - ` - }${item.name ?? item.track.name}` - : `${ - this.options.disableArtistSearch - ? item.track.artists[0].name - : `${item.track.artists[0].name} - ` - }${item.name ?? item.track.name}`; + let tracks: Track[] = []; - const data = await Util.ytSearch(sq, { - limit: 1, - player: this, - user: message.author, - pl: true + if (playlist.type !== 'playlist') + tracks = playlist.tracks.items.map((m: any) => { + const data = new Track(this, { + title: m.name ?? '', + description: m.description ?? '', + author: m.artists[0]?.name ?? 'Unknown Artist', + url: m.external_urls?.spotify ?? query, + thumbnail: + playlist.images[0]?.url ?? m.preview_url?.length + ? `https://i.scdn.co/image/${m.preview_url?.split('?cid=')[1]}` + : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + duration: Util.buildTimeCode(Util.parseMS(m.duration_ms)), + views: 0, + requestedBy: message.author, + fromPlaylist: true, + source: 'spotify' + }); + return data; + }); + else { + tracks = playlist.tracks.items.map((m: any) => { + const data = new Track(this, { + title: m.track.name ?? '', + description: m.track.description ?? '', + author: m.track.artists[0]?.name ?? 'Unknown Artist', + url: m.track.external_urls?.spotify ?? query, + thumbnail: + playlist.images[0]?.url ?? m.track.preview_url?.length + ? `https://i.scdn.co/image/${m.track.preview_url?.split('?cid=')[1]}` + : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + duration: Util.buildTimeCode(Util.parseMS(m.track.duration_ms)), + views: 0, + requestedBy: message.author, + fromPlaylist: true, + source: 'spotify' }); - if (data.length) return data[0]; - }) - ); + return data; + }); + } - tracks = tracks.filter((f) => !!f); if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); const pl = { @@ -1254,10 +1279,35 @@ export class Player extends EventEmitter { } let newStream: any; - if (queue.playing.raw.source === 'youtube') { - newStream = ytdl(queue.playing.url, { + let clonedTrack = queue.playing; + + // modify spotify + if (clonedTrack.raw.source === 'spotify') { + const searchQueryString = this.options.disableArtistSearch + ? clonedTrack.title + : `${clonedTrack.title}${' - ' + clonedTrack.author}`; + const yteqv = await Util.ytSearch(searchQueryString, { + player: this, + limit: 1, + user: clonedTrack.requestedBy + }).catch(() => {}); + + if (!yteqv || !yteqv.length) + return void this.emit( + PlayerEvents.ERROR, + PlayerErrorEventCodes.VIDEO_UNAVAILABLE, + queue.firstMessage, + queue.playing, + new PlayerError('Could not find alternative track on youtube!', 'SpotifyTrackError') + ); + + clonedTrack = yteqv[0]; + } + + if (clonedTrack.raw.source === 'youtube') { + newStream = ytdl(clonedTrack.url, { opusEncoded: true, - encoderArgs: queue.playing.raw.live ? [] : encoderArgs, + encoderArgs: clonedTrack.raw.live ? [] : encoderArgs, seek: seekTime / 1000, // tslint:disable-next-line:no-bitwise highWaterMark: 1 << 25, @@ -1265,9 +1315,9 @@ export class Player extends EventEmitter { }); } else { newStream = ytdl.arbitraryStream( - queue.playing.raw.source === 'soundcloud' - ? await queue.playing.raw.engine.downloadProgressive() - : queue.playing.raw.engine, + clonedTrack.raw.source === 'soundcloud' + ? await clonedTrack.raw.engine.downloadProgressive() + : clonedTrack.raw.engine, { opusEncoded: true, encoderArgs, diff --git a/src/types/types.ts b/src/types/types.ts index 629188d..91e32e3 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -18,7 +18,7 @@ export interface PlayerOptions { export type FiltersName = keyof QueueFilters; -export type TrackSource = 'soundcloud' | 'youtube' | 'arbitrary'; +export type TrackSource = 'soundcloud' | 'youtube' | 'spotify' | 'arbitrary'; export interface TrackData { title: string; From 5d0e93fc263030519d51d801be76d78a56334ef0 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 11:19:44 +0545 Subject: [PATCH 47/65] method: queue#destroy --- src/Structures/Queue.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index a8fa7a5..5375996 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -197,6 +197,14 @@ export class Queue extends EventEmitter { return Object.keys(this.filters).filter((f) => !enabled.includes(f)); } + /** + * Destroys this queue + * @returns {Boolean} + */ + destroy() { + return this.player.stop(this.firstMessage); + } + /** * String representation of this Queue * @returns {String} From f2c458d7858e43d46a5aba8ac586b7578f46287e Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 11:20:07 +0545 Subject: [PATCH 48/65] jsdoc --- src/Structures/Queue.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index 5375996..7398466 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -167,7 +167,7 @@ export class Queue extends EventEmitter { /** * Sets audio filters in this player * @param {QueueFilters} filters Audio filters to set - * @type {Promise} + * @returns {Promise} */ setFilters(filters: QueueFilters): Promise { return this.player.setFilters(this.firstMessage, filters); @@ -175,7 +175,7 @@ export class Queue extends EventEmitter { /** * Returns array of all enabled filters - * @type {String[]} + * @returns {String[]} */ getFiltersEnabled(): string[] { const filters: string[] = []; @@ -189,7 +189,7 @@ export class Queue extends EventEmitter { /** * Returns all disabled filters - * @type {String[]} + * @returns {String[]} */ getFiltersDisabled(): string[] { const enabled = this.getFiltersEnabled(); From 7753f3573706d93476a182fed20da37842d69a2a Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 11:23:18 +0545 Subject: [PATCH 49/65] getter: Track#source --- src/Structures/Track.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Structures/Track.ts b/src/Structures/Track.ts index b2759f1..c92c057 100644 --- a/src/Structures/Track.ts +++ b/src/Structures/Track.ts @@ -133,6 +133,14 @@ export class Track { .map((m, i) => parseInt(m) * times(60, i)) .reduce((a, c) => a + c, 0); } + + /** + * Returns source of this track + * @type {TrackSource} + */ + get source() { + return this.raw.source ?? 'arbitrary'; + } /** * String representation of this track From 139a7aeb68a27b51794d89e2f7db7413edd3f5f2 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 11:26:41 +0545 Subject: [PATCH 50/65] typo --- src/Player.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Player.ts b/src/Player.ts index baa9e7d..4f9444b 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -1567,7 +1567,7 @@ export default Player; * @property {String} thumbnail The thumbnail * @property {String} image The image * @property {String} url The url - * @property {Object} artist The artust info + * @property {Object} artist The artist info * @property {String} [artist.name] The name of the artist * @property {Number} [artist.id] The ID of the artist * @property {String} [artist.url] The profile link of the artist From 76b76a27cc331dddb6882698e22a28aef8e465b9 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 12:09:28 +0545 Subject: [PATCH 51/65] cache youtube links for spotify --- src/Player.ts | 28 ++++++++++++++++------------ src/Structures/Track.ts | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 4f9444b..29e4d87 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -1279,17 +1279,16 @@ export class Player extends EventEmitter { } let newStream: any; - let clonedTrack = queue.playing; // modify spotify - if (clonedTrack.raw.source === 'spotify') { + if (queue.playing.raw.source === 'spotify' && !(queue.playing as any).backupLink) { const searchQueryString = this.options.disableArtistSearch - ? clonedTrack.title - : `${clonedTrack.title}${' - ' + clonedTrack.author}`; + ? queue.playing.title + : `${queue.playing.title}${' - ' + queue.playing.author}`; const yteqv = await Util.ytSearch(searchQueryString, { player: this, limit: 1, - user: clonedTrack.requestedBy + user: queue.playing.requestedBy }).catch(() => {}); if (!yteqv || !yteqv.length) @@ -1301,13 +1300,18 @@ export class Player extends EventEmitter { new PlayerError('Could not find alternative track on youtube!', 'SpotifyTrackError') ); - clonedTrack = yteqv[0]; + Object.defineProperty(queue.playing, 'backupLink', { + value: yteqv[0].url, + writable: true, + enumerable: false, + configurable: true + }); } - if (clonedTrack.raw.source === 'youtube') { - newStream = ytdl(clonedTrack.url, { + if (queue.playing.raw.source === 'youtube' || queue.playing.raw.source === 'spotify') { + newStream = ytdl((queue.playing as any).backupLink ?? queue.playing.url, { opusEncoded: true, - encoderArgs: clonedTrack.raw.live ? [] : encoderArgs, + encoderArgs: queue.playing.raw.live ? [] : encoderArgs, seek: seekTime / 1000, // tslint:disable-next-line:no-bitwise highWaterMark: 1 << 25, @@ -1315,9 +1319,9 @@ export class Player extends EventEmitter { }); } else { newStream = ytdl.arbitraryStream( - clonedTrack.raw.source === 'soundcloud' - ? await clonedTrack.raw.engine.downloadProgressive() - : clonedTrack.raw.engine, + queue.playing.raw.source === 'soundcloud' + ? await queue.playing.raw.engine.downloadProgressive() + : queue.playing.raw.engine, { opusEncoded: true, encoderArgs, diff --git a/src/Structures/Track.ts b/src/Structures/Track.ts index c92c057..e24b791 100644 --- a/src/Structures/Track.ts +++ b/src/Structures/Track.ts @@ -133,7 +133,7 @@ export class Track { .map((m, i) => parseInt(m) * times(60, i)) .reduce((a, c) => a + c, 0); } - + /** * Returns source of this track * @type {TrackSource} From bead343493968f97acea5b56c945232c2ba3b81c Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 12:16:30 +0545 Subject: [PATCH 52/65] v4.0.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e4d3251..64a3309 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player", - "version": "4.0.7", + "version": "4.0.8", "description": "Complete framework to facilitate music commands using discord.js", "main": "lib/index.js", "types": "lib/index.d.ts", From 30af411c075d84f45ee034283a832b7867b99752 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 13:55:11 +0545 Subject: [PATCH 53/65] fetchBeforeQueued --- src/Player.ts | 64 ++++++++++++++++++++++++++++++++++++---------- src/types/types.ts | 1 + src/utils/Util.ts | 15 +++++++++++ 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 29e4d87..7018fb4 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -203,6 +203,19 @@ export class Player extends EventEmitter { source: 'spotify' }); + if (this.options.fetchBeforeQueued) { + const searchQueryString = this.options.disableArtistSearch + ? spotifyTrack.title + : `${spotifyTrack.title}${' - ' + spotifyTrack.author}`; + const ytv = await YouTube.search(searchQueryString, { limit: 1, type: "video" }).catch(e => { }); + + if (ytv && ytv[0]) Util.define({ + target: spotifyTrack, + prop: 'backupLink', + value: ytv[0].url + }); + } + tracks = [spotifyTrack]; } } @@ -219,7 +232,7 @@ export class Player extends EventEmitter { let tracks: Track[] = []; if (playlist.type !== 'playlist') - tracks = playlist.tracks.items.map((m: any) => { + tracks = await Promise.all(playlist.tracks.items.map(async (m: any) => { const data = new Track(this, { title: m.name ?? '', description: m.description ?? '', @@ -235,10 +248,24 @@ export class Player extends EventEmitter { fromPlaylist: true, source: 'spotify' }); + + if (this.options.fetchBeforeQueued) { + const searchQueryString = this.options.disableArtistSearch + ? data.title + : `${data.title}${' - ' + data.author}`; + const ytv = await YouTube.search(searchQueryString, { limit: 1, type: "video" }).catch(e => { }); + + if (ytv && ytv[0]) Util.define({ + target: data, + prop: 'backupLink', + value: ytv[0].url + }); + } + return data; - }); + })); else { - tracks = playlist.tracks.items.map((m: any) => { + tracks = await Promise.all(playlist.tracks.items.map(async (m: any) => { const data = new Track(this, { title: m.track.name ?? '', description: m.track.description ?? '', @@ -255,8 +282,21 @@ export class Player extends EventEmitter { source: 'spotify' }); + if (this.options.fetchBeforeQueued) { + const searchQueryString = this.options.disableArtistSearch + ? data.title + : `${data.title}${' - ' + data.author}`; + const ytv = await YouTube.search(searchQueryString, { limit: 1, type: "video" }).catch(e => {}); + + if (ytv && ytv[0]) Util.define({ + target: data, + prop: 'backupLink', + value: ytv[0].url + }); + } + return data; - }); + })); } if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); @@ -1285,11 +1325,7 @@ export class Player extends EventEmitter { const searchQueryString = this.options.disableArtistSearch ? queue.playing.title : `${queue.playing.title}${' - ' + queue.playing.author}`; - const yteqv = await Util.ytSearch(searchQueryString, { - player: this, - limit: 1, - user: queue.playing.requestedBy - }).catch(() => {}); + const yteqv = await YouTube.search(searchQueryString, { type: "video", limit: 1 }).catch(() => {}); if (!yteqv || !yteqv.length) return void this.emit( @@ -1300,11 +1336,10 @@ export class Player extends EventEmitter { new PlayerError('Could not find alternative track on youtube!', 'SpotifyTrackError') ); - Object.defineProperty(queue.playing, 'backupLink', { - value: yteqv[0].url, - writable: true, - enumerable: false, - configurable: true + Util.define({ + target: queue.playing, + prop: 'backupLink', + value: yteqv[0].url }); } @@ -1496,6 +1531,7 @@ export default Player; * @property {Boolean} [useSafeSearch=false] If it should use `safe search` method for youtube searches * @property {Boolean} [disableAutoRegister=false] If it should disable auto-registeration of `@discord-player/extractor` * @property {Boolean} [disableArtistSearch=false] If it should disable artist search for spotify + * @property {Boolean} [fetchBeforeQueued=false] If it should fetch all songs loaded from spotify before playing */ /** diff --git a/src/types/types.ts b/src/types/types.ts index 91e32e3..11d48b2 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -14,6 +14,7 @@ export interface PlayerOptions { useSafeSearch?: boolean; disableAutoRegister?: boolean; disableArtistSearch?: boolean; + fetchBeforeQueued?: boolean; } export type FiltersName = keyof QueueFilters; diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 56e313f..68d74f4 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -204,6 +204,21 @@ export class Util { return null; } } + + /** + * + * @param target + * @param prop + * @param value + */ + static define(ops: { target: any, prop: any, value: any, enumerate?: boolean }) { + Object.defineProperty(ops.target, ops.prop, { + value: ops.value, + writable: true, + enumerable: Boolean(ops.enumerate), + configurable: true + }); + } } export default Util; From 82cfc913c82848ff1c753f4b4c072c43ad31850b Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 13:55:41 +0545 Subject: [PATCH 54/65] (chore) prettier --- src/Player.ts | 150 +++++++++++++++++++++++++--------------------- src/utils/Util.ts | 10 ++-- 2 files changed, 88 insertions(+), 72 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 7018fb4..10abc9e 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -207,13 +207,17 @@ export class Player extends EventEmitter { const searchQueryString = this.options.disableArtistSearch ? spotifyTrack.title : `${spotifyTrack.title}${' - ' + spotifyTrack.author}`; - const ytv = await YouTube.search(searchQueryString, { limit: 1, type: "video" }).catch(e => { }); + const ytv = await YouTube.search(searchQueryString, { + limit: 1, + type: 'video' + }).catch((e) => {}); - if (ytv && ytv[0]) Util.define({ - target: spotifyTrack, - prop: 'backupLink', - value: ytv[0].url - }); + if (ytv && ytv[0]) + Util.define({ + target: spotifyTrack, + prop: 'backupLink', + value: ytv[0].url + }); } tracks = [spotifyTrack]; @@ -232,71 +236,83 @@ export class Player extends EventEmitter { let tracks: Track[] = []; if (playlist.type !== 'playlist') - tracks = await Promise.all(playlist.tracks.items.map(async (m: any) => { - const data = new Track(this, { - title: m.name ?? '', - description: m.description ?? '', - author: m.artists[0]?.name ?? 'Unknown Artist', - url: m.external_urls?.spotify ?? query, - thumbnail: - playlist.images[0]?.url ?? m.preview_url?.length - ? `https://i.scdn.co/image/${m.preview_url?.split('?cid=')[1]}` - : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', - duration: Util.buildTimeCode(Util.parseMS(m.duration_ms)), - views: 0, - requestedBy: message.author, - fromPlaylist: true, - source: 'spotify' - }); - - if (this.options.fetchBeforeQueued) { - const searchQueryString = this.options.disableArtistSearch - ? data.title - : `${data.title}${' - ' + data.author}`; - const ytv = await YouTube.search(searchQueryString, { limit: 1, type: "video" }).catch(e => { }); - - if (ytv && ytv[0]) Util.define({ - target: data, - prop: 'backupLink', - value: ytv[0].url + tracks = await Promise.all( + playlist.tracks.items.map(async (m: any) => { + const data = new Track(this, { + title: m.name ?? '', + description: m.description ?? '', + author: m.artists[0]?.name ?? 'Unknown Artist', + url: m.external_urls?.spotify ?? query, + thumbnail: + playlist.images[0]?.url ?? m.preview_url?.length + ? `https://i.scdn.co/image/${m.preview_url?.split('?cid=')[1]}` + : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + duration: Util.buildTimeCode(Util.parseMS(m.duration_ms)), + views: 0, + requestedBy: message.author, + fromPlaylist: true, + source: 'spotify' }); - } - return data; - })); + if (this.options.fetchBeforeQueued) { + const searchQueryString = this.options.disableArtistSearch + ? data.title + : `${data.title}${' - ' + data.author}`; + const ytv = await YouTube.search(searchQueryString, { + limit: 1, + type: 'video' + }).catch((e) => {}); + + if (ytv && ytv[0]) + Util.define({ + target: data, + prop: 'backupLink', + value: ytv[0].url + }); + } + + return data; + }) + ); else { - tracks = await Promise.all(playlist.tracks.items.map(async (m: any) => { - const data = new Track(this, { - title: m.track.name ?? '', - description: m.track.description ?? '', - author: m.track.artists[0]?.name ?? 'Unknown Artist', - url: m.track.external_urls?.spotify ?? query, - thumbnail: - playlist.images[0]?.url ?? m.track.preview_url?.length - ? `https://i.scdn.co/image/${m.track.preview_url?.split('?cid=')[1]}` - : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', - duration: Util.buildTimeCode(Util.parseMS(m.track.duration_ms)), - views: 0, - requestedBy: message.author, - fromPlaylist: true, - source: 'spotify' - }); - - if (this.options.fetchBeforeQueued) { - const searchQueryString = this.options.disableArtistSearch - ? data.title - : `${data.title}${' - ' + data.author}`; - const ytv = await YouTube.search(searchQueryString, { limit: 1, type: "video" }).catch(e => {}); - - if (ytv && ytv[0]) Util.define({ - target: data, - prop: 'backupLink', - value: ytv[0].url + tracks = await Promise.all( + playlist.tracks.items.map(async (m: any) => { + const data = new Track(this, { + title: m.track.name ?? '', + description: m.track.description ?? '', + author: m.track.artists[0]?.name ?? 'Unknown Artist', + url: m.track.external_urls?.spotify ?? query, + thumbnail: + playlist.images[0]?.url ?? m.track.preview_url?.length + ? `https://i.scdn.co/image/${m.track.preview_url?.split('?cid=')[1]}` + : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + duration: Util.buildTimeCode(Util.parseMS(m.track.duration_ms)), + views: 0, + requestedBy: message.author, + fromPlaylist: true, + source: 'spotify' }); - } - return data; - })); + if (this.options.fetchBeforeQueued) { + const searchQueryString = this.options.disableArtistSearch + ? data.title + : `${data.title}${' - ' + data.author}`; + const ytv = await YouTube.search(searchQueryString, { + limit: 1, + type: 'video' + }).catch((e) => {}); + + if (ytv && ytv[0]) + Util.define({ + target: data, + prop: 'backupLink', + value: ytv[0].url + }); + } + + return data; + }) + ); } if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query); @@ -1325,7 +1341,7 @@ export class Player extends EventEmitter { const searchQueryString = this.options.disableArtistSearch ? queue.playing.title : `${queue.playing.title}${' - ' + queue.playing.author}`; - const yteqv = await YouTube.search(searchQueryString, { type: "video", limit: 1 }).catch(() => {}); + const yteqv = await YouTube.search(searchQueryString, { type: 'video', limit: 1 }).catch(() => {}); if (!yteqv || !yteqv.length) return void this.emit( diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 68d74f4..12c5671 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -206,12 +206,12 @@ export class Util { } /** - * - * @param target - * @param prop - * @param value + * + * @param target + * @param prop + * @param value */ - static define(ops: { target: any, prop: any, value: any, enumerate?: boolean }) { + static define(ops: { target: any; prop: any; value: any; enumerate?: boolean }) { Object.defineProperty(ops.target, ops.prop, { value: ops.value, writable: true, From f4f9136956dafae071602bfdd8909240ef088409 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 13:57:33 +0545 Subject: [PATCH 55/65] do not remove initial track from the playlist object --- src/Player.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 10abc9e..d73eb6b 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -331,7 +331,7 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); } else { - const track = tracks.shift(); + const track = tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; @@ -387,7 +387,7 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist); } else { - const track = tracks.shift(); + const track = tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; @@ -442,7 +442,7 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, res.tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res); } else { - const track = res.tracks.shift(); + const track = res.tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; From 9e2203ca8c020de76ce5e7ca941c0249a79429b0 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 14:00:58 +0545 Subject: [PATCH 56/65] fix docs --- src/utils/Util.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/Util.ts b/src/utils/Util.ts index 12c5671..9ba4bf0 100644 --- a/src/utils/Util.ts +++ b/src/utils/Util.ts @@ -206,10 +206,11 @@ export class Util { } /** - * - * @param target - * @param prop - * @param value + * Defines a property in the given object + * @param {any} target The target + * @param {any} prop The property to define + * @param {any} value The value + * @returns {void} */ static define(ops: { target: any; prop: any; value: any; enumerate?: boolean }) { Object.defineProperty(ops.target, ops.prop, { From 160e887b64ee9d7edc2e33f20580ae3613c20dd0 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 14:31:36 +0545 Subject: [PATCH 57/65] allow extractors to specify source type --- src/Player.ts | 2 +- src/types/types.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Player.ts b/src/Player.ts index d73eb6b..05c773c 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -556,7 +556,7 @@ export class Player extends EventEmitter { author: data.author, views: data.views, engine: data.engine, - source: 'arbitrary', + source: data.source ?? 'arbitrary', fromPlaylist: false, requestedBy: message.author, url: data.url diff --git a/src/types/types.ts b/src/types/types.ts index 11d48b2..bc9c541 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -92,6 +92,7 @@ export interface ExtractorModelData { url: string; version?: string; important?: boolean; + source?: TrackSource; } export interface PlayerProgressbarOptions { From 4face50dd670c4bcaecfd2fe01ccf308f719b8a4 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 21:56:20 +0545 Subject: [PATCH 58/65] revert playlistAdd update --- src/Player.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 05c773c..5aecb9d 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -331,7 +331,7 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); } else { - const track = tracks[0]; + const track = tracks.shift(); const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; @@ -387,7 +387,7 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist); } else { - const track = tracks[0]; + const track = tracks.shift(); const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; @@ -442,7 +442,7 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, res.tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res); } else { - const track = res.tracks[0]; + const track = res.tracks.shift(); const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; From 1eb2aa56955e1f945dc99cca185fbdca78e6bffe Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 22:09:09 +0545 Subject: [PATCH 59/65] fix spotify thumbnails bug --- src/Player.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 5aecb9d..97837d3 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -244,9 +244,7 @@ export class Player extends EventEmitter { author: m.artists[0]?.name ?? 'Unknown Artist', url: m.external_urls?.spotify ?? query, thumbnail: - playlist.images[0]?.url ?? m.preview_url?.length - ? `https://i.scdn.co/image/${m.preview_url?.split('?cid=')[1]}` - : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + playlist.images[0]?.url ?? 'https://www.scdn.co/i/_global/twitter_card-default.jpg', duration: Util.buildTimeCode(Util.parseMS(m.duration_ms)), views: 0, requestedBy: message.author, @@ -282,10 +280,7 @@ export class Player extends EventEmitter { description: m.track.description ?? '', author: m.track.artists[0]?.name ?? 'Unknown Artist', url: m.track.external_urls?.spotify ?? query, - thumbnail: - playlist.images[0]?.url ?? m.track.preview_url?.length - ? `https://i.scdn.co/image/${m.track.preview_url?.split('?cid=')[1]}` - : 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + thumbnail: m.track.album?.images[0]?.url ?? 'https://www.scdn.co/i/_global/twitter_card-default.jpg', duration: Util.buildTimeCode(Util.parseMS(m.track.duration_ms)), views: 0, requestedBy: message.author, From f02422366ca224504b72394abd30fbd17201e90d Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Thu, 13 May 2021 22:09:55 +0545 Subject: [PATCH 60/65] v4.0.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 64a3309..4737441 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player", - "version": "4.0.8", + "version": "4.0.9", "description": "Complete framework to facilitate music commands using discord.js", "main": "lib/index.js", "types": "lib/index.d.ts", From 56a0cd63745cd46fe1fa86d047e11f761d3dbaab Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Fri, 14 May 2021 06:19:42 +0545 Subject: [PATCH 61/65] bump ytdl-core --- package.json | 2 +- src/Player.ts | 10 +++++++--- yarn.lock | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4737441..93cc9aa 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "soundcloud-scraper": "^5.0.0", "spotify-url-info": "^2.2.0", "youtube-sr": "^4.0.7", - "ytdl-core": "^4.7.0" + "ytdl-core": "^4.8.0" }, "devDependencies": { "@babel/cli": "^7.13.16", diff --git a/src/Player.ts b/src/Player.ts index 97837d3..3058f93 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -326,12 +326,13 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); } else { - const track = tracks.shift(); + const track = tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); + tracks.shift(); this._addTracksToQueue(message, tracks); } @@ -382,12 +383,13 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist); } else { - const track = tracks.shift(); + const track = tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); + tracks[0]; this._addTracksToQueue(message, tracks); } @@ -437,12 +439,13 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, res.tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res); } else { - const track = res.tracks.shift(); + const track = res.tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); + res.tracks.shift(); this._addTracksToQueue(message, res.tracks); } @@ -1549,6 +1552,7 @@ export default Player; * The type of Track source, either: * * `soundcloud` - a stream from SoundCloud * * `youtube` - a stream from YouTube + * * `spotify` - a spotify track * * `arbitrary` - arbitrary stream * @typedef {String} TrackSource */ diff --git a/yarn.lock b/yarn.lock index 24d141b..702661d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4642,10 +4642,10 @@ youtube-sr@^4.0.7: "@types/node-fetch" "^2.5.10" node-fetch "^2.6.1" -ytdl-core@^4.7.0: - version "4.7.0" - resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.7.0.tgz#2c92023536484d8a2760d1aa504df2778f87ae21" - integrity sha512-G09HeYsyLMsUCPEuK2asDqmLnOx+n5SxVV3QqGJd+iYuw5Z/qiwx7x0gxZTiAkHBsbG3WuluJWBPswZyrygKmQ== +ytdl-core@^4.8.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.8.0.tgz#d9f037a370a4b984f1f937e7a11b4531e8959443" + integrity sha512-LFhhwqFojReoaME17VpsFeiamygM0W/YNG8O02mrmS2O6Em5LjCPiJYdq7Af3CmJtBEOCdptSZ3Ql+3LGWDGvg== dependencies: m3u8stream "^0.8.3" miniget "^4.0.0" From c8f62a852379f2b87200d75cb2fba949646f12db Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Fri, 14 May 2021 06:20:19 +0545 Subject: [PATCH 62/65] (chore) prettier --- src/Player.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 3058f93..51d657f 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -244,7 +244,8 @@ export class Player extends EventEmitter { author: m.artists[0]?.name ?? 'Unknown Artist', url: m.external_urls?.spotify ?? query, thumbnail: - playlist.images[0]?.url ?? 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + playlist.images[0]?.url ?? + 'https://www.scdn.co/i/_global/twitter_card-default.jpg', duration: Util.buildTimeCode(Util.parseMS(m.duration_ms)), views: 0, requestedBy: message.author, @@ -280,7 +281,9 @@ export class Player extends EventEmitter { description: m.track.description ?? '', author: m.track.artists[0]?.name ?? 'Unknown Artist', url: m.track.external_urls?.spotify ?? query, - thumbnail: m.track.album?.images[0]?.url ?? 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + thumbnail: + m.track.album?.images[0]?.url ?? + 'https://www.scdn.co/i/_global/twitter_card-default.jpg', duration: Util.buildTimeCode(Util.parseMS(m.track.duration_ms)), views: 0, requestedBy: message.author, From 2d9c53a85892dc9e3598543a88f8c46a563b67d6 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Fri, 14 May 2021 06:20:41 +0545 Subject: [PATCH 63/65] v4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93cc9aa..a990b18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player", - "version": "4.0.9", + "version": "4.1.0", "description": "Complete framework to facilitate music commands using discord.js", "main": "lib/index.js", "types": "lib/index.d.ts", From 122c66618c1be82c989f3025b1ec1074f80bbc46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 May 2021 02:49:56 +0000 Subject: [PATCH 64/65] Bump browserslist from 4.16.4 to 4.16.6 Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.16.4 to 4.16.6. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](https://github.com/browserslist/browserslist/compare/4.16.4...4.16.6) Signed-off-by: dependabot[bot] --- yarn.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/yarn.lock b/yarn.lock index 702661d..a8c386f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1317,13 +1317,13 @@ browser-process-hrtime@^1.0.0: integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== browserslist@^4.14.5, browserslist@^4.16.4: - version "4.16.4" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.4.tgz#7ebf913487f40caf4637b892b268069951c35d58" - integrity sha512-d7rCxYV8I9kj41RH8UKYnvDYCRENUlHRgyXy/Rhr/1BaeLGfiCptEdFE8MIrvGfWbBFNjVYx76SQWvNX1j+/cQ== + version "4.16.6" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.6.tgz#d7901277a5a88e554ed305b183ec9b0c08f66fa2" + integrity sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ== dependencies: - caniuse-lite "^1.0.30001208" + caniuse-lite "^1.0.30001219" colorette "^1.2.2" - electron-to-chromium "^1.3.712" + electron-to-chromium "^1.3.723" escalade "^3.1.1" node-releases "^1.1.71" @@ -1374,10 +1374,10 @@ camelcase@^5.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== -caniuse-lite@^1.0.30001208: - version "1.0.30001214" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001214.tgz#70f153c78223515c6d37a9fde6cd69250da9d872" - integrity sha512-O2/SCpuaU3eASWVaesQirZv1MSjUNOvmugaD8zNSJqw6Vv5SGwoOpA9LJs3pNPfM745nxqPvfZY3MQKY4AKHYg== +caniuse-lite@^1.0.30001219: + version "1.0.30001230" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz#8135c57459854b2240b57a4a6786044bdc5a9f71" + integrity sha512-5yBd5nWCBS+jWKTcHOzXwo5xzcj4ePE/yjtkZyUV1BTUmrBaA9MRGC+e7mxnqXSA90CmCA8L3eKLaSUkt099IQ== caseless@~0.12.0: version "0.12.0" @@ -1910,10 +1910,10 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -electron-to-chromium@^1.3.712: - version "1.3.718" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.718.tgz#a192981ced608978410ebc011e24ecab1bb4beb3" - integrity sha512-CikzdUSShGXwjq1pcW740wK8j+KbazgHZiwzlHICejDaczM6OVsPcrZmBHPwzj9i2rj5twg20MBwp+cYZwldYA== +electron-to-chromium@^1.3.723: + version "1.3.740" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.740.tgz#e38b7d2b848f632191b643e6dabca51be2162922" + integrity sha512-Mi2m55JrX2BFbNZGKYR+2ItcGnR4O5HhrvgoRRyZQlaMGQULqDhoGkLWHzJoshSzi7k1PUofxcDbNhlFrDZNhg== emoji-regex@^7.0.1: version "7.0.3" @@ -3249,9 +3249,9 @@ node-fetch@2.6.1, node-fetch@^2.6.0, node-fetch@^2.6.1: integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== node-releases@^1.1.71: - version "1.1.71" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.71.tgz#cb1334b179896b1c89ecfdd4b725fb7bbdfc7dbb" - integrity sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg== + version "1.1.72" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.72.tgz#14802ab6b1039a79a0c7d662b610a5bbd76eacbe" + integrity sha512-LLUo+PpH3dU6XizX3iVoubUNheF/owjXCZZ5yACDxNnPtgFuludV1ZL3ayK1kVep42Rmm0+R9/Y60NQbZ2bifw== nopt@^5.0.0: version "5.0.0" From b90f739c0db2fd5dff87f5a499cdb792325f7283 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 May 2021 04:32:23 +0000 Subject: [PATCH 65/65] Bump ws from 7.4.4 to 7.4.6 Bumps [ws](https://github.com/websockets/ws) from 7.4.4 to 7.4.6. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.4.4...7.4.6) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 702661d..43f0c27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4580,9 +4580,9 @@ write@1.0.3: mkdirp "^0.5.1" ws@^7.4.4: - version "7.4.4" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59" - integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw== + version "7.4.6" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" + integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== xml-name-validator@^3.0.0: version "3.0.0"