mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Ability to play a playlist
This commit is contained in:
42
src/smapi.ts
42
src/smapi.ts
@@ -13,6 +13,7 @@ import {
|
||||
ArtistSummary,
|
||||
Genre,
|
||||
MusicService,
|
||||
PlaylistSummary,
|
||||
slice2,
|
||||
Track,
|
||||
} from "./music_service";
|
||||
@@ -194,7 +195,7 @@ export type Container = {
|
||||
itemType: ContainerType;
|
||||
id: string;
|
||||
title: string;
|
||||
displayType: string | undefined
|
||||
displayType: string | undefined;
|
||||
};
|
||||
|
||||
const genre = (genre: Genre) => ({
|
||||
@@ -203,6 +204,13 @@ const genre = (genre: Genre) => ({
|
||||
title: genre.name,
|
||||
});
|
||||
|
||||
const playlist = (playlist: PlaylistSummary) => ({
|
||||
itemType: "album",
|
||||
id: `playlist:${playlist.id}`,
|
||||
title: playlist.name,
|
||||
canPlay: true,
|
||||
});
|
||||
|
||||
export const defaultAlbumArtURI = (
|
||||
webAddress: string,
|
||||
accessToken: string,
|
||||
@@ -487,6 +495,11 @@ function bindSmapiSoapServiceToExpress(
|
||||
id: "albums",
|
||||
title: "Albums",
|
||||
},
|
||||
{
|
||||
itemType: "container",
|
||||
id: "playlists",
|
||||
title: "Playlists",
|
||||
},
|
||||
{
|
||||
itemType: "container",
|
||||
id: "genres",
|
||||
@@ -519,7 +532,7 @@ function bindSmapiSoapServiceToExpress(
|
||||
},
|
||||
],
|
||||
index: 0,
|
||||
total: 8,
|
||||
total: 9,
|
||||
});
|
||||
case "search":
|
||||
return getMetadataResult({
|
||||
@@ -589,6 +602,31 @@ function bindSmapiSoapServiceToExpress(
|
||||
total,
|
||||
})
|
||||
);
|
||||
case "playlists":
|
||||
return musicLibrary
|
||||
.playlists()
|
||||
.then(slice2(paging))
|
||||
.then(([page, total]) =>
|
||||
getMetadataResult({
|
||||
mediaCollection: page.map(playlist),
|
||||
index: paging._index,
|
||||
total,
|
||||
})
|
||||
);
|
||||
case "playlist":
|
||||
return musicLibrary
|
||||
.playlist(typeId!)
|
||||
.then(playlist => playlist.entries)
|
||||
.then(slice2(paging))
|
||||
.then(([page, total]) => {
|
||||
return getMetadataResult({
|
||||
mediaMetadata: page.map((it) =>
|
||||
track(webAddress, accessToken, it)
|
||||
),
|
||||
index: paging._index,
|
||||
total,
|
||||
});
|
||||
});
|
||||
case "artist":
|
||||
return musicLibrary
|
||||
.artist(typeId!)
|
||||
|
||||
Reference in New Issue
Block a user