From c1bbcc733c9df2e954f76c6ce8a157de690fdb02 Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Thu, 7 Nov 2024 20:48:40 +1100 Subject: [PATCH 1/2] Migrate getLiveStream to jellyfin-sdk-typescript --- src/components/jellyfinActions.ts | 45 ++++++++++++------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/src/components/jellyfinActions.ts b/src/components/jellyfinActions.ts index a03d65d7..d756168e 100644 --- a/src/components/jellyfinActions.ts +++ b/src/components/jellyfinActions.ts @@ -301,7 +301,7 @@ export async function getPlaybackInfo( * @param subtitleStreamIndex - subtitleStreamIndex * @returns promise */ -export function getLiveStream( +export async function getLiveStream( item: BaseItemDto, playSessionId: string, maxBitrate: number, @@ -311,34 +311,23 @@ export function getLiveStream( audioStreamIndex: number | null, subtitleStreamIndex: number | null ): Promise { - const postData = { - DeviceProfile: deviceProfile, - OpenToken: mediaSource.OpenToken - }; - - const query: PlayRequestQuery = { - ItemId: item.Id, - MaxStreamingBitrate: maxBitrate, - PlaySessionId: playSessionId, - StartTimeTicks: startPosition || 0, - UserId: JellyfinApi.userId ?? undefined - }; - - if (audioStreamIndex != null) { - query.AudioStreamIndex = audioStreamIndex; - } - - if (subtitleStreamIndex != null) { - query.SubtitleStreamIndex = subtitleStreamIndex; - } - - return JellyfinApi.authAjax('LiveStreams/Open', { - contentType: 'application/json', - data: JSON.stringify(postData), - dataType: 'json', - query: query, - type: 'POST' + const liveStreamResponse = await getMediaInfoApi( + JellyfinApi.jellyfinApi + ).openLiveStream({ + openLiveStreamDto: { + AudioStreamIndex: audioStreamIndex, + DeviceProfile: deviceProfile, + ItemId: item.Id, + MaxStreamingBitrate: maxBitrate, + OpenToken: mediaSource.OpenToken, + PlaySessionId: playSessionId, + StartTimeTicks: startPosition || 0, + SubtitleStreamIndex: subtitleStreamIndex, + UserId: JellyfinApi.userId + } }); + + return liveStreamResponse.data; } /** From bec432f57be1b695ec07006199cb51881f461321 Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Thu, 7 Nov 2024 20:49:04 +1100 Subject: [PATCH 2/2] Remove unused PlayRequestQuery interface --- src/components/jellyfinActions.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/components/jellyfinActions.ts b/src/components/jellyfinActions.ts index d756168e..7bec4fad 100644 --- a/src/components/jellyfinActions.ts +++ b/src/components/jellyfinActions.ts @@ -4,8 +4,7 @@ import type { LiveStreamResponse, MediaSourceInfo, PlaybackInfoDto, - PlaybackProgressInfo, - PlayRequest + PlaybackProgressInfo } from '@jellyfin/sdk/lib/generated-client'; import { getHlsSegmentApi, @@ -18,15 +17,6 @@ import { JellyfinApi } from './jellyfinApi'; import { DocumentManager } from './documentManager'; import { PlaybackManager, PlaybackState } from './playbackManager'; -interface PlayRequestQuery extends PlayRequest { - UserId?: string; - StartTimeTicks?: number; - MaxStreamingBitrate?: number; - LiveStreamId?: string; - ItemId?: string; - PlaySessionId?: string; -} - let pingInterval: number; let lastTranscoderPing = 0;