Migrate getItemsForPlayback to jellyfin-sdk-typescript

This commit is contained in:
Matthew Haughton 2024-11-10 11:48:48 +11:00
parent d8eee5d989
commit bfee74f006

View File

@ -14,7 +14,11 @@ import type {
ItemFields, ItemFields,
ItemsApiGetItemsRequest ItemsApiGetItemsRequest
} from '@jellyfin/sdk/lib/generated-client'; } from '@jellyfin/sdk/lib/generated-client';
import { getInstantMixApi, getTvShowsApi } from '@jellyfin/sdk/lib/utils/api'; import {
getInstantMixApi,
getItemsApi,
getTvShowsApi
} from '@jellyfin/sdk/lib/utils/api';
import { JellyfinApi } from './components/jellyfinApi'; import { JellyfinApi } from './components/jellyfinApi';
import { PlaybackManager, PlaybackState } from './components/playbackManager'; import { PlaybackManager, PlaybackState } from './components/playbackManager';
import { BusMessage } from './types/global'; import { BusMessage } from './types/global';
@ -577,21 +581,18 @@ export async function getItemsForPlayback(
}; };
if (query.ids?.length == 1) { if (query.ids?.length == 1) {
const item = await JellyfinApi.authAjaxUser(`Items/${query.ids[0]}`, { const response = await getItemsApi(JellyfinApi.jellyfinApi).getItems({
dataType: 'json', ...query,
type: 'GET' ...params
}); });
return { return response.data;
Items: [item],
TotalRecordCount: 1
};
} else { } else {
return JellyfinApi.authAjaxUser('Items', { const response = await getItemsApi(JellyfinApi.jellyfinApi).getItems(
dataType: 'json', query
query: { ...query, ...params }, );
type: 'GET'
}); return response.data;
} }
} }