From 89c88abc311e3e169baba07dae1b4a304545ef31 Mon Sep 17 00:00:00 2001 From: Jos Vooges | STH Date: Thu, 24 Sep 2026 01:01:02 +0200 Subject: [PATCH] Show how many Viaplay accounts were tried on VOD soft-fail. --- apps/master-api/src/app.ts | 2 +- apps/master-api/src/viaplay/play.ts | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/master-api/src/app.ts b/apps/master-api/src/app.ts index e78423c..29318da 100644 --- a/apps/master-api/src/app.ts +++ b/apps/master-api/src/app.ts @@ -106,7 +106,7 @@ async function main() { return { status: "ok", service: "master-api", - version: "1.0.4-dontgo-detect-v7", + version: "1.0.5-vod-rr-diag", lastVodPlay: getLastVodPlay(), }; }); diff --git a/apps/master-api/src/viaplay/play.ts b/apps/master-api/src/viaplay/play.ts index 70e00a3..397f8e3 100644 --- a/apps/master-api/src/viaplay/play.ts +++ b/apps/master-api/src/viaplay/play.ts @@ -32,6 +32,10 @@ export type LastVodPlayDiag = { mediaPath: string | null; error: string | null; resolver: string; + /** Hoeveel accounts deze play heeft geprobeerd (eigen cookies per account). */ + triedAccounts?: number; + /** Korte labels van geprobeerde accounts (geen secrets). */ + triedLabels?: string[]; }; let lastVodPlay: LastVodPlayDiag | null = null; @@ -340,8 +344,11 @@ export async function resolveViaplayGuidPlay( let cachedKeys = await keysForMediaGuid(sessionSecret, guid); let lastError: Error | null = null; + const triedLabels: string[] = []; + const attemptErrors: string[] = []; // Zelfde round-robin als live: elke VOD-play start op een ander account. + // Per account: eigen session/AT/PL-cookies (na persistentLogin-refresh). const ordered = accountOrder(guid, accounts, []); const productUrl = @@ -349,6 +356,8 @@ export async function resolveViaplayGuidPlay( `https://content.viaplay.com/${tweaks.deviceKey}/sport/${guid}?partial=true`; for (const account of ordered) { + const label = account.label || account.email || account.id; + triedLabels.push(label); try { // Verse session-cookie is verplicht; tray-tokens verlopen snel. let creds = account; @@ -442,6 +451,8 @@ export async function resolveViaplayGuidPlay( accountId: account.id, mediaPath: mediaPathOf(mpdUrl), error: null, + triedAccounts: triedLabels.length, + triedLabels, }); return { @@ -455,17 +466,25 @@ export async function resolveViaplayGuidPlay( }; } catch (err) { lastError = err instanceof Error ? err : new Error(String(err)); + attemptErrors.push(`${label}: ${lastError.message}`); } } + const summary = + attemptErrors.length > 1 + ? `Alle ${attemptErrors.length} Viaplay-accounts mislukt (eigen cookies per account). Laatste: ${lastError?.message || "onbekend"}` + : lastError?.message || "Viaplay VOD-play mislukt"; + recordVodPlay({ guid, ok: false, title: null, accountId: null, mediaPath: null, - error: lastError?.message || "Viaplay VOD-play mislukt", + error: summary, + triedAccounts: triedLabels.length, + triedLabels, }); - throw lastError || new AppError("UPSTREAM", "Viaplay VOD-play mislukt", 502); + throw new AppError("UPSTREAM", summary, 502); }