Skip to content

Commit

Permalink
fixup! [Discogs] Adapt to new artists
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucki committed Aug 25, 2024
1 parent 5d13d4f commit 676d177
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions packages/core/src/plugins/meta/discogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DiscogsMetaProvider extends MetaProvider {

getCoverImage(entity: DiscogsReleaseInfo | DiscogsArtistInfo) {
return _.get(
_.find(entity.images, { type: 'primary' }),
_.find(entity.images, { type: 'primary' }),
'resource_url',
_.get(_.find(entity.images, { type: 'secondary' }), 'resource_url')
);
Expand All @@ -64,7 +64,7 @@ class DiscogsMetaProvider extends MetaProvider {
source: SearchResultsSource.Discogs
};
}

discogsArtistReleaseSearchResultToGeneric(release: DiscogsArtistReleaseSearchResult): SearchResultsAlbum {
return {
id: `${release.id}`,
Expand All @@ -85,9 +85,9 @@ class DiscogsMetaProvider extends MetaProvider {

release.tracklist.forEach(track => {
if (track.sub_tracks) {
track.sub_tracks.forEach(subTrack => tracklist.push(this.discogsTrackToGeneric(subTrack)));
track.sub_tracks.forEach(subTrack => tracklist.push(this.discogsTrackToGeneric(subTrack, artist)));
} else {
tracklist.push(this.discogsTrackToGeneric(track));
tracklist.push(this.discogsTrackToGeneric(track, artist));
}
});

Expand All @@ -106,13 +106,13 @@ class DiscogsMetaProvider extends MetaProvider {
};
}

discogsTrackToGeneric(discogsTrack: DiscogsTrack): Track {
discogsTrackToGeneric(discogsTrack: DiscogsTrack, albumArtist: string): Track {
const track = new Track();
track.artists = discogsTrack.artists.map(artist => artist.name);
track.artists = discogsTrack.artists?.map(artist => artist.name) ?? [albumArtist];
track.title = discogsTrack.title;
track.duration = discogsTrack.duration;
track.position = discogsTrack.position;
discogsTrack.extraartists?.forEach(artist => track.artists.push(artist.name));
track.artists = track.artists.concat(_.map(discogsTrack.extraartists, 'name'));
track.type = discogsTrack.type_;
return track;
}
Expand Down Expand Up @@ -157,15 +157,15 @@ class DiscogsMetaProvider extends MetaProvider {
(item.type === 'artist') ?
[this.discogsArtistSearchResultToGeneric(item)] : []
);

const releases = json.results.flatMap(item =>
(item.type === 'master' || item.type === 'release' ) ?
[this.discogsReleaseSearchResultToGeneric(item)] : []
);

return Promise.resolve({ artists, releases, tracks: [] });
}

return Promise.resolve({ artists: [], releases: [], tracks: [] });
});
}
Expand Down Expand Up @@ -225,7 +225,7 @@ class DiscogsMetaProvider extends MetaProvider {
albumType,
{ resource_url: resourceUrl }
)).json();

return Promise.resolve(
this.discogsReleaseInfoToGeneric(
albumData,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/rest/Discogs.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export type DiscogsTrack = {
duration: string;
position: string;
title: string;
artists: {
artists?: {
name: string;
id: number;
}[];
Expand Down

0 comments on commit 676d177

Please sign in to comment.