Merge pull request #375 from watchdogsrox/watchdogsrox-patch-1

Fixed spotify album/playlist loading
This commit is contained in:
MegaPixel 2021-05-08 22:38:11 +05:45 committed by GitHub
commit e1be3f73ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -177,17 +177,14 @@ 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);
// 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);
// tslint:disable:no-shadowed-variable
const tracks = [];
for (const item of playlist.tracks.items) {
const tracks = await Promise.all(playlist.tracks.items.map(async (track) => {
const sq =
queryType === 'spotify_album'
? `${item.artists[0].name} - ${item.name}`
@ -199,8 +196,8 @@ export class Player extends EventEmitter {
pl: true
});
if (data[0]) tracks.push(data[0]);
}
return results[0];
}));
if (!tracks.length) return void this.emit(PlayerEvents.NO_RESULTS, message, query);