chore: Apply linting rules and add git hok (#611)

Co-authored-by: Fredrik Burmester <fredrik.burmester@gmail.com>
This commit is contained in:
lostb1t
2025-03-16 18:01:12 +01:00
committed by GitHub
parent 2688e1b981
commit 92513e234f
268 changed files with 9197 additions and 8394 deletions

View File

@@ -1,10 +1,10 @@
// utils/getDefaultPlaySettings.ts
import { BITRATES } from "@/components/BitrateSelector";
import {
import type {
BaseItemDto,
MediaSourceInfo,
} from "@jellyfin/sdk/lib/generated-client";
import { Settings, useSettings } from "../atoms/settings";
import { type Settings, useSettings } from "../atoms/settings";
import {
AudioStreamRanker,
StreamRanker,
@@ -34,7 +34,7 @@ export function getDefaultPlaySettings(
item: BaseItemDto,
settings: Settings,
previousIndexes?: previousIndexes,
previousSource?: MediaSourceInfo
previousSource?: MediaSourceInfo,
): PlaySettings {
if (item.Type === "Program") {
return {
@@ -53,14 +53,14 @@ export function getDefaultPlaySettings(
// 2. Get default or preferred audio
const defaultAudioIndex = mediaSource?.DefaultAudioStreamIndex;
const preferedAudioIndex = mediaSource?.MediaStreams?.find(
(x) => x.Type === "Audio" && x.Language === settings?.defaultAudioLanguage
(x) => x.Type === "Audio" && x.Language === settings?.defaultAudioLanguage,
)?.Index;
const firstAudioIndex = mediaSource?.MediaStreams?.find(
(x) => x.Type === "Audio"
(x) => x.Type === "Audio",
)?.Index;
// We prefer the previous track over the default track.
let trackOptions: TrackOptions = {
const trackOptions: TrackOptions = {
DefaultAudioStreamIndex: defaultAudioIndex ?? -1,
DefaultSubtitleStreamIndex: mediaSource?.DefaultSubtitleStreamIndex ?? -1,
};
@@ -74,7 +74,7 @@ export function getDefaultPlaySettings(
previousIndexes.subtitleIndex,
previousSource,
mediaStreams,
trackOptions
trackOptions,
);
}
}
@@ -87,7 +87,7 @@ export function getDefaultPlaySettings(
previousIndexes.audioIndex,
previousSource,
mediaStreams,
trackOptions
trackOptions,
);
}
}

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import type { Api } from "@jellyfin/sdk";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { getPrimaryImageUrl } from "./getPrimaryImageUrl";
/**

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import type { Api } from "@jellyfin/sdk";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
/**
* Retrieves the primary image URL for a given item.

View File

@@ -1,6 +1,6 @@
import { Api } from "@jellyfin/sdk";
import type { Api } from "@jellyfin/sdk";
import {
BaseItemDto,
type BaseItemDto,
BaseItemPerson,
} from "@jellyfin/sdk/lib/generated-client/models";
import { isBaseItemDto } from "../jellyfin";

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import {
import type { Api } from "@jellyfin/sdk";
import type {
BaseItemDto,
BaseItemPerson,
} from "@jellyfin/sdk/lib/generated-client/models";

View File

@@ -1,4 +1,4 @@
import { Api } from "@jellyfin/sdk";
import type { Api } from "@jellyfin/sdk";
/**
* Retrieves the primary image URL for a given item.

View File

@@ -1,6 +1,6 @@
import { Api } from "@jellyfin/sdk";
import type { Api } from "@jellyfin/sdk";
import {
BaseItemDto,
type BaseItemDto,
BaseItemPerson,
} from "@jellyfin/sdk/lib/generated-client/models";
import { isBaseItemDto } from "../jellyfin";

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import type { Api } from "@jellyfin/sdk";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
/**
* Generates the authorization headers for Jellyfin API requests.

View File

@@ -1,4 +1,4 @@
import { Api } from "@jellyfin/sdk";
import type { Api } from "@jellyfin/sdk";
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api";
/**

View File

@@ -1,6 +1,6 @@
import native from "@/utils/profiles/native";
import { Api } from "@jellyfin/sdk";
import {
import type { Api } from "@jellyfin/sdk";
import type {
BaseItemDto,
MediaSourceInfo,
PlaybackInfoResponse,
@@ -63,7 +63,7 @@ export const getStreamUrl = async ({
data: {
deviceProfile,
},
}
},
);
const transcodeUrl = res0.data.MediaSources?.[0].TranscodingUrl;
sessionId = res0.data.PlaySessionId || null;
@@ -95,7 +95,7 @@ export const getStreamUrl = async ({
audioStreamIndex,
subtitleStreamIndex,
},
}
},
);
if (res2.status !== 200) {
@@ -105,7 +105,7 @@ export const getStreamUrl = async ({
sessionId = res2.data.PlaySessionId || null;
mediaSource = res2.data.MediaSources?.find(
(source: MediaSourceInfo) => source.Id === mediaSourceId
(source: MediaSourceInfo) => source.Id === mediaSourceId,
);
if (item.MediaType === "Video") {

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import { AxiosError } from "axios";
import type { Api } from "@jellyfin/sdk";
import type { AxiosError } from "axios";
interface MarkAsNotPlayedParams {
api: Api | null | undefined;

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import type { Api } from "@jellyfin/sdk";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api";
interface MarkAsPlayedParams {
@@ -14,7 +14,11 @@ interface MarkAsPlayedParams {
* @param params - The parameters for marking an item as played∏
* @returns A promise that resolves to true if the operation was successful, false otherwise
*/
export const markAsPlayed = async ({ api, item, userId }: MarkAsPlayedParams): Promise<boolean> => {
export const markAsPlayed = async ({
api,
item,
userId,
}: MarkAsPlayedParams): Promise<boolean> => {
if (!api || !item?.Id || !userId || !item.RunTimeTicks) {
console.error("Invalid parameters for markAsPlayed");
return false;

View File

@@ -1,17 +1,17 @@
import { Api } from "@jellyfin/sdk";
import { getAuthHeaders } from "../jellyfin";
import { postCapabilities } from "../session/capabilities";
import { Settings } from "@/utils/atoms/settings";
import { getOrSetDeviceId } from "@/providers/JellyfinProvider";
import type { Settings } from "@/utils/atoms/settings";
import ios from "@/utils/profiles/ios";
import native from "@/utils/profiles/native";
import old from "@/utils/profiles/old";
import type { Api } from "@jellyfin/sdk";
import { DeviceProfile } from "@jellyfin/sdk/lib/generated-client";
import {
getMediaInfoApi,
getPlaystateApi,
getSessionApi,
} from "@jellyfin/sdk/lib/utils/api";
import { DeviceProfile } from "@jellyfin/sdk/lib/generated-client";
import { getOrSetDeviceId } from "@/providers/JellyfinProvider";
import ios from "@/utils/profiles/ios";
import native from "@/utils/profiles/native";
import old from "@/utils/profiles/old";
import { getAuthHeaders } from "../jellyfin";
import { postCapabilities } from "../session/capabilities";
interface ReportPlaybackProgressParams {
api?: Api | null;

View File

@@ -1,7 +1,7 @@
import { Settings } from "@/utils/atoms/settings";
import type { Settings } from "@/utils/atoms/settings";
import native from "@/utils/profiles/native";
import { Api } from "@jellyfin/sdk";
import { AxiosError, AxiosResponse } from "axios";
import type { Api } from "@jellyfin/sdk";
import type { AxiosError, AxiosResponse } from "axios";
import { getAuthHeaders } from "../jellyfin";
interface PostCapabilitiesParams {
@@ -47,7 +47,7 @@ export const postCapabilities = async ({
},
{
headers: getAuthHeaders(api),
}
},
);
return d;
} catch (error: any | AxiosError) {

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import type { Api } from "@jellyfin/sdk";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { AxiosError } from "axios";
import { getAuthHeaders } from "../jellyfin";

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import type { Api } from "@jellyfin/sdk";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api";
/**

View File

@@ -1,5 +1,5 @@
import { Api } from "@jellyfin/sdk";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import type { Api } from "@jellyfin/sdk";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api";
/**