From f177c2610425a3ea141e0b8f0df85a4ab961ff64 Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:59:24 +1100 Subject: [PATCH] Migrate onStopPlayerBeforePlaybackDone to jellyfin-sdk-typescript --- src/components/maincontroller.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/maincontroller.ts b/src/components/maincontroller.ts index ca35e943..7137ad3b 100644 --- a/src/components/maincontroller.ts +++ b/src/components/maincontroller.ts @@ -3,7 +3,7 @@ import type { MediaStream, MediaSourceInfo } from '@jellyfin/sdk/lib/generated-client'; -import { getSessionApi } from '@jellyfin/sdk/lib/utils/api'; +import { getSessionApi, getUserLibraryApi } from '@jellyfin/sdk/lib/utils/api'; import { getCurrentPositionTicks, getReportingParams, @@ -635,12 +635,15 @@ export async function onStopPlayerBeforePlaybackDone( // eslint-disable-next-line @typescript-eslint/no-explicit-any options: any ): Promise { - const data = await JellyfinApi.authAjaxUser(`Items/${item.Id}`, { - dataType: 'json', - type: 'GET' - }); + if (item.Id) { + const response = await getUserLibraryApi( + JellyfinApi.jellyfinApi + ).getItem({ + itemId: item.Id + }); - PlaybackManager.playItemInternal(data, options); + PlaybackManager.playItemInternal(response.data, options); + } } let lastBitrateDetect = 0;