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
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions music_assistant/server/providers/jellyfin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Callable, Coroutine

from aiohttp import ClientTimeout
from jellyfin_apiclient_python import JellyfinClient
from jellyfin_apiclient_python.api import API

Expand Down Expand Up @@ -53,6 +52,7 @@
from music_assistant.common.models.media_items import Playlist as JellyfinPlaylist
from music_assistant.common.models.media_items import Track as JellyfinTrack
from music_assistant.common.models.streamdetails import StreamDetails
from music_assistant.server.helpers.audio import get_http_stream

if TYPE_CHECKING:
from music_assistant.common.models.provider import ProviderManifest
Expand Down Expand Up @@ -808,11 +808,11 @@ 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
2 changes: 1 addition & 1 deletion music_assistant/server/providers/slimproto/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"multi_instance": false,
"builtin": false,
"load_by_default": false
}
}