From dd58410cdac802a882195e3d6783a68cb8a1ebf1 Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Thu, 7 Nov 2024 21:33:16 +1100 Subject: [PATCH] Migrate getDownloadSpeed to jellyfin-sdk-typescript --- src/components/jellyfinActions.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/jellyfinActions.ts b/src/components/jellyfinActions.ts index a03d65d7..8730f9a2 100644 --- a/src/components/jellyfinActions.ts +++ b/src/components/jellyfinActions.ts @@ -348,17 +348,21 @@ export function getLiveStream( * @returns the bitrate in bits/s */ export async function getDownloadSpeed(byteSize: number): Promise { - const path = `Playback/BitrateTest?size=${byteSize}`; - const now = new Date().getTime(); - const response = await JellyfinApi.authAjax(path, { - timeout: 5000, - type: 'GET' - }); + const response = await getMediaInfoApi( + JellyfinApi.jellyfinApi + ).getBitrateTestBytes( + { + size: byteSize + }, + { + timeout: 5000 + } + ); // Force javascript to download the whole response before calculating bitrate - await response.blob(); + await response.data; const responseTimeSeconds = (new Date().getTime() - now) / 1000; const bytesPerSecond = byteSize / responseTimeSeconds;