Artist images from getArtistInfo

This commit is contained in:
simojenki
2021-03-05 14:46:12 +11:00
parent 4dae907826
commit 5ad0da5168
7 changed files with 407 additions and 210 deletions

View File

@@ -6,7 +6,12 @@ import path from "path";
import logger from "./logger";
import { LinkCodes } from "./link_codes";
import { Album, Artist, MusicLibrary, MusicService } from "./music_service";
import {
Album,
ArtistSummary,
MusicLibrary,
MusicService,
} from "./music_service";
export const LOGIN_ROUTE = "/login";
export const SOAP_PATH = "/ws/sonos";
@@ -227,35 +232,41 @@ function bindSmapiSoapServiceToExpress(
case "artists":
return await musicLibrary
.artists(paging)
.then(({ results, total }: { results: Artist[], total: number}) =>
getMetadataResult({
mediaCollection: results.map((it) =>
({
.then(
({
results,
total,
}: {
results: ArtistSummary[];
total: number;
}) =>
getMetadataResult({
mediaCollection: results.map((it) => ({
itemType: "artist",
id: `artist:${it.id}`,
artistId: it.id,
title: it.name,
albumArtURI: it.image.small
})
),
index: paging._index,
total,
})
albumArtURI: it.image.small,
})),
index: paging._index,
total,
})
);
case "albums":
return await musicLibrary
.albums(paging)
.then(({ results, total }: { results: Album[], total: number}) =>
getMetadataResult({
mediaCollection: results.map((it) =>
container({
id: `album:${it.id}`,
title: it.name,
})
),
index: paging._index,
total,
})
.then(
({ results, total }: { results: Album[]; total: number }) =>
getMetadataResult({
mediaCollection: results.map((it) =>
container({
id: `album:${it.id}`,
title: it.name,
})
),
index: paging._index,
total,
})
);
default:
throw `Unsupported id:${id}`;