mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
chore: linting fixes && github actions for linting (#612)
This commit is contained in:
@@ -15,7 +15,6 @@ function orientationToOrientationLock(
|
||||
return OrientationLock.LANDSCAPE_LEFT;
|
||||
case Orientation.LANDSCAPE_RIGHT:
|
||||
return OrientationLock.LANDSCAPE_RIGHT;
|
||||
case Orientation.UNKNOWN:
|
||||
default:
|
||||
return OrientationLock.DEFAULT;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ export const useJellyseerrCanRequest = (
|
||||
const canNotRequest =
|
||||
item?.mediaInfo?.requests?.some(
|
||||
(r: MediaRequest) =>
|
||||
r.status == MediaRequestStatus.PENDING ||
|
||||
r.status == MediaRequestStatus.APPROVED,
|
||||
r.status === MediaRequestStatus.PENDING ||
|
||||
r.status === MediaRequestStatus.APPROVED,
|
||||
) ||
|
||||
item.mediaInfo?.status === MediaStatus.AVAILABLE ||
|
||||
item.mediaInfo?.status === MediaStatus.BLACKLISTED ||
|
||||
|
||||
@@ -41,7 +41,7 @@ const calculateContrastRatio = (rgb1: number[], rgb2: number[]): number => {
|
||||
const calculateRelativeLuminance = (rgb: number[]): number => {
|
||||
const [r, g, b] = rgb.map((c) => {
|
||||
c /= 255;
|
||||
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
||||
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
||||
});
|
||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
};
|
||||
|
||||
@@ -11,9 +11,8 @@ export function convertBitsToMegabitsOrGigabits(bits?: number | null): string {
|
||||
const megabits = bits / 1000000;
|
||||
|
||||
if (megabits < 1000) {
|
||||
return Math.round(megabits) + "MB";
|
||||
} else {
|
||||
const gigabits = megabits / 1000;
|
||||
return gigabits.toFixed(1) + "GB";
|
||||
return `${Math.round(megabits)}MB`;
|
||||
}
|
||||
const gigabits = megabits / 1000;
|
||||
return `${gigabits.toFixed(1)}GB`;
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ export const formatBitrate = (bitrate?: number | null) => {
|
||||
const i = Number.parseInt(
|
||||
Math.floor(Math.log(bitrate) / Math.log(1000)).toString(),
|
||||
);
|
||||
return Math.round((bitrate / Math.pow(1000, i)) * 100) / 100 + " " + sizes[i];
|
||||
return `${Math.round((bitrate / 1000 ** i) * 100) / 100} ${sizes[i]}`;
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
|
||||
/**
|
||||
* Converts a ColletionType to a BaseItemKind (also called ItemType)
|
||||
*
|
||||
*
|
||||
* CollectionTypes
|
||||
* readonly Unknown: "unknown";
|
||||
readonly Movies: "movies";
|
||||
@@ -41,8 +41,6 @@ export const colletionTypeToItemType = (
|
||||
return BaseItemKind.Photo;
|
||||
case CollectionType.Trailers:
|
||||
return BaseItemKind.Trailer;
|
||||
case CollectionType.Playlists:
|
||||
return BaseItemKind.Playlist;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
@@ -54,7 +54,7 @@ export const getItemImage = ({
|
||||
};
|
||||
break;
|
||||
case "Primary":
|
||||
tag = item.ImageTags?.["Primary"];
|
||||
tag = item.ImageTags?.Primary;
|
||||
if (!tag) break;
|
||||
blurhash = item.ImageBlurHashes?.Primary?.[tag];
|
||||
|
||||
@@ -64,7 +64,7 @@ export const getItemImage = ({
|
||||
};
|
||||
break;
|
||||
case "Thumb":
|
||||
tag = item.ImageTags?.["Thumb"];
|
||||
tag = item.ImageTags?.Thumb;
|
||||
if (!tag) break;
|
||||
blurhash = item.ImageBlurHashes?.Thumb?.[tag];
|
||||
|
||||
@@ -74,7 +74,7 @@ export const getItemImage = ({
|
||||
};
|
||||
break;
|
||||
default:
|
||||
tag = item.ImageTags?.["Primary"];
|
||||
tag = item.ImageTags?.Primary;
|
||||
src = {
|
||||
uri: `${api.basePath}/Items/${item.Id}/Images/Primary?quality=${quality}&tag=${tag}&width=${width}`,
|
||||
};
|
||||
|
||||
@@ -24,12 +24,12 @@ export async function parseM3U8ForSubtitles(
|
||||
const attributes = parseAttributes(line);
|
||||
const track: SubtitleTrack = {
|
||||
index: index++,
|
||||
name: attributes["NAME"] || "",
|
||||
uri: attributes["URI"] || "",
|
||||
language: attributes["LANGUAGE"] || "",
|
||||
default: attributes["DEFAULT"] === "YES",
|
||||
forced: attributes["FORCED"] === "YES",
|
||||
autoSelect: attributes["AUTOSELECT"] === "YES",
|
||||
name: attributes.NAME || "",
|
||||
uri: attributes.URI || "",
|
||||
language: attributes.LANGUAGE || "",
|
||||
default: attributes.DEFAULT === "YES",
|
||||
forced: attributes.FORCED === "YES",
|
||||
autoSelect: attributes.AUTOSELECT === "YES",
|
||||
};
|
||||
subtitleTracks.push(track);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ export const getBackdropUrl = ({
|
||||
return `${api.basePath}/Items/${
|
||||
item.Id
|
||||
}/Images/Backdrop/0?${params.toString()}`;
|
||||
} else {
|
||||
return getPrimaryImageUrl({ api, item, quality, width });
|
||||
}
|
||||
return getPrimaryImageUrl({ api, item, quality, width });
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ export const getLogoImageUrlById = ({
|
||||
return `${api.basePath}/Items/${parentId}/Images/Logo?${params.toString()}`;
|
||||
}
|
||||
|
||||
const imageTag = item.ImageTags?.["Logo"];
|
||||
const imageTag = item.ImageTags?.Logo;
|
||||
|
||||
if (!imageTag) return null;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export const getPrimaryImageUrl = ({
|
||||
return `${api?.basePath}/Items/${item?.Id}/Images/Primary`;
|
||||
}
|
||||
|
||||
const primaryTag = item.ImageTags?.["Primary"];
|
||||
const primaryTag = item.ImageTags?.Primary;
|
||||
const backdropTag = item.BackdropImageTags?.[0];
|
||||
const parentBackdropTag = item.ParentBackdropImageTags?.[0];
|
||||
|
||||
|
||||
@@ -121,32 +121,31 @@ export const getStreamUrl = async ({
|
||||
sessionId: sessionId,
|
||||
mediaSource,
|
||||
};
|
||||
} else {
|
||||
const searchParams = new URLSearchParams({
|
||||
playSessionId: sessionData?.PlaySessionId || "",
|
||||
mediaSourceId: mediaSource?.Id || "",
|
||||
static: "true",
|
||||
subtitleStreamIndex: subtitleStreamIndex?.toString() || "",
|
||||
audioStreamIndex: audioStreamIndex?.toString() || "",
|
||||
deviceId: api.deviceInfo.id,
|
||||
api_key: api.accessToken,
|
||||
startTimeTicks: startTimeTicks.toString(),
|
||||
maxStreamingBitrate: maxStreamingBitrate?.toString() || "",
|
||||
userId: userId || "",
|
||||
});
|
||||
|
||||
const directPlayUrl = `${
|
||||
api.basePath
|
||||
}/Videos/${itemId}/stream.mp4?${searchParams.toString()}`;
|
||||
|
||||
console.log("Video is being direct played:", directPlayUrl);
|
||||
|
||||
return {
|
||||
url: directPlayUrl,
|
||||
sessionId: sessionId,
|
||||
mediaSource,
|
||||
};
|
||||
}
|
||||
const searchParams = new URLSearchParams({
|
||||
playSessionId: sessionData?.PlaySessionId || "",
|
||||
mediaSourceId: mediaSource?.Id || "",
|
||||
static: "true",
|
||||
subtitleStreamIndex: subtitleStreamIndex?.toString() || "",
|
||||
audioStreamIndex: audioStreamIndex?.toString() || "",
|
||||
deviceId: api.deviceInfo.id,
|
||||
api_key: api.accessToken,
|
||||
startTimeTicks: startTimeTicks.toString(),
|
||||
maxStreamingBitrate: maxStreamingBitrate?.toString() || "",
|
||||
userId: userId || "",
|
||||
});
|
||||
|
||||
const directPlayUrl = `${
|
||||
api.basePath
|
||||
}/Videos/${itemId}/stream.mp4?${searchParams.toString()}`;
|
||||
|
||||
console.log("Video is being direct played:", directPlayUrl);
|
||||
|
||||
return {
|
||||
url: directPlayUrl,
|
||||
sessionId: sessionId,
|
||||
mediaSource,
|
||||
};
|
||||
}
|
||||
|
||||
Alert.alert("Error", "Could not play this item");
|
||||
|
||||
@@ -66,7 +66,7 @@ export const writeDebugLog = (message: string, data?: any) => {
|
||||
if (process.env.EXPO_PUBLIC_WRITE_DEBUG === "1") {
|
||||
writeToLog("DEBUG", message, data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const readFromLog = (): LogEntry[] => {
|
||||
const logs = storage.getString("logs");
|
||||
|
||||
@@ -19,8 +19,8 @@ abstract class StreamRankerStrategy {
|
||||
mediaStreams: MediaStream[],
|
||||
trackOptions: any,
|
||||
): void {
|
||||
if (prevIndex == -1) {
|
||||
console.debug(`AutoSet Subtitle - No Stream Set`);
|
||||
if (prevIndex === -1) {
|
||||
console.debug("AutoSet Subtitle - No Stream Set");
|
||||
trackOptions[`Default${this.streamType}StreamIndex`] = -1;
|
||||
return;
|
||||
}
|
||||
@@ -46,32 +46,44 @@ abstract class StreamRankerStrategy {
|
||||
|
||||
let prevRelIndex = 0;
|
||||
for (const stream of prevSource.MediaStreams) {
|
||||
if (stream.Type != this.streamType) continue;
|
||||
if (stream.Type !== this.streamType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stream.Index == prevIndex) break;
|
||||
if (stream.Index === prevIndex) {
|
||||
break;
|
||||
}
|
||||
|
||||
prevRelIndex += 1;
|
||||
}
|
||||
|
||||
let newRelIndex = 0;
|
||||
for (const stream of mediaStreams) {
|
||||
if (stream.Type != this.streamType) continue;
|
||||
if (stream.Type !== this.streamType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let score = 0;
|
||||
|
||||
if (prevStream.Codec == stream.Codec) score += 1;
|
||||
if (prevRelIndex == newRelIndex) score += 1;
|
||||
if (prevStream.Codec === stream.Codec) {
|
||||
score += 1;
|
||||
}
|
||||
if (prevRelIndex === newRelIndex) {
|
||||
score += 1;
|
||||
}
|
||||
if (
|
||||
prevStream.DisplayTitle &&
|
||||
prevStream.DisplayTitle == stream.DisplayTitle
|
||||
)
|
||||
prevStream.DisplayTitle === stream.DisplayTitle
|
||||
) {
|
||||
score += 2;
|
||||
}
|
||||
if (
|
||||
prevStream.Language &&
|
||||
prevStream.Language != "und" &&
|
||||
prevStream.Language == stream.Language
|
||||
)
|
||||
prevStream.Language !== "und" &&
|
||||
prevStream.Language === stream.Language
|
||||
) {
|
||||
score += 2;
|
||||
}
|
||||
|
||||
console.debug(
|
||||
`AutoSet ${this.streamType} - Score ${score} for ${stream.Index} - ${stream.DisplayTitle}`,
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
*/
|
||||
export const tc = (text: string | null | undefined, length = 20) => {
|
||||
if (!text) return "";
|
||||
return text.length > length ? text.substr(0, length) + "..." : text;
|
||||
return text.length > length ? `${text.substr(0, length)}...` : text;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export const runtimeTicksToMinutes = (
|
||||
const minutes = Math.floor((ticks % ticksPerHour) / ticksPerMinute);
|
||||
|
||||
if (hours > 0) return `${hours}h ${minutes}m`;
|
||||
else return `${minutes}m`;
|
||||
return `${minutes}m`;
|
||||
};
|
||||
|
||||
export const runtimeTicksToSeconds = (
|
||||
@@ -33,7 +33,7 @@ export const runtimeTicksToSeconds = (
|
||||
const seconds = Math.floor((ticks % ticksPerMinute) / 10000000);
|
||||
|
||||
if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
|
||||
else return `${minutes}m ${seconds}s`;
|
||||
return `${minutes}m ${seconds}s`;
|
||||
};
|
||||
|
||||
// t: ms
|
||||
@@ -66,9 +66,8 @@ export const formatTimeString = (
|
||||
|
||||
if (hours > 0) {
|
||||
return `${hours}h ${minutes}m ${remainingSeconds}s`;
|
||||
} else {
|
||||
return `${minutes}m ${remainingSeconds}s`;
|
||||
}
|
||||
return `${minutes}m ${remainingSeconds}s`;
|
||||
};
|
||||
|
||||
export const secondsToTicks = (seconds?: number | undefined) => {
|
||||
|
||||
Reference in New Issue
Block a user