Show how many Viaplay accounts were tried on VOD soft-fail.

This commit is contained in:
Jos Vooges | STH 2026-09-24 01:01:02 +02:00
parent 1847f3c72f
commit 89c88abc31
2 changed files with 22 additions and 3 deletions

View file

@ -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(),
};
});

View file

@ -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);
}