Skip to content

Commit

Permalink
Merge pull request #1740 from rishiral/fix-cd
Browse files Browse the repository at this point in the history
New UI for displaying album with multiple discs on Spotify search result
  • Loading branch information
nukeop authored Nov 26, 2024
2 parents 7fb19e5 + 640d24c commit 34ec5dd
Show file tree
Hide file tree
Showing 9 changed files with 773 additions and 163 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/plugins/meta/spotify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ describe('SpotifyMetaProvider', () => {
name: 'test track',
artists: [{ name: 'test artist' }],
duration_ms: 1000,
disc_number: 0,
type: 'track'
}]
},
Expand All @@ -379,6 +380,7 @@ describe('SpotifyMetaProvider', () => {
title: 'test track',
artist: 'test artist',
duration: 1,
discNumber: 0,
thumbnail: 'thumbnail.jpg'
}]
});
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/plugins/meta/spotify.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import spotify from '../../helpers/playlist/spotify';
import { SpotifyArtist, SpotifyClientProvider, SpotifyImage, SpotifySimplifiedAlbum, SpotifyTrack, getImageSet } from '../../rest/Spotify';
import Track from '../../structs/Track';
import MetaProvider from '../metaProvider';
Expand All @@ -13,7 +14,7 @@ export class SpotifyMetaProvider extends MetaProvider {
this.image = null;
this.isDefault = true;
}

async searchForArtists(query: string, limit=10): Promise<SearchResultsArtist[]> {
const client = await SpotifyClientProvider.get();
const results = await client.searchArtists(query, limit);
Expand Down Expand Up @@ -67,6 +68,7 @@ export class SpotifyMetaProvider extends MetaProvider {
id: spotifyTrack.id,
title: spotifyTrack.name,
artist: spotifyTrack.artists[0].name,
discNumber: spotifyTrack.disc_number,
source: SearchResultsSource.Spotify,
thumb
};
Expand Down Expand Up @@ -169,6 +171,7 @@ export class SpotifyMetaProvider extends MetaProvider {
title: track.name,
artist: result.artists[0].name,
duration: track.duration_ms/1000,
discNumber: track.disc_number,
position: track.track_number,
thumbnail: thumb
}))
Expand All @@ -181,6 +184,6 @@ export class SpotifyMetaProvider extends MetaProvider {

return this.fetchAlbumDetails(result.id, albumType);
}

}

1 change: 1 addition & 0 deletions packages/core/src/plugins/plugins.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type SearchResultsTrack = {
artist: string;
source: SearchResultsSource;
thumb?: string;
discNumber?: number | string;
}

export type ArtistTopTrack = {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/rest/Spotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export type SpotifyTrack = {
popularity: number;
track_number: number;
duration_ms: number;
disc_number: number;
type: 'track';
}

Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/structs/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export default class Track {
title: string;
name?: string;
duration: string | number;

position?: string | number;
discNumber?: string | number;
playcount?: string | number;
thumbnail?: string;
extraArtists?: string[];
Expand All @@ -35,13 +36,15 @@ export default class Track {
this.duration = data.duration;
this.position = data.position;
this.thumbnail = data.thumbnail;
this.discNumber = data.discNumber;
}

addSearchResultData(data: SearchResultsTrack): void {
this.ids = { ...this.ids, [data.source]: data.id };
this.artist = data.artist;
this.title = data.title;
this.name = data.title;
this.discNumber = data.discNumber;
}

static fromSearchResultData(data: SearchResultsTrack): Track {
Expand Down
Loading

0 comments on commit 34ec5dd

Please sign in to comment.