missing commit

This commit is contained in:
simojenki
2021-03-13 12:52:47 +11:00
parent 41d383fcf3
commit a62abd3888

View File

@@ -239,7 +239,7 @@ export class Navidrome implements MusicService {
"subsonic-response.artist.album", "subsonic-response.artist.album",
"subsonic-response.albumList.album", "subsonic-response.albumList.album",
"subsonic-response.album.song", "subsonic-response.album.song",
"subsonic-response.genres.genre" "subsonic-response.genres.genre",
], ],
}).xml2js(response.data) as SubconicEnvelope }).xml2js(response.data) as SubconicEnvelope
) )
@@ -306,19 +306,16 @@ export class Navidrome implements MusicService {
id, id,
}) })
.then((it) => it.artist) .then((it) => it.artist)
.then((it) => { .then((it) => ({
console.log(`artist is ${JSON.stringify(it)}`); id: it._id,
return { name: it._name,
id: it._id, albums: it.album.map((album) => ({
name: it._name, id: album._id,
albums: it.album.map((album) => ({ name: album._name,
id: album._id, year: album._year,
name: album._name, genre: album._genre,
year: album._year, })),
genre: album._genre, }));
})),
};
});
async login(token: string) { async login(token: string) {
const navidrome = this; const navidrome = this;
@@ -345,12 +342,10 @@ export class Navidrome implements MusicService {
) )
) )
) )
.then((resultWithInfo) => { .then((resultWithInfo) => ({
return { total: resultWithInfo[0]?.total || 0,
total: resultWithInfo[0]?.total || 0, results: resultWithInfo.map((it) => it.result),
results: resultWithInfo.map((it) => it.result), })),
};
}),
artist: async (id: string): Promise<Artist> => artist: async (id: string): Promise<Artist> =>
Promise.all([ Promise.all([
navidrome.getArtist(credentials, id), navidrome.getArtist(credentials, id),
@@ -361,21 +356,19 @@ export class Navidrome implements MusicService {
image: artistInfo.image, image: artistInfo.image,
albums: artist.albums, albums: artist.albums,
})), })),
albums: (q: AlbumQuery): Promise<Result<AlbumSummary>> => { albums: (q: AlbumQuery): Promise<Result<AlbumSummary>> =>
const p = pipe( navidrome
O.fromNullable(q.genre),
O.map<string, getAlbumListParams>((genre) => ({
type: "byGenre",
genre,
})),
O.getOrElse<getAlbumListParams>(() => ({
type: "alphabeticalByArtist",
}))
);
return navidrome
.getJSON<GetAlbumListResponse>(credentials, "/rest/getAlbumList", { .getJSON<GetAlbumListResponse>(credentials, "/rest/getAlbumList", {
...p, ...pipe(
O.fromNullable(q.genre),
O.map<string, getAlbumListParams>((genre) => ({
type: "byGenre",
genre,
})),
O.getOrElse<getAlbumListParams>(() => ({
type: "alphabeticalByArtist",
}))
),
size: MAX_ALBUM_LIST, size: MAX_ALBUM_LIST,
offset: 0, offset: 0,
}) })
@@ -392,8 +385,7 @@ export class Navidrome implements MusicService {
.then(([page, total]) => ({ .then(([page, total]) => ({
results: page, results: page,
total: Math.min(MAX_ALBUM_LIST, total), total: Math.min(MAX_ALBUM_LIST, total),
})); })),
},
album: (id: string): Promise<Album> => album: (id: string): Promise<Album> =>
navidrome.getAlbum(credentials, id), navidrome.getAlbum(credentials, id),
genres: () => genres: () =>