Files
streamyfin/utils/jellyfin/jellyfin.ts
Gauvain 5f39622ad6
Some checks failed
🤖 Android APK Build / 🏗️ Build Android APK (push) Has been cancelled
🤖 iOS IPA Build / 🏗️ Build iOS IPA (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled
fix: bump biome and fix error (#864)
2025-07-21 09:44:24 +02:00

30 lines
965 B
TypeScript

import type { Api } from "@jellyfin/sdk";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
/**
* Generates the authorization headers for Jellyfin API requests.
*
* @param {Api} api - The Jellyfin API instance.
* @returns {Record<string, string>} - The authorization headers.
*/
export const getAuthHeaders = (api: Api): Record<string, string> => ({
Authorization: `MediaBrowser DeviceId="${api.deviceInfo.id}", Token="${api.accessToken}"`,
});
/**
* Converts a bitrate to a human-readable string.
*
* @param {number} bitrate - The bitrate to convert.
* @returns {string} - The bitrate as a human-readable string.
*/
export const bitrateToString = (bitrate: number): string => {
const _kbps = bitrate / 1000;
const mbps = (bitrate / 1000000).toFixed(2);
return `${mbps} Mb/s`;
};
export function isBaseItemDto(item: any): item is BaseItemDto {
return item && "BackdropImageTags" in item && "ImageTags" in item;
}