Linking Album->Artist so that artist name shows on albumLists

This commit is contained in:
simojenki
2021-04-21 14:35:21 +10:00
parent 9f90f54067
commit a06ae2e18e
8 changed files with 151 additions and 76 deletions

View File

@@ -50,6 +50,9 @@ export type AlbumSummary = {
name: string;
year: string | undefined;
genre: Genre | undefined;
artistName: string;
artistId: string;
};
export type Album = AlbumSummary & {};
@@ -111,6 +114,8 @@ export const albumToAlbumSummary = (it: Album): AlbumSummary => ({
name: it.name,
year: it.year,
genre: it.genre,
artistName: it.artistName,
artistId: it.artistId,
});
export type StreamingHeader = "content-type" | "content-length" | "content-range" | "accept-ranges";

View File

@@ -69,6 +69,8 @@ export type album = {
_genre: string | undefined;
_year: string | undefined;
_coverArt: string | undefined;
_artist: string;
_artistId: string;
};
export type artistSummary = {
@@ -215,6 +217,8 @@ const asAlbum = (album: album) => ({
name: album._name,
year: album._year,
genre: maybeAsGenre(album._genre),
artistId: album._artistId,
artistName: album._artist
});
export const asGenre = (genreName: string) => ({
@@ -361,6 +365,8 @@ export class Navidrome implements MusicService {
name: album._name,
year: album._year,
genre: maybeAsGenre(album._genre),
artistId: album._artistId,
artistName: album._artist
}));
getArtist = (
@@ -379,6 +385,8 @@ export class Navidrome implements MusicService {
name: album._name,
year: album._year,
genre: maybeAsGenre(album._genre),
artistId: it._id,
artistName: it._name,
})),
}));
@@ -422,6 +430,8 @@ export class Navidrome implements MusicService {
name: album._name,
year: album._year,
genre: maybeAsGenre(album._genre),
artistId: album._artistId,
artistName: album._artist
}));
search3 = (credentials: Credentials, q: any) =>

View File

@@ -135,7 +135,7 @@ function server(
<Category id="tracks"/>
</SearchCategories>
</Match>
</PresentationMap>
</PresentationMap>
</Presentation>`);
});

View File

@@ -188,30 +188,15 @@ class SonosSoap {
}
}
export type ContainerType = "container" | "search" | "albumList";
export type Container = {
itemType: "container" | "search";
itemType: ContainerType;
id: string;
title: string;
displayType: string | undefined
};
const container = ({
id,
title,
}: {
id: string;
title: string;
}): Container => ({
itemType: "container",
id,
title,
});
const search = ({ id, title }: { id: string; title: string }): Container => ({
itemType: "search",
id,
title,
});
const genre = (genre: Genre) => ({
itemType: "container",
id: `genre:${genre.id}`,
@@ -239,6 +224,8 @@ export const album = (
) => ({
itemType: "album",
id: `album:${album.id}`,
artist: album.artistName,
artistId: album.artistId,
title: album.name,
albumArtURI: defaultAlbumArtURI(webAddress, accessToken, album),
canPlay: true,
@@ -262,10 +249,10 @@ export const track = (
albumArtURI: defaultAlbumArtURI(webAddress, accessToken, track.album),
artist: track.artist.name,
artistId: track.artist.id,
duration: `${track.duration}`,
duration: track.duration,
genre: track.album.genre?.name,
genreId: track.album.genre?.id,
trackNumber: `${track.number}`,
trackNumber: track.number,
},
});
@@ -490,23 +477,46 @@ function bindSmapiSoapServiceToExpress(
case "root":
return getMetadataResult({
mediaCollection: [
container({ id: "artists", title: "Artists" }),
container({ id: "albums", title: "Albums" }),
container({ id: "genres", title: "Genres" }),
container({ id: "randomAlbums", title: "Random" }),
container({ id: "starredAlbums", title: "Starred" }),
container({
{
itemType: "container",
id: "artists",
title: "Artists",
},
{
itemType: "albumList",
id: "albums",
title: "Albums",
},
{
itemType: "container",
id: "genres",
title: "Genres",
},
{
itemType: "albumList",
id: "randomAlbums",
title: "Random",
},
{
itemType: "albumList",
id: "starredAlbums",
title: "Starred",
},
{
itemType: "albumList",
id: "recentlyAdded",
title: "Recently Added",
}),
container({
},
{
itemType: "albumList",
id: "recentlyPlayed",
title: "Recently Played",
}),
container({
},
{
itemType: "albumList",
id: "mostPlayed",
title: "Most Played",
}),
},
],
index: 0,
total: 8,
@@ -514,9 +524,9 @@ function bindSmapiSoapServiceToExpress(
case "search":
return getMetadataResult({
mediaCollection: [
search({ id: "artists", title: "Artists" }),
search({ id: "albums", title: "Albums" }),
search({ id: "tracks", title: "Tracks" }),
{ itemType: "search", id: "artists", title: "Artists" },
{ itemType: "search", id: "albums", title: "Albums" },
{ itemType: "search", id: "tracks", title: "Tracks" },
],
index: 0,
total: 3,

View File

@@ -7,7 +7,7 @@ import logger from "./logger";
import { SOAP_PATH, STRINGS_ROUTE, PRESENTATION_MAP_ROUTE } from "./smapi";
import qs from "querystring"
export const PRESENTATION_AND_STRINGS_VERSION = "12";
export const PRESENTATION_AND_STRINGS_VERSION = "15";
export type Capability =
| "search"