From e603461e73affaa9d63047828dac47ca4b62bbda Mon Sep 17 00:00:00 2001 From: Snowflake Date: Sat, 20 Feb 2021 15:51:34 +0545 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20properly=20remove=20xvdl=20(#286)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 7 +++-- package.json | 4 +-- src/Player.js | 37 ++------------------------ src/Util.js | 7 +---- typings/index.d.ts | 66 ++++++++++++++++++++-------------------------- 5 files changed, 38 insertions(+), 83 deletions(-) diff --git a/index.js b/index.js index 409153f..05f8ee9 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,9 @@ process.env.YTDL_NO_UPDATE = true module.exports = { Extractors: require('./src/Extractors/Extractor'), - version: require('./package.json').version, - Player: require('./src/Player') + Player: require('./src/Player'), + Queue: require('./src/Queue'), + Track: require('./src/Track'), + Util: require('./src/Util'), + version: require('./package.json').version } diff --git a/package.json b/package.json index b8a9443..c20703b 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "reverbnation-scraper": "^2.0.0", "soundcloud-scraper": "^4.0.3", "spotify-url-info": "^2.2.0", - "youtube-sr": "^3.0.0", - "ytdl-core": "^4.4.3" + "youtube-sr": "^4.0.0", + "ytdl-core": "^4.5.0" }, "devDependencies": { "@discordjs/opus": "^0.4.0", diff --git a/src/Player.js b/src/Player.js index 4eebf34..4391bab 100644 --- a/src/Player.js +++ b/src/Player.js @@ -9,7 +9,7 @@ const Track = require('./Track') const Util = require('./Util') const { EventEmitter } = require('events') const Client = new soundcloud.Client() -const { VimeoExtractor, DiscordExtractor, FacebookExtractor, ReverbnationExtractor, XVideosExtractor } = require('./Extractors/Extractor') +const { VimeoExtractor, DiscordExtractor, FacebookExtractor, ReverbnationExtractor } = require('./Extractors/Extractor') /** * @typedef Filters @@ -194,8 +194,6 @@ class Player extends EventEmitter { return 'reverbnation' } else if (this.util.isDiscordAttachment(query)) { return 'attachment' - } else if (this.util.isXVLink(query)) { - return 'xvlink' } else { return 'youtube-video-keywords' } @@ -342,32 +340,6 @@ class Player extends EventEmitter { } }) - tracks.push(track) - } else if (queryType === 'xvlink') { - const data = await XVideosExtractor.getInfo(query).catch(() => {}) - if (!data || !(data.streams.lq || data.streams.hq)) return this.emit('noResults', message, query) - - const track = new Track({ - title: data.title, - url: data.url, - thumbnail: data.thumbnail, - lengthSeconds: data.length, - description: '', - views: data.views, - author: { - name: data.channel.name - } - }, message.author, this) - - Object.defineProperties(track, { - arbitrary: { - get: () => true - }, - stream: { - get: () => data.streams.lq || data.streams.hq - } - }) - tracks.push(track) } @@ -697,7 +669,7 @@ class Player extends EventEmitter { /** * Custom search function * @param {string} query Search query - * @param {("youtube"|"soundcloud"|"xvideos")} type Search type + * @param {("youtube"|"soundcloud")} type Search type * @returns {Promise} */ async search (query, type = 'youtube') { @@ -706,11 +678,6 @@ class Player extends EventEmitter { switch (type.toLowerCase()) { case 'soundcloud': return await Client.search(query, 'track').catch(() => {}) || [] - case 'xvideos': - // eslint-disable-next-line - let videos = await XVideosExtractor.search(query).catch(() => {}) - if (!videos) return [] - return videos.videos default: return ytsr.search(query, { type: 'video' }).catch(() => {}) || [] } diff --git a/src/Util.js b/src/Util.js index 3bbc902..9c731f0 100644 --- a/src/Util.js +++ b/src/Util.js @@ -7,7 +7,6 @@ const spotifyPlaylistRegex = (/https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(? const spotifyAlbumRegex = (/https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:album\/|\?uri=spotify:album:)((\w|-){22})/) const vimeoRegex = (/(http|https)?:\/\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/) const facebookRegex = (/(https?:\/\/)(www\.|m\.)?(facebook|fb).com\/.*\/videos\/.*/) -const xvRegex = (/(http|https):\/\/(.+)?xvideos.com\/(.+)\/(.+)/) module.exports = class Util { constructor () { @@ -20,7 +19,7 @@ module.exports = class Util { prism.FFmpeg.getInfo() return true } catch { - this.alertFFMPEG() + Util.alertFFMPEG() return false } } @@ -81,10 +80,6 @@ module.exports = class Util { return /https:\/\/cdn.discordapp.com\/attachments\/(\d{17,19})\/(\d{17,19})\/(.+)/.test(query) } - static isXVLink (query) { - return xvRegex.test(query) - } - static buildTimecode (data) { const items = Object.keys(data) const required = ['days', 'hours', 'minutes', 'seconds'] diff --git a/typings/index.d.ts b/typings/index.d.ts index 1d8b129..1879c70 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -44,7 +44,7 @@ declare module 'discord-player' { public setRepeatMode(message: Message, enabled: boolean): boolean; public setLoopMode(message: Message, enabled: boolean): boolean public shuffle(message: Message): Queue; - public remove(message: Message, trackOrPosition: Track|number): Track; + public remove(message: Message, trackOrPosition: Track | number): Track; public createProgressBar(message: Message, progressBarOptions: ProgressBarOptions): string; public on(event: K, listener: (...args: PlayerEvents[K]) => void): this; @@ -61,34 +61,34 @@ declare module 'discord-player' { autoSelfDeaf: boolean; quality: MusicQuality; } - type Filters = - | 'bassboost' - | '8D' - | 'vaporwave' + type Filters = + | 'bassboost' + | '8D' + | 'vaporwave' | 'nightcore' - | 'phaser' - | 'tremolo' - | 'vibrato' - | 'reverse' - | 'treble' - | 'normalizer' - | 'surrounding' - | 'pulsator' - | 'subboost' - | 'karaoke' - | 'flanger' - | 'gate' - | 'haas' - | 'mcompand' - | 'mono' - | 'mstlr' - | 'mstrr' - | 'compressor' - | 'expander' - | 'softlimiter' - | 'chorus' - | 'chorus2d' - | 'chorus3d' + | 'phaser' + | 'tremolo' + | 'vibrato' + | 'reverse' + | 'treble' + | 'normalizer' + | 'surrounding' + | 'pulsator' + | 'subboost' + | 'karaoke' + | 'flanger' + | 'gate' + | 'haas' + | 'mcompand' + | 'mono' + | 'mstlr' + | 'mstrr' + | 'compressor' + | 'expander' + | 'softlimiter' + | 'chorus' + | 'chorus2d' + | 'chorus3d' | 'fadein'; type FiltersStatuses = { @@ -234,16 +234,6 @@ declare module 'discord-player' { avatar: string; }; url: string; - reactions: { - total: number; - like: number; - love: number; - care: number; - wow: number; - haha: number; - sad: number; - angry: number; - }; shares: string; views: string; }