mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Ability to list tracks on an album
This commit is contained in:
41
src/smapi.ts
41
src/smapi.ts
@@ -11,6 +11,7 @@ import {
|
||||
MusicLibrary,
|
||||
MusicService,
|
||||
slice2,
|
||||
Track,
|
||||
} from "./music_service";
|
||||
|
||||
export const LOGIN_ROUTE = "/login";
|
||||
@@ -168,7 +169,7 @@ const genre = (genre: string) => ({
|
||||
itemType: "container",
|
||||
id: `genre:${genre}`,
|
||||
title: genre,
|
||||
})
|
||||
});
|
||||
|
||||
const album = (album: AlbumSummary) => ({
|
||||
itemType: "album",
|
||||
@@ -182,6 +183,27 @@ const album = (album: AlbumSummary) => ({
|
||||
// }
|
||||
});
|
||||
|
||||
const track = (track: Track) => ({
|
||||
itemType: "track",
|
||||
id: `track:${track.id}`,
|
||||
mimeType: track.mimeType,
|
||||
title: track.name,
|
||||
|
||||
trackMetadata: {
|
||||
album: track.album.name,
|
||||
albumId: track.album.id,
|
||||
albumArtist: track.artist.name,
|
||||
albumArtistId: track.artist.id,
|
||||
// albumArtURI
|
||||
artist: track.artist.name,
|
||||
artistId: track.artist.id,
|
||||
duration: track.duration,
|
||||
genre: track.album.genre,
|
||||
// genreId
|
||||
trackNumber: track.number,
|
||||
},
|
||||
});
|
||||
|
||||
type SoapyHeaders = {
|
||||
credentials?: Credentials;
|
||||
};
|
||||
@@ -280,8 +302,8 @@ function bindSmapiSoapServiceToExpress(
|
||||
index: paging._index,
|
||||
total,
|
||||
})
|
||||
);
|
||||
case "artist":
|
||||
);
|
||||
case "artist":
|
||||
return await musicLibrary
|
||||
.artist(typeId!)
|
||||
.then((artist) => artist.albums)
|
||||
@@ -289,7 +311,18 @@ function bindSmapiSoapServiceToExpress(
|
||||
.then(([page, total]) =>
|
||||
getMetadataResult({
|
||||
mediaCollection: page.map(album),
|
||||
index: 0,
|
||||
index: paging._index,
|
||||
total,
|
||||
})
|
||||
);
|
||||
case "album":
|
||||
return await musicLibrary
|
||||
.tracks(typeId!)
|
||||
.then(slice2(paging))
|
||||
.then(([page, total]) =>
|
||||
getMetadataResult({
|
||||
mediaCollection: page.map(track),
|
||||
index: paging._index,
|
||||
total,
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user