This commit is contained in:
Snowflake107 2021-05-09 18:09:06 +05:45
parent e1be3f73ca
commit 892fc29a18

View file

@ -177,18 +177,18 @@ export class Player extends EventEmitter {
}
break;
// todo: make spotify playlist/album load faster
case 'spotify_album':
case 'spotify_playlist': {
this.emit(PlayerEvents.PLAYLIST_PARSE_START, null, message);
const playlist = await spotify.getData(query);
if (!playlist) return void this.emit(PlayerEvents.NO_RESULTS, message, query);
const tracks = await Promise.all(playlist.tracks.items.map(async (track) => {
const tracks = await Promise.all<Track>(playlist.tracks.items.map(async (item: any) => {
const sq =
queryType === 'spotify_album'
? `${item.artists[0].name} - ${item.name}`
: `${item.track.artists[0].name} - ${item.name}`;
const data = await Util.ytSearch(sq, {
limit: 1,
player: this,
@ -196,7 +196,7 @@ export class Player extends EventEmitter {
pl: true
});
return results[0];
return data[0];
}));
if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query);