@discord-player/extractor as dev dependency
This commit is contained in:
parent
9d175d3f3f
commit
63e0e7bece
4 changed files with 34 additions and 16 deletions
|
@ -4,7 +4,9 @@
|
||||||
"description": "Complete framework to facilitate music commands using discord.js",
|
"description": "Complete framework to facilitate music commands using discord.js",
|
||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"files": ["lib/"],
|
"files": [
|
||||||
|
"lib/"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "yarn build && cd test && node index.js",
|
"test": "yarn build && cd test && node index.js",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
@ -36,7 +38,6 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/Androz2091/discord-player#readme",
|
"homepage": "https://github.com/Androz2091/discord-player#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discord-player/extractor": "^2.0.0",
|
|
||||||
"discord-ytdl-core": "^5.0.2",
|
"discord-ytdl-core": "^5.0.2",
|
||||||
"soundcloud-scraper": "^4.0.3",
|
"soundcloud-scraper": "^4.0.3",
|
||||||
"spotify-url-info": "^2.2.0",
|
"spotify-url-info": "^2.2.0",
|
||||||
|
@ -44,6 +45,7 @@
|
||||||
"ytdl-core": "^4.5.0"
|
"ytdl-core": "^4.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@discord-player/extractor": "^2.0.0",
|
||||||
"@discordjs/opus": "^0.5.0",
|
"@discordjs/opus": "^0.5.0",
|
||||||
"@types/node": "^14.14.41",
|
"@types/node": "^14.14.41",
|
||||||
"@types/ws": "^7.4.1",
|
"@types/ws": "^7.4.1",
|
||||||
|
|
|
@ -23,9 +23,6 @@ import spotify from 'spotify-url-info';
|
||||||
import { Client as SoundCloudClient } from 'soundcloud-scraper';
|
import { Client as SoundCloudClient } from 'soundcloud-scraper';
|
||||||
import YouTube from 'youtube-sr';
|
import YouTube from 'youtube-sr';
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
import * as DP_EXTRACTORS from '@discord-player/extractor';
|
|
||||||
|
|
||||||
const SoundCloud = new SoundCloudClient();
|
const SoundCloud = new SoundCloudClient();
|
||||||
|
|
||||||
export class Player extends EventEmitter {
|
export class Player extends EventEmitter {
|
||||||
|
@ -76,7 +73,11 @@ export class Player extends EventEmitter {
|
||||||
|
|
||||||
this.client.on('voiceStateUpdate', (o, n) => void this._handleVoiceStateUpdate(o, n));
|
this.client.on('voiceStateUpdate', (o, n) => void this._handleVoiceStateUpdate(o, n));
|
||||||
|
|
||||||
['Attachment', 'Facebook', 'Reverbnation', 'Vimeo'].forEach((ext) => void this.use(ext, DP_EXTRACTORS[ext]));
|
// auto detect @discord-player/extractor
|
||||||
|
let nv: any;
|
||||||
|
if ((nv = Util.require('@discord-player/extractor'))) {
|
||||||
|
['Attachment', 'Facebook', 'Reverbnation', 'Vimeo'].forEach((ext) => void this.use(ext, nv[ext]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static get AudioFilters() {
|
static get AudioFilters() {
|
||||||
|
@ -876,7 +877,10 @@ export class Player extends EventEmitter {
|
||||||
* message.channel.send(lyrics.lyrics);
|
* message.channel.send(lyrics.lyrics);
|
||||||
*/
|
*/
|
||||||
async lyrics(query: string) {
|
async lyrics(query: string) {
|
||||||
const data = await DP_EXTRACTORS.Lyrics(query);
|
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);
|
||||||
if (Array.isArray(data)) return null;
|
if (Array.isArray(data)) return null;
|
||||||
|
|
||||||
return data as LyricsData;
|
return data as LyricsData;
|
||||||
|
|
|
@ -152,6 +152,18 @@ export class Util {
|
||||||
.join(':');
|
.join(':');
|
||||||
return final.length <= 3 ? `0:${final.padStart(2, '0') || 0}` : final;
|
return final.length <= 3 ? `0:${final.padStart(2, '0') || 0}` : final;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage CJS require
|
||||||
|
* @param id id to require
|
||||||
|
*/
|
||||||
|
static require(id: string): any {
|
||||||
|
try {
|
||||||
|
return require(id);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Util;
|
export default Util;
|
||||||
|
|
18
yarn.lock
18
yarn.lock
|
@ -123,9 +123,9 @@ acorn@^7.1.1:
|
||||||
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
|
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
|
||||||
|
|
||||||
acorn@^8.1.0:
|
acorn@^8.1.0:
|
||||||
version "8.1.0"
|
version "8.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.1.0.tgz#52311fd7037ae119cbb134309e901aa46295b3fe"
|
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.1.1.tgz#fb0026885b9ac9f48bac1e185e4af472971149ff"
|
||||||
integrity sha512-LWCF/Wn0nfHOmJ9rzQApGnxnvgfROzGilS8936rqN/lfcYkY9MYZzdMqN+2NJ4SlTc+m5HiSa+kNfDtI64dwUA==
|
integrity sha512-xYiIVjNuqtKXMxlRMDc6mZUhXehod4a3gbZ1qRlM7icK4EbxUFNLhWoPblCvFtB2Y9CIqHP3CF/rdxLItaQv8g==
|
||||||
|
|
||||||
agent-base@6:
|
agent-base@6:
|
||||||
version "6.0.2"
|
version "6.0.2"
|
||||||
|
@ -808,9 +808,9 @@ jsbn@~0.1.0:
|
||||||
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
|
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
|
||||||
|
|
||||||
jsdom@^16.5.2:
|
jsdom@^16.5.2:
|
||||||
version "16.5.2"
|
version "16.5.3"
|
||||||
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.5.2.tgz#583fac89a0aea31dbf6237e7e4bedccd9beab472"
|
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.5.3.tgz#13a755b3950eb938b4482c407238ddf16f0d2136"
|
||||||
integrity sha512-JxNtPt9C1ut85boCbJmffaQ06NBnzkQY/MWO3YxPW8IWS38A26z+B1oBvA9LwKrytewdfymnhi4UNH3/RAgZrg==
|
integrity sha512-Qj1H+PEvUsOtdPJ056ewXM4UJPCi4hhLA8wpiz9F2YvsRBhuFsXxtrIFAgGBDynQA9isAMGE91PfUYbdMPXuTA==
|
||||||
dependencies:
|
dependencies:
|
||||||
abab "^2.0.5"
|
abab "^2.0.5"
|
||||||
acorn "^8.1.0"
|
acorn "^8.1.0"
|
||||||
|
@ -971,9 +971,9 @@ node-fetch@2.6.1, node-fetch@^2.6.0, node-fetch@^2.6.1:
|
||||||
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
|
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
|
||||||
|
|
||||||
node-html-parser@^3.0.4:
|
node-html-parser@^3.0.4:
|
||||||
version "3.1.3"
|
version "3.1.5"
|
||||||
resolved "https://registry.yarnpkg.com/node-html-parser/-/node-html-parser-3.1.3.tgz#987d39bc8df27bc70cbe3b4e9a31fd84f7454dfb"
|
resolved "https://registry.yarnpkg.com/node-html-parser/-/node-html-parser-3.1.5.tgz#ffb62f2a336b6b634f41f3315487fe446fb9d7b5"
|
||||||
integrity sha512-pCE2I5UY5iOBnWdJQkbYZSk+fyq2zepw0nsELpHQjVFyCzOeZhkMhnvKqGceKgzWsWx7EG4KtMqsy9Eklf5Thw==
|
integrity sha512-/XKKdWbSUymlXTjtNBcDlmM7Jp8S/BqGMzLx7r2bd2NMjTXz+ofuLcz0Bl3VT0vTvVzF+N511FNLrZt4HVitXA==
|
||||||
dependencies:
|
dependencies:
|
||||||
css-select "^3.1.2"
|
css-select "^3.1.2"
|
||||||
he "1.2.0"
|
he "1.2.0"
|
||||||
|
|
Loading…
Reference in a new issue