mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-02-13 15:52:23 +00:00
Adding logic to be able to play local intros before content plays Signed-off-by: Lance Chant <13349722+lancechant@users.noreply.github.com>
29 lines
791 B
TypeScript
29 lines
791 B
TypeScript
import type { Api } from "@jellyfin/sdk";
|
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
|
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api";
|
|
|
|
/**
|
|
* Fetches intro items for a given media item using the Jellyfin SDK
|
|
* @param api - The Jellyfin API instance
|
|
* @param itemId - The ID of the media item
|
|
* @param userId - Optional user ID
|
|
* @returns Promise<BaseItemDto[]> - Array of intro items
|
|
*/
|
|
export async function getIntros(
|
|
api: Api,
|
|
itemId: string,
|
|
userId?: string,
|
|
): Promise<BaseItemDto[]> {
|
|
try {
|
|
const response = await getUserLibraryApi(api).getIntros({
|
|
itemId,
|
|
userId,
|
|
});
|
|
|
|
return response.data.Items || [];
|
|
} catch (error) {
|
|
console.error("Error fetching intros:", error);
|
|
return [];
|
|
}
|
|
}
|