diff options
| author | Max Isom <[email protected]> | 2020-03-16 12:10:08 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2020-03-16 12:10:08 -0500 |
| commit | 6e6fbfa5913d72bb68e39a9346c8ceb09f91542a (patch) | |
| tree | 1e15c495622bfdab18b17c20bba215d2773a9bcf /src | |
| parent | 53cd705bde65ea092642e437f95ba39ec087eac8 (diff) | |
| download | muse-6e6fbfa5913d72bb68e39a9346c8ceb09f91542a.tar.xz muse-6e6fbfa5913d72bb68e39a9346c8ceb09f91542a.zip | |
Add Spotify artist URL support
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands/play.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/commands/play.ts b/src/commands/play.ts index d791be3..b354e5a 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -172,8 +172,13 @@ export default class implements Command { } case 'artist': { - await res.stop('ope, can\'t add a whole artist'); - return; + // Await res.stop('ope, can\'t add a whole artist'); + const uri = parsed as spotifyURI.Artist; + + const {body} = await this.spotify.getArtistTopTracks(uri.id, 'US'); + + tracks.push(...body.tracks); + break; } default: { @@ -185,7 +190,12 @@ export default class implements Command { // Search YouTube for each track const searchForTrack = async (track: SpotifyApi.TrackObjectSimplified): Promise<QueuedSong|null> => { 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 { title: video.title, |
