mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 10:03:33 +00:00
subsonic limit to 500
This commit is contained in:
parent
c94029012f
commit
0becfd4b59
1 changed files with 9 additions and 7 deletions
|
|
@ -46,6 +46,8 @@ const ALBUM_LIST_SORT_MAPPING: Record<AlbumListSort, AlbumListSortType | undefin
|
|||
[AlbumListSort.YEAR]: AlbumListSortType.BY_YEAR,
|
||||
};
|
||||
|
||||
const BATCH_SIZE = 500;
|
||||
|
||||
export const SubsonicController: ControllerEndpoint = {
|
||||
addToPlaylist: async ({ apiClientProps, body, query }) => {
|
||||
const res = await ssApiClient(apiClientProps).updatePlaylist({
|
||||
|
|
@ -1128,17 +1130,17 @@ export const SubsonicController: ControllerEndpoint = {
|
|||
|
||||
if (numberOfResults !== 1) {
|
||||
fetchNextSection = false;
|
||||
startIndex = sectionIndex === 0 ? 0 : sectionIndex - 5000;
|
||||
startIndex = sectionIndex === 0 ? 0 : sectionIndex - BATCH_SIZE;
|
||||
break;
|
||||
} else {
|
||||
sectionIndex += 5000;
|
||||
sectionIndex += BATCH_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
while (fetchNextPage) {
|
||||
const res = await ssApiClient(apiClientProps).getSongsByGenre({
|
||||
query: {
|
||||
count: 500,
|
||||
count: BATCH_SIZE,
|
||||
genre: query.genreIds[0],
|
||||
musicFolderId: query.musicFolderId,
|
||||
offset: startIndex,
|
||||
|
|
@ -1195,13 +1197,13 @@ export const SubsonicController: ControllerEndpoint = {
|
|||
|
||||
const numberOfResults = (res.body.searchResult3?.song || []).length || 0;
|
||||
|
||||
// Check each batch of 5000 songs to check for data
|
||||
sectionIndex += 5000;
|
||||
// Check each batch of 500 songs to check for data
|
||||
sectionIndex += BATCH_SIZE;
|
||||
fetchNextSection = numberOfResults === 1;
|
||||
|
||||
if (!fetchNextSection) {
|
||||
// fetchNextBlock will be false on the next loop so we need to subtract 5000 * 2
|
||||
startIndex = sectionIndex - 10000;
|
||||
// fetchNextBlock will be false on the next loop so we need to subtract 2 * BATCH_SIZE
|
||||
startIndex = sectionIndex - 2 * BATCH_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue