mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 12:30:12 +02:00
conditionally disable Subsonic list filters based on availability (#1567)
This commit is contained in:
@@ -1599,6 +1599,76 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
return (res.body.starred?.song || []).length || 0;
|
||||
}
|
||||
|
||||
const artistIds = query.albumArtistIds || query.artistIds;
|
||||
|
||||
if (query.albumIds || artistIds) {
|
||||
const fromAlbumPromises: Promise<ServerInferResponses<typeof contract.getAlbum>>[] = [];
|
||||
const artistDetailPromises: Promise<ServerInferResponses<typeof contract.getArtist>>[] =
|
||||
[];
|
||||
|
||||
if (query.albumIds) {
|
||||
for (const albumId of query.albumIds) {
|
||||
fromAlbumPromises.push(
|
||||
ssApiClient(apiClientProps).getAlbum({
|
||||
query: {
|
||||
id: albumId,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (artistIds) {
|
||||
for (const artistId of artistIds) {
|
||||
artistDetailPromises.push(
|
||||
ssApiClient(apiClientProps).getArtist({
|
||||
query: {
|
||||
id: artistId,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const artistResult = await Promise.all(artistDetailPromises);
|
||||
|
||||
const albums = artistResult.flatMap((artist) => {
|
||||
if (artist.status !== 200) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return artist.body.artist.album ?? [];
|
||||
});
|
||||
|
||||
const albumIds = albums.map((album) => album.id);
|
||||
|
||||
for (const albumId of albumIds) {
|
||||
fromAlbumPromises.push(
|
||||
ssApiClient(apiClientProps).getAlbum({
|
||||
query: {
|
||||
id: albumId.toString(),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let results: z.infer<typeof ssType._response.song>[] = [];
|
||||
|
||||
if (fromAlbumPromises.length > 0) {
|
||||
const albumsResult = await Promise.all(fromAlbumPromises);
|
||||
|
||||
results = albumsResult.flatMap((album) => {
|
||||
if (album.status !== 200) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return album.body.album.song;
|
||||
});
|
||||
}
|
||||
|
||||
return results.length;
|
||||
}
|
||||
|
||||
let totalRecordCount = 0;
|
||||
|
||||
// Rather than just do `search3` by groups of 500, instead
|
||||
|
||||
Reference in New Issue
Block a user