feat(settings): unify Streamystats + Marlin URL inputs via the resolver

- jellyfinProbe (/System/Info/Public, ProductName check) + reachabilityProbe (services with no health route).

- ServerUrlStatusText: compact resolver status for ListItem-row layouts.

- Streamystats + Marlin: resolve the URL on blur (https-first, http fallback) and store the canonical URL; inline status feedback.
This commit is contained in:
Gauvain
2026-06-04 20:44:39 +02:00
parent 0f29457ff8
commit b54b0c670b
6 changed files with 133 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import axios from "axios";
import type { ServerProbe } from "../types";
/** Public, unauthenticated Jellyfin endpoint; `ProductName` confirms the service. */
const PRODUCT_NAME = "Jellyfin Server";
export const jellyfinProbe: ServerProbe = async (url, signal) => {
try {
const { status, data } = await axios.get(`${url}/System/Info/Public`, {
signal,
timeout: 8000, // backstop; the resolver aborts via signal first
});
if (status < 200 || status >= 300) return { status: "unreachable" };
if (data?.ProductName !== PRODUCT_NAME) return { status: "wrong-service" };
return {
status: "ok",
meta: { version: data?.Version, serverName: data?.ServerName },
};
} catch {
return { status: "unreachable" };
}
};

View File

@@ -0,0 +1,23 @@
import axios from "axios";
import type { ServerProbe } from "../types";
/**
* Minimal probe for services without a known/unauthenticated health endpoint
* (e.g. Marlin Search, Streamystats). Any HTTP response — even 4xx — proves the
* host is up and speaking HTTP at this protocol/port, which is enough to pick
* https vs http. It cannot detect a "wrong service".
*/
export const reachabilityProbe: ServerProbe = async (url, signal) => {
try {
await axios.get(url, {
signal,
timeout: 8000,
validateStatus: () => true, // any status = the server answered
});
return { status: "ok" };
} catch (error) {
// A delivered response that still threw counts as reachable.
if ((error as { response?: unknown })?.response) return { status: "ok" };
return { status: "unreachable" };
}
};