mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Add Starred albums
This commit is contained in:
@@ -94,7 +94,7 @@ export const asResult = <T>([results, total]: [T[], number]) => ({
|
|||||||
|
|
||||||
export type ArtistQuery = Paging;
|
export type ArtistQuery = Paging;
|
||||||
|
|
||||||
export type AlbumQueryType = 'alphabeticalByArtist' | 'byGenre' | 'random' | 'recent' | 'frequent' | 'newest';
|
export type AlbumQueryType = 'alphabeticalByArtist' | 'byGenre' | 'random' | 'recent' | 'frequent' | 'newest' | 'starred';
|
||||||
|
|
||||||
export type AlbumQuery = Paging & {
|
export type AlbumQuery = Paging & {
|
||||||
type: AlbumQueryType;
|
type: AlbumQueryType;
|
||||||
|
|||||||
14
src/smapi.ts
14
src/smapi.ts
@@ -419,6 +419,7 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
container({ id: "albums", title: "Albums" }),
|
container({ id: "albums", title: "Albums" }),
|
||||||
container({ id: "genres", title: "Genres" }),
|
container({ id: "genres", title: "Genres" }),
|
||||||
container({ id: "randomAlbums", title: "Random" }),
|
container({ id: "randomAlbums", title: "Random" }),
|
||||||
|
container({ id: "starredAlbums", title: "Starred" }),
|
||||||
container({
|
container({
|
||||||
id: "recentlyAdded",
|
id: "recentlyAdded",
|
||||||
title: "Recently Added",
|
title: "Recently Added",
|
||||||
@@ -433,7 +434,7 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
index: 0,
|
index: 0,
|
||||||
total: 7,
|
total: 8,
|
||||||
});
|
});
|
||||||
case "artists":
|
case "artists":
|
||||||
return musicLibrary.artists(paging).then((result) => {
|
return musicLibrary.artists(paging).then((result) => {
|
||||||
@@ -451,15 +452,20 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
...paging,
|
...paging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
case "genre":
|
||||||
|
return albums({
|
||||||
|
type: "byGenre",
|
||||||
|
genre: typeId,
|
||||||
|
...paging,
|
||||||
|
});
|
||||||
case "randomAlbums":
|
case "randomAlbums":
|
||||||
return albums({
|
return albums({
|
||||||
type: "random",
|
type: "random",
|
||||||
...paging,
|
...paging,
|
||||||
});
|
});
|
||||||
case "genre":
|
case "starredAlbums":
|
||||||
return albums({
|
return albums({
|
||||||
type: "byGenre",
|
type: "starred",
|
||||||
genre: typeId,
|
|
||||||
...paging,
|
...paging,
|
||||||
});
|
});
|
||||||
case "recentlyAdded":
|
case "recentlyAdded":
|
||||||
|
|||||||
@@ -542,6 +542,11 @@ describe("api", () => {
|
|||||||
id: "randomAlbums",
|
id: "randomAlbums",
|
||||||
title: "Random",
|
title: "Random",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
itemType: "container",
|
||||||
|
id: "starredAlbums",
|
||||||
|
title: "Starred",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
itemType: "container",
|
itemType: "container",
|
||||||
id: "recentlyAdded",
|
id: "recentlyAdded",
|
||||||
@@ -559,7 +564,7 @@ describe("api", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
index: 0,
|
index: 0,
|
||||||
total: 7,
|
total: 8,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -938,6 +943,49 @@ describe("api", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("asking for starred albums", () => {
|
||||||
|
const albums = [rock2, rock1, pop2];
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
musicLibrary.albums.mockResolvedValue({
|
||||||
|
results: albums,
|
||||||
|
total: allAlbums.length,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return some", async () => {
|
||||||
|
const paging = {
|
||||||
|
index: 0,
|
||||||
|
count: 100,
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await ws.getMetadataAsync({
|
||||||
|
id: "starredAlbums",
|
||||||
|
...paging,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result[0]).toEqual(
|
||||||
|
getMetadataResult({
|
||||||
|
mediaCollection: albums.map((it) => ({
|
||||||
|
itemType: "album",
|
||||||
|
id: `album:${it.id}`,
|
||||||
|
title: it.name,
|
||||||
|
albumArtURI: defaultAlbumArtURI(rootUrl, accessToken, it),
|
||||||
|
canPlay: true,
|
||||||
|
})),
|
||||||
|
index: 0,
|
||||||
|
total: 6,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(musicLibrary.albums).toHaveBeenCalledWith({
|
||||||
|
type: "starred",
|
||||||
|
_index: paging.index,
|
||||||
|
_count: paging.count,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("asking for recently played albums", () => {
|
describe("asking for recently played albums", () => {
|
||||||
const recentlyPlayed = [rock2, rock1, pop2];
|
const recentlyPlayed = [rock2, rock1, pop2];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user