mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-09-03 05:10:00 +03:00
Handle album artists
This commit is contained in:
@@ -330,7 +330,17 @@ export default class MusicbrainzTransformer extends AtomicPartsTransformer<Exter
|
||||
return transformData.data.artists;
|
||||
}
|
||||
protected async handleAlbumArtists(play: PlayObject, parts: ExternalMetadataTerm, transformData: PlayObject): Promise<string[] | undefined> {
|
||||
// TODO
|
||||
if (parts === false) {
|
||||
return play.data.artists;
|
||||
}
|
||||
if (typeof parts === 'object') {
|
||||
if (parts.when !== undefined) {
|
||||
if (!testWhenConditions(parts.when, play, { testMaybeRegex: this.regex.testMaybeRegex })) {
|
||||
this.logger.debug('When condition for albumArtists not met, returning original artists');
|
||||
return play.data.artists;
|
||||
}
|
||||
}
|
||||
}
|
||||
return play.data.albumArtists;
|
||||
}
|
||||
protected async handleAlbum(play: PlayObject, parts: ExternalMetadataTerm, transformData: PlayObject): Promise<string | undefined> {
|
||||
|
||||
@@ -127,24 +127,31 @@ export class MusicbrainzApiClient extends AbstractApiClient {
|
||||
export const recordingToPlay = (data: IRecording): PlayObject => {
|
||||
|
||||
let album: IRelease;
|
||||
// try to find official album first
|
||||
album = data.releases.find(x => x.status === 'Official');
|
||||
if(album === undefined) {
|
||||
// find the first album that isn't "bad"
|
||||
album = data.releases.find(x => !['Expunged','Withdrawn'].includes(x.status));
|
||||
|
||||
let albumArtists: string[];
|
||||
const artists = (data["artist-credit"] ?? []).map(x => x.name);
|
||||
if(data.releases !== undefined && data.releases.length > 0) {
|
||||
album = data.releases[0];
|
||||
const aa = album["artist-credit"].map(x => x.name);
|
||||
// if not every artist of the recording is also on the album
|
||||
// then use release album artists
|
||||
if(!artists.every(x => aa.includes(x))) {
|
||||
albumArtists = aa;
|
||||
}
|
||||
}
|
||||
|
||||
const play: PlayObject = {
|
||||
data: {
|
||||
// TODO figure out album artists
|
||||
track: data.title,
|
||||
artists: (data["artist-credit"] ?? []).map(x => x.name),
|
||||
artists,
|
||||
album: album !== undefined ? album.title : undefined,
|
||||
albumArtists,
|
||||
meta: {
|
||||
brainz: {
|
||||
track: data.id,
|
||||
artist: data["artist-credit"].map(x => x.artist.id),
|
||||
album: album !== undefined ? album.id : undefined,
|
||||
releaseGroup: album !== undefined ? album["release-group"]?.id : undefined
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user