mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Add most recently played
This commit is contained in:
11
src/smapi.ts
11
src/smapi.ts
@@ -427,9 +427,13 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
id: "recentlyPlayed",
|
id: "recentlyPlayed",
|
||||||
title: "Recently Played",
|
title: "Recently Played",
|
||||||
}),
|
}),
|
||||||
|
container({
|
||||||
|
id: "mostPlayed",
|
||||||
|
title: "Most Played",
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
index: 0,
|
index: 0,
|
||||||
total: 6,
|
total: 7,
|
||||||
});
|
});
|
||||||
case "artists":
|
case "artists":
|
||||||
return musicLibrary.artists(paging).then((result) => {
|
return musicLibrary.artists(paging).then((result) => {
|
||||||
@@ -464,6 +468,11 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
...paging,
|
...paging,
|
||||||
});
|
});
|
||||||
case "recentlyPlayed":
|
case "recentlyPlayed":
|
||||||
|
return albums({
|
||||||
|
type: "recent",
|
||||||
|
...paging,
|
||||||
|
});
|
||||||
|
case "mostPlayed":
|
||||||
return albums({
|
return albums({
|
||||||
type: "frequent",
|
type: "frequent",
|
||||||
...paging,
|
...paging,
|
||||||
|
|||||||
@@ -552,9 +552,14 @@ describe("api", () => {
|
|||||||
id: "recentlyPlayed",
|
id: "recentlyPlayed",
|
||||||
title: "Recently Played",
|
title: "Recently Played",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
itemType: "container",
|
||||||
|
id: "mostPlayed",
|
||||||
|
title: "Most Played",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
index: 0,
|
index: 0,
|
||||||
total: 6,
|
total: 7,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -968,6 +973,49 @@ describe("api", () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(musicLibrary.albums).toHaveBeenCalledWith({
|
||||||
|
type: "recent",
|
||||||
|
_index: paging.index,
|
||||||
|
_count: paging.count,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("asking for most played albums", () => {
|
||||||
|
const mostPlayed = [rock2, rock1, pop2];
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
musicLibrary.albums.mockResolvedValue({
|
||||||
|
results: mostPlayed,
|
||||||
|
total: allAlbums.length,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return some", async () => {
|
||||||
|
const paging = {
|
||||||
|
index: 0,
|
||||||
|
count: 100,
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await ws.getMetadataAsync({
|
||||||
|
id: "mostPlayed",
|
||||||
|
...paging,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result[0]).toEqual(
|
||||||
|
getMetadataResult({
|
||||||
|
mediaCollection: mostPlayed.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({
|
expect(musicLibrary.albums).toHaveBeenCalledWith({
|
||||||
type: "frequent",
|
type: "frequent",
|
||||||
_index: paging.index,
|
_index: paging.index,
|
||||||
|
|||||||
Reference in New Issue
Block a user