properly remove xvdl (#286)

This commit is contained in:
Snowflake 2021-02-20 15:51:34 +05:45 committed by GitHub
parent 36fa63f0fd
commit e603461e73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 83 deletions

View file

@ -2,6 +2,9 @@ process.env.YTDL_NO_UPDATE = true
module.exports = { module.exports = {
Extractors: require('./src/Extractors/Extractor'), 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
} }

View file

@ -40,8 +40,8 @@
"reverbnation-scraper": "^2.0.0", "reverbnation-scraper": "^2.0.0",
"soundcloud-scraper": "^4.0.3", "soundcloud-scraper": "^4.0.3",
"spotify-url-info": "^2.2.0", "spotify-url-info": "^2.2.0",
"youtube-sr": "^3.0.0", "youtube-sr": "^4.0.0",
"ytdl-core": "^4.4.3" "ytdl-core": "^4.5.0"
}, },
"devDependencies": { "devDependencies": {
"@discordjs/opus": "^0.4.0", "@discordjs/opus": "^0.4.0",

View file

@ -9,7 +9,7 @@ const Track = require('./Track')
const Util = require('./Util') const Util = require('./Util')
const { EventEmitter } = require('events') const { EventEmitter } = require('events')
const Client = new soundcloud.Client() const Client = new soundcloud.Client()
const { VimeoExtractor, DiscordExtractor, FacebookExtractor, ReverbnationExtractor, XVideosExtractor } = require('./Extractors/Extractor') const { VimeoExtractor, DiscordExtractor, FacebookExtractor, ReverbnationExtractor } = require('./Extractors/Extractor')
/** /**
* @typedef Filters * @typedef Filters
@ -194,8 +194,6 @@ class Player extends EventEmitter {
return 'reverbnation' return 'reverbnation'
} else if (this.util.isDiscordAttachment(query)) { } else if (this.util.isDiscordAttachment(query)) {
return 'attachment' return 'attachment'
} else if (this.util.isXVLink(query)) {
return 'xvlink'
} else { } else {
return 'youtube-video-keywords' 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) tracks.push(track)
} }
@ -697,7 +669,7 @@ class Player extends EventEmitter {
/** /**
* Custom search function * Custom search function
* @param {string} query Search query * @param {string} query Search query
* @param {("youtube"|"soundcloud"|"xvideos")} type Search type * @param {("youtube"|"soundcloud")} type Search type
* @returns {Promise<any[]>} * @returns {Promise<any[]>}
*/ */
async search (query, type = 'youtube') { async search (query, type = 'youtube') {
@ -706,11 +678,6 @@ class Player extends EventEmitter {
switch (type.toLowerCase()) { switch (type.toLowerCase()) {
case 'soundcloud': case 'soundcloud':
return await Client.search(query, 'track').catch(() => {}) || [] 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: default:
return ytsr.search(query, { type: 'video' }).catch(() => {}) || [] return ytsr.search(query, { type: 'video' }).catch(() => {}) || []
} }

View file

@ -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 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 vimeoRegex = (/(http|https)?:\/\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/)
const facebookRegex = (/(https?:\/\/)(www\.|m\.)?(facebook|fb).com\/.*\/videos\/.*/) const facebookRegex = (/(https?:\/\/)(www\.|m\.)?(facebook|fb).com\/.*\/videos\/.*/)
const xvRegex = (/(http|https):\/\/(.+)?xvideos.com\/(.+)\/(.+)/)
module.exports = class Util { module.exports = class Util {
constructor () { constructor () {
@ -20,7 +19,7 @@ module.exports = class Util {
prism.FFmpeg.getInfo() prism.FFmpeg.getInfo()
return true return true
} catch { } catch {
this.alertFFMPEG() Util.alertFFMPEG()
return false return false
} }
} }
@ -81,10 +80,6 @@ module.exports = class Util {
return /https:\/\/cdn.discordapp.com\/attachments\/(\d{17,19})\/(\d{17,19})\/(.+)/.test(query) return /https:\/\/cdn.discordapp.com\/attachments\/(\d{17,19})\/(\d{17,19})\/(.+)/.test(query)
} }
static isXVLink (query) {
return xvRegex.test(query)
}
static buildTimecode (data) { static buildTimecode (data) {
const items = Object.keys(data) const items = Object.keys(data)
const required = ['days', 'hours', 'minutes', 'seconds'] const required = ['days', 'hours', 'minutes', 'seconds']

66
typings/index.d.ts vendored
View file

@ -44,7 +44,7 @@ declare module 'discord-player' {
public setRepeatMode(message: Message, enabled: boolean): boolean; public setRepeatMode(message: Message, enabled: boolean): boolean;
public setLoopMode(message: Message, enabled: boolean): boolean public setLoopMode(message: Message, enabled: boolean): boolean
public shuffle(message: Message): Queue; 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 createProgressBar(message: Message, progressBarOptions: ProgressBarOptions): string;
public on<K extends keyof PlayerEvents>(event: K, listener: (...args: PlayerEvents[K]) => void): this; public on<K extends keyof PlayerEvents>(event: K, listener: (...args: PlayerEvents[K]) => void): this;
@ -61,34 +61,34 @@ declare module 'discord-player' {
autoSelfDeaf: boolean; autoSelfDeaf: boolean;
quality: MusicQuality; quality: MusicQuality;
} }
type Filters = type Filters =
| 'bassboost' | 'bassboost'
| '8D' | '8D'
| 'vaporwave' | 'vaporwave'
| 'nightcore' | 'nightcore'
| 'phaser' | 'phaser'
| 'tremolo' | 'tremolo'
| 'vibrato' | 'vibrato'
| 'reverse' | 'reverse'
| 'treble' | 'treble'
| 'normalizer' | 'normalizer'
| 'surrounding' | 'surrounding'
| 'pulsator' | 'pulsator'
| 'subboost' | 'subboost'
| 'karaoke' | 'karaoke'
| 'flanger' | 'flanger'
| 'gate' | 'gate'
| 'haas' | 'haas'
| 'mcompand' | 'mcompand'
| 'mono' | 'mono'
| 'mstlr' | 'mstlr'
| 'mstrr' | 'mstrr'
| 'compressor' | 'compressor'
| 'expander' | 'expander'
| 'softlimiter' | 'softlimiter'
| 'chorus' | 'chorus'
| 'chorus2d' | 'chorus2d'
| 'chorus3d' | 'chorus3d'
| 'fadein'; | 'fadein';
type FiltersStatuses = { type FiltersStatuses = {
@ -234,16 +234,6 @@ declare module 'discord-player' {
avatar: string; avatar: string;
}; };
url: string; url: string;
reactions: {
total: number;
like: number;
love: number;
care: number;
wow: number;
haha: number;
sad: number;
angry: number;
};
shares: string; shares: string;
views: string; views: string;
} }