Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subsonic: Check for transcodeOffset support on startup #1137

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions music_assistant/server/providers/opensubsonic/sonic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class OpenSonicProvider(MusicProvider):

_conn: SonicConnection = None
_enable_podcasts: bool = True
_seek_support: bool = False

async def handle_async_init(self) -> None:
"""Set up the music provider and test the connection."""
Expand Down Expand Up @@ -97,6 +98,17 @@ async def handle_async_init(self) -> None:
)
raise LoginFailed(msg) from e
self._enable_podcasts = self.config.get_value(CONF_ENABLE_PODCASTS)
try:
ret = await self._run_async(self._conn.getOpenSubsonicExtensions)
extensions = ret["openSubsonicExtensions"]
for entry in extensions:
if entry["name"] == "transcodeOffset":
self._seek_support = True
khers marked this conversation as resolved.
Show resolved Hide resolved
break
except OSError:
logging.getLogger("libopensonic").info(
"Server does not support transcodeOffset, seeking in player provider"
)

@property
def supported_features(self) -> tuple[ProviderFeature, ...]:
Expand Down Expand Up @@ -656,6 +668,7 @@ async def get_stream_details(self, item_id: str) -> StreamDetails | None:
return StreamDetails(
item_id=sonic_song.id,
provider=self.instance_id,
can_seek=self._seek_support,
audio_format=AudioFormat(content_type=ContentType.try_parse(mime_type)),
duration=sonic_song.duration if sonic_song.duration is not None else 0,
callback=self._report_playback_stopped,
Expand Down
Loading