From: Eric Munson Date: Tue, 25 Nov 2025 08:32:08 +0000 (-0500) Subject: Subsonic: Give user control over pagination size (#2665) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=18ad955af631656faa832ef68da9885958beaf0d;p=music-assistant-server.git Subsonic: Give user control over pagination size (#2665) 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 --- diff --git a/music_assistant/providers/opensubsonic/__init__.py b/music_assistant/providers/opensubsonic/__init__.py index 401c6096..e2c1279d 100644 --- a/music_assistant/providers/opensubsonic/__init__.py +++ b/music_assistant/providers/opensubsonic/__init__.py @@ -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", + ), ) diff --git a/music_assistant/providers/opensubsonic/sonic_provider.py b/music_assistant/providers/opensubsonic/sonic_provider.py index e8d058ba..a3287465 100644 --- a/music_assistant/providers/opensubsonic/sonic_provider.py +++ b/music_assistant/providers/opensubsonic/sonic_provider.py @@ -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,