Add years menu (#202)

This commit is contained in:
Jonathan Virga
2024-04-23 02:06:18 +02:00
committed by GitHub
parent e7f5f5871e
commit 0488f398c1
8 changed files with 159 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ import {
AlbumSummary,
ArtistSummary,
Genre,
Year,
MusicService,
Playlist,
RadioStation,
@@ -244,12 +245,19 @@ export type Container = {
};
const genre = (bonobUrl: URLBuilder, genre: Genre) => ({
itemType: "container",
itemType: "albumList",
id: `genre:${genre.id}`,
title: genre.name,
albumArtURI: iconArtURI(bonobUrl, iconForGenre(genre.name)).href(),
});
const year = (bonobUrl: URLBuilder, year: Year) => ({
itemType: "albumList",
id: `year:${year.year}`,
title: year.year,
albumArtURI: iconArtURI(bonobUrl, "music").href(),
});
const playlist = (bonobUrl: URLBuilder, playlist: Playlist) => ({
itemType: "playlist",
id: `playlist:${playlist.id}`,
@@ -740,6 +748,12 @@ function bindSmapiSoapServiceToExpress(
albumArtURI: iconArtURI(bonobUrl, "genres").href(),
itemType: "container",
},
{
id: "years",
title: lang("years"),
albumArtURI: iconArtURI(bonobUrl, "music").href(),
itemType: "container",
},
{
id: "recentlyAdded",
title: lang("recentlyAdded"),
@@ -817,6 +831,13 @@ function bindSmapiSoapServiceToExpress(
genre: typeId,
...paging,
});
case "year":
return albums({
type: "byYear",
fromYear: typeId,
toYear: typeId,
...paging,
});
case "randomAlbums":
return albums({
type: "random",
@@ -860,6 +881,19 @@ function bindSmapiSoapServiceToExpress(
total,
})
);
case "years":
return musicLibrary
.years()
.then(slice2(paging))
.then(([page, total]) =>
getMetadataResult({
mediaCollection: page.map((it) =>
year(bonobUrl, it)
),
index: paging._index,
total,
})
);
case "genres":
return musicLibrary
.genres()