mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 18:33: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,
|
[AlbumListSort.YEAR]: AlbumListSortType.BY_YEAR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const BATCH_SIZE = 500;
|
||||||
|
|
||||||
export const SubsonicController: ControllerEndpoint = {
|
export const SubsonicController: ControllerEndpoint = {
|
||||||
addToPlaylist: async ({ apiClientProps, body, query }) => {
|
addToPlaylist: async ({ apiClientProps, body, query }) => {
|
||||||
const res = await ssApiClient(apiClientProps).updatePlaylist({
|
const res = await ssApiClient(apiClientProps).updatePlaylist({
|
||||||
|
|
@ -1128,17 +1130,17 @@ export const SubsonicController: ControllerEndpoint = {
|
||||||
|
|
||||||
if (numberOfResults !== 1) {
|
if (numberOfResults !== 1) {
|
||||||
fetchNextSection = false;
|
fetchNextSection = false;
|
||||||
startIndex = sectionIndex === 0 ? 0 : sectionIndex - 5000;
|
startIndex = sectionIndex === 0 ? 0 : sectionIndex - BATCH_SIZE;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
sectionIndex += 5000;
|
sectionIndex += BATCH_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fetchNextPage) {
|
while (fetchNextPage) {
|
||||||
const res = await ssApiClient(apiClientProps).getSongsByGenre({
|
const res = await ssApiClient(apiClientProps).getSongsByGenre({
|
||||||
query: {
|
query: {
|
||||||
count: 500,
|
count: BATCH_SIZE,
|
||||||
genre: query.genreIds[0],
|
genre: query.genreIds[0],
|
||||||
musicFolderId: query.musicFolderId,
|
musicFolderId: query.musicFolderId,
|
||||||
offset: startIndex,
|
offset: startIndex,
|
||||||
|
|
@ -1195,13 +1197,13 @@ export const SubsonicController: ControllerEndpoint = {
|
||||||
|
|
||||||
const numberOfResults = (res.body.searchResult3?.song || []).length || 0;
|
const numberOfResults = (res.body.searchResult3?.song || []).length || 0;
|
||||||
|
|
||||||
// Check each batch of 5000 songs to check for data
|
// Check each batch of 500 songs to check for data
|
||||||
sectionIndex += 5000;
|
sectionIndex += BATCH_SIZE;
|
||||||
fetchNextSection = numberOfResults === 1;
|
fetchNextSection = numberOfResults === 1;
|
||||||
|
|
||||||
if (!fetchNextSection) {
|
if (!fetchNextSection) {
|
||||||
// fetchNextBlock will be false on the next loop so we need to subtract 5000 * 2
|
// fetchNextBlock will be false on the next loop so we need to subtract 2 * BATCH_SIZE
|
||||||
startIndex = sectionIndex - 10000;
|
startIndex = sectionIndex - 2 * BATCH_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue