Let the media server card show the whole mesh, not just this host
A partner's Emby URL is http://localhost:8096 — true there, meaningless here — so nobody queries a partner's media server directly. Each host reports its own over the SSH call remote_arr_cache_writer.sh already makes, which keeps its API keys on it and costs no extra connection. Local is the default: opening the tab to check your own server should not first make you read past a partner's. A partner with no cache is stated as not collected rather than omitted, because an empty mesh view and a partner that is down look identical otherwise.
This commit is contained in:
@@ -486,7 +486,7 @@ function vv_arrs_all(): array {
|
||||
// their own. Cheap — three run records and three log tails — and it rides this payload
|
||||
// rather than a fourth endpoint because it is shown on this page and cached with it.
|
||||
'media_jobs' => function_exists('vv_media_jobs') ? vv_media_jobs() : [],
|
||||
'media_servers' => function_exists('vv_media_server_stats') ? vv_media_server_stats() : [],
|
||||
'media_servers' => function_exists('vv_media_servers_mesh') ? vv_media_servers_mesh() : [],
|
||||
'host' => $currentHost,
|
||||
'settings' => [
|
||||
'arr_sync_enabled' => ($vars['ARR_SYNC_ENABLED'] ?? 'true') !== 'false',
|
||||
|
||||
@@ -367,6 +367,46 @@ function vv_media_server_stats(): array {
|
||||
return $out;
|
||||
}
|
||||
|
||||
// ── The mesh view ─────────────────────────────────────────────────────────────────────────────
|
||||
// Local live, partners from cache — the same split the arrs use, for the same reason. A partner's
|
||||
// Emby URL is http://localhost:8096, which is true on that host and meaningless here, so nobody
|
||||
// queries a partner's media server directly. Each host answers about itself over SSH in
|
||||
// remote_arr_cache_writer.sh and its API keys never leave it.
|
||||
//
|
||||
// A partner with no cache is reported as not collected rather than as having no media servers.
|
||||
// Those are different states and only one of them is the partner's fault — the arrs page already
|
||||
// makes that distinction and this matches it rather than inventing a second vocabulary.
|
||||
function vv_media_servers_mesh(): array {
|
||||
$me = vv_detect_host();
|
||||
$names = function_exists('vv_known_hosts') ? vv_known_hosts() : [$me => $me];
|
||||
$out = [];
|
||||
|
||||
foreach (array_keys($names) as $h) {
|
||||
if ($h === $me) {
|
||||
$out[] = [
|
||||
'host' => $h,
|
||||
'name' => $names[$h] ?? $h,
|
||||
'local' => true,
|
||||
'servers' => vv_media_server_stats(),
|
||||
];
|
||||
continue;
|
||||
}
|
||||
$f = VV_CACHE_DIR . '/media_remote_' . $h . '.json';
|
||||
$raw = @file_get_contents($f);
|
||||
$d = $raw !== false ? json_decode($raw, true) : null;
|
||||
$out[] = [
|
||||
'host' => $h,
|
||||
'name' => $names[$h] ?? $h,
|
||||
'local' => false,
|
||||
'cached' => is_array($d),
|
||||
'cache_miss' => !is_array($d),
|
||||
'cache_age' => is_array($d) ? max(0, time() - (int)@filemtime($f)) : null,
|
||||
'servers' => is_array($d) ? $d : [],
|
||||
];
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
// ── The media jobs that had nowhere to be seen ────────────────────────────────────────────────
|
||||
// Three scripts that operate on the media files every day and appeared in no tab: play state sync
|
||||
// every thirty minutes, permissions and the cleaner nightly. The only way to know whether any of
|
||||
|
||||
Reference in New Issue
Block a user