mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-23 09:15:29 +01:00
Add Spotify artist URL support
This commit is contained in:
parent
53cd705bde
commit
6e6fbfa591
|
@ -172,8 +172,13 @@ export default class implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'artist': {
|
case 'artist': {
|
||||||
await res.stop('ope, can\'t add a whole artist');
|
// Await res.stop('ope, can\'t add a whole artist');
|
||||||
return;
|
const uri = parsed as spotifyURI.Artist;
|
||||||
|
|
||||||
|
const {body} = await this.spotify.getArtistTopTracks(uri.id, 'US');
|
||||||
|
|
||||||
|
tracks.push(...body.tracks);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
@ -185,7 +190,12 @@ export default class implements Command {
|
||||||
// Search YouTube for each track
|
// Search YouTube for each track
|
||||||
const searchForTrack = async (track: SpotifyApi.TrackObjectSimplified): Promise<QueuedSong|null> => {
|
const searchForTrack = async (track: SpotifyApi.TrackObjectSimplified): Promise<QueuedSong|null> => {
|
||||||
try {
|
try {
|
||||||
const {items: [video]} = await ytsr(`${track.name} ${track.artists[0].name} offical`, {limit: 1});
|
const {items} = await ytsr(`${track.name} ${track.artists[0].name} offical`, {limit: 5});
|
||||||
|
const video = items.find((item: { type: string }) => item.type === 'video');
|
||||||
|
|
||||||
|
if (!video) {
|
||||||
|
throw new Error('No video found for query.');
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: video.title,
|
title: video.title,
|
||||||
|
|
Loading…
Reference in a new issue