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

Added seek support to Jellyfin Provider #1140

Merged
merged 8 commits into from
Mar 16, 2024
14 changes: 9 additions & 5 deletions music_assistant/server/providers/jellyfin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
SearchResults,
Track,
)
from music_assistant.server.helpers.audio import (
get_http_stream
)
from music_assistant.common.models.media_items import Album as JellyfinAlbum
from music_assistant.common.models.media_items import Artist as JellyfinArtist
from music_assistant.common.models.media_items import Playlist as JellyfinPlaylist
Expand Down Expand Up @@ -808,11 +811,12 @@ def _media_mime_type(self, media_item: dict[str, Any]) -> str | None:

return mime_type

async def get_audio_stream(self, streamdetails: StreamDetails) -> AsyncGenerator[bytes, None]:
async def get_audio_stream(self, streamdetails: StreamDetails, seek_position: int = 0) -> AsyncGenerator[bytes, None]:
"""Return the audio stream for the provider item."""
url = API.audio_url(self._jellyfin_server.jellyfin, streamdetails.item_id)

timeout = ClientTimeout(total=0, connect=30, sock_read=600)
async with self.mass.http_session.get(url, timeout=timeout) as resp:
async for chunk in resp.content.iter_any():
yield chunk
async for chunk in get_http_stream(
self.mass, url, streamdetails, seek_position
):
yield chunk

Loading