Subsonic: Give user control over pagination size (#2665)
authorEric Munson <eric@munsonfam.org>
Tue, 25 Nov 2025 08:32:08 +0000 (03:32 -0500)
committerGitHub <noreply@github.com>
Tue, 25 Nov 2025 08:32:08 +0000 (08:32 +0000)
The selected value of 500 entries per invocation may not be ideal for
all users. Given that there isn't a single value that is ideal for all
users, let each configure their own. The default is shrinking to 200 as
a starting point.

Signed-off-by: Eric B Munson <eric@munsonfam.org>
music_assistant/providers/opensubsonic/__init__.py
music_assistant/providers/opensubsonic/sonic_provider.py

index 401c6096613b0fdb843a13bcefcf3482c74132e9..e2c1279d41a7bb1cee95d50be019e6c4b409add4 100644 (file)
@@ -15,6 +15,7 @@ from .sonic_provider import (
     CONF_ENABLE_PODCASTS,
     CONF_NEW_ALBUMS,
     CONF_OVERRIDE_OFFSET,
+    CONF_PAGE_SIZE,
     CONF_PLAYED_ALBUMS,
     CONF_RECO_FAVES,
     CONF_RECO_SIZE,
@@ -157,4 +158,15 @@ async def get_config_entries(
             description="How many recommendations from each enabled type should be included.",
             default_value=10,
         ),
+        ConfigEntry(
+            key=CONF_PAGE_SIZE,
+            type=ConfigEntryType.INTEGER,
+            label="Number of items included per server request.",
+            required=True,
+            description="When enumerating items from the server, how many should be in each "
+            "request. Smaller will require more requests but is better for low bandwidth "
+            "connections. The Open Subsonic spec says the max value for this is 500 items.",
+            default_value=200,
+            category="advanced",
+        ),
     )
index e8d058ba1226f0db63e7b3206e143bcf242a355b..a32874650eaf81ac64efa0c25e3ea79f5acc1f11 100644 (file)
@@ -78,6 +78,7 @@ CONF_RECO_FAVES = "recommend_favorites"
 CONF_NEW_ALBUMS = "recommend_new"
 CONF_PLAYED_ALBUMS = "recommend_played"
 CONF_RECO_SIZE = "recommendation_count"
+CONF_PAGE_SIZE = "pagination_size"
 
 CACHE_CATEGORY_PODCAST_CHANNEL = 1
 CACHE_CATEGORY_PODCAST_EPISODES = 2
@@ -97,6 +98,7 @@ class OpenSonicProvider(MusicProvider):
     _show_new: bool = True
     _show_played: bool = True
     _reco_limit: int = 10
+    _pagination_size: int = 200
 
     async def handle_async_init(self) -> None:
         """Set up the music provider and test the connection."""
@@ -139,6 +141,8 @@ class OpenSonicProvider(MusicProvider):
         self._show_new = bool(self.config.get_value(CONF_NEW_ALBUMS))
         self._show_played = bool(self.config.get_value(CONF_PLAYED_ALBUMS))
         self._reco_limit = int(str(self.config.get_value(CONF_RECO_SIZE)))
+        self._pagination_size = int(str(self.config.get_value(CONF_PAGE_SIZE)))
+        self._pagination_size = min(self._pagination_size, 500)
 
     @property
     def is_streaming_provider(self) -> bool:
@@ -287,7 +291,7 @@ class OpenSonicProvider(MusicProvider):
         returning 500 items per invocation.
         """
         offset = 0
-        size = 500
+        size = self._pagination_size
         albums = await self._run_async(
             self.conn.get_album_list2,
             ltype="alphabeticalByArtist",
@@ -319,7 +323,7 @@ class OpenSonicProvider(MusicProvider):
         """
         query = ""
         offset = 0
-        count = 500
+        count = self._pagination_size
         try:
             results = await self._run_async(
                 self.conn.search3,