revert extractor first
This commit is contained in:
parent
33d467af13
commit
355157a753
2 changed files with 43 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "discord-player",
|
"name": "discord-player",
|
||||||
"version": "4.1.3",
|
"version": "4.1.4",
|
||||||
"description": "Complete framework to facilitate music commands using discord.js",
|
"description": "Complete framework to facilitate music commands using discord.js",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|
|
@ -488,32 +488,53 @@ export class Player extends EventEmitter {
|
||||||
if (typeof query === 'string') query = query.replace(/<(.+)>/g, '$1');
|
if (typeof query === 'string') query = query.replace(/<(.+)>/g, '$1');
|
||||||
let track;
|
let track;
|
||||||
|
|
||||||
if (query instanceof Track) query = query.url;
|
if (query instanceof Track) track = query;
|
||||||
else {
|
else {
|
||||||
for (const [_, extractor] of this.Extractors) {
|
if (ytdl.validateURL(query)) {
|
||||||
if (extractor.validate(query)) {
|
const info = await ytdl.getBasicInfo(query).catch(() => {});
|
||||||
const data = await extractor.handle(query);
|
if (!info) return void this.emit(PlayerEvents.NO_RESULTS, message, query);
|
||||||
if (data) {
|
if (info.videoDetails.isLiveContent && !this.options.enableLive) return void this.emit(PlayerEvents.ERROR, PlayerErrorEventCodes.LIVE_VIDEO, message, new PlayerError('Live video is not enabled!'));
|
||||||
track = new Track(this, {
|
const lastThumbnail = info.videoDetails.thumbnails[info.videoDetails.thumbnails.length - 1];
|
||||||
title: data.title,
|
|
||||||
description: data.description,
|
|
||||||
duration: Util.buildTimeCode(Util.parseMS(data.duration)),
|
|
||||||
thumbnail: data.thumbnail,
|
|
||||||
author: data.author,
|
|
||||||
views: data.views,
|
|
||||||
engine: data.engine,
|
|
||||||
source: data.source ?? 'arbitrary',
|
|
||||||
fromPlaylist: false,
|
|
||||||
requestedBy: message.author,
|
|
||||||
url: data.url
|
|
||||||
});
|
|
||||||
|
|
||||||
if (extractor.important) break;
|
track = new Track(this, {
|
||||||
|
title: info.videoDetails.title,
|
||||||
|
description: info.videoDetails.description,
|
||||||
|
author: info.videoDetails.author.name,
|
||||||
|
url: info.videoDetails.video_url,
|
||||||
|
thumbnail: lastThumbnail.url,
|
||||||
|
duration: Util.buildTimeCode(Util.parseMS(parseInt(info.videoDetails.lengthSeconds) * 1000)),
|
||||||
|
views: parseInt(info.videoDetails.viewCount),
|
||||||
|
requestedBy: message.author,
|
||||||
|
fromPlaylist: false,
|
||||||
|
source: 'youtube',
|
||||||
|
live: Boolean(info.videoDetails.isLiveContent)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for (const [_, extractor] of this.Extractors) {
|
||||||
|
if (extractor.validate(query)) {
|
||||||
|
const data = await extractor.handle(query);
|
||||||
|
if (data) {
|
||||||
|
track = new Track(this, {
|
||||||
|
title: data.title,
|
||||||
|
description: data.description,
|
||||||
|
duration: Util.buildTimeCode(Util.parseMS(data.duration)),
|
||||||
|
thumbnail: data.thumbnail,
|
||||||
|
author: data.author,
|
||||||
|
views: data.views,
|
||||||
|
engine: data.engine,
|
||||||
|
source: data.source ?? 'arbitrary',
|
||||||
|
fromPlaylist: false,
|
||||||
|
requestedBy: message.author,
|
||||||
|
url: data.url
|
||||||
|
});
|
||||||
|
|
||||||
|
if (extractor.important) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!track) track = await this._searchTracks(message, query, firstResult);
|
if (!track) track = await this._searchTracks(message, query, firstResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track) {
|
if (track) {
|
||||||
|
|
Loading…
Reference in a new issue