make it suitable for extractor
This commit is contained in:
parent
1ce6213a04
commit
7f5fc57677
1 changed files with 2 additions and 23 deletions
|
@ -488,7 +488,7 @@ 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) track = query;
|
if (query instanceof Track) query = query.url;
|
||||||
else {
|
else {
|
||||||
for (const [_, extractor] of this.Extractors) {
|
for (const [_, extractor] of this.Extractors) {
|
||||||
if (extractor.validate(query)) {
|
if (extractor.validate(query)) {
|
||||||
|
@ -513,28 +513,7 @@ export class Player extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!track && ytdl.validateURL(query)) {
|
if (!track) track = await this._searchTracks(message, query, firstResult);
|
||||||
const info = await ytdl.getBasicInfo(query).catch(() => {});
|
|
||||||
if (!info) return void this.emit(PlayerEvents.NO_RESULTS, message, query);
|
|
||||||
if (info.videoDetails.isLiveContent && !this.options.enableLive) return void this.emit(PlayerEvents.ERROR, PlayerErrorEventCodes.LIVE_VIDEO, message, new PlayerError('Live video is not enabled!'));
|
|
||||||
const lastThumbnail = info.videoDetails.thumbnails[info.videoDetails.thumbnails.length - 1];
|
|
||||||
|
|
||||||
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 {
|
|
||||||
if (!track) track = await this._searchTracks(message, query, firstResult);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track) {
|
if (track) {
|
||||||
|
|
Loading…
Reference in a new issue