mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 23:59:08 +00:00
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
30 lines
965 B
TypeScript
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;
|
|
}
|