fix(realdebrid): persist web status and report relevant provider errors

Check Real-Debrid API and browser sessions through the account status flow, retain the service status across settings updates, and refresh the account row when a browser login is detected. Exclude unavailable providers that were never attempted from conversion failures and prevent aggregated fallback text from being mislabeled as a Debrid-Link terminal error. Bump the development version to 2.0.37 and add focused regression coverage.
This commit is contained in:
Sucukdeluxe
2026-08-14 21:02:30 +02:00
parent c2d5dbaeb3
commit b80209a10f
20 changed files with 556 additions and 81 deletions
+48 -3
View File
@@ -72,7 +72,7 @@ describe("debrid service", () => {
expect(megaWeb).toHaveBeenCalledTimes(1);
});
it("does not fallback when auto fallback is disabled", async () => {
it("does not fallback when auto fallback is disabled", async () => {
const settings = {
...defaultSettings(),
token: "rd-token",
@@ -102,8 +102,53 @@ describe("debrid service", () => {
const service = new DebridService(settings, { megaWebUnrestrict: megaWeb });
await expect(service.unrestrictLink("https://rapidgator.net/file/example.part2.rar.html")).rejects.toThrow();
expect(megaWeb).toHaveBeenCalledTimes(0);
});
expect(megaWeb).toHaveBeenCalledTimes(0);
});
it("reports only providers that were actually attempted", async () => {
const megaLogin = "disabled@example.test";
const debridLinkKeys = parseDebridLinkApiKeys("disabled-dl-key");
const settings = {
...defaultSettings(),
token: "rd-token",
megaDebridApiCredentials: `${megaLogin}:password`,
megaDebridApiEnabled: true,
megaDebridApiDisabledAccountIds: [getMegaDebridAccountId(megaLogin)],
debridLinkApiKeys: "disabled-dl-key",
debridLinkApiKeyDailyLimitBytes: { [debridLinkKeys[0].id]: 1 },
debridLinkApiKeyDailyUsageBytes: { [debridLinkKeys[0].id]: 1 },
providerDailyUsageDay: getProviderUsageDayKey(),
providerOrder: ["megadebrid-api", "debridlink", "realdebrid"] as const,
providerPrimary: "megadebrid-api" as const,
providerSecondary: "debridlink" as const,
providerTertiary: "realdebrid" as const,
autoProviderFallback: true
};
globalThis.fetch = (async (input: RequestInfo | URL): Promise<Response> => {
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
if (url.includes("api.real-debrid.com/rest/1.0/unrestrict/link")) {
return new Response(JSON.stringify({ error: "traffic_exhausted" }), {
status: 429,
headers: { "Content-Type": "application/json" }
});
}
return new Response("not-found", { status: 404 });
}) as typeof fetch;
const service = new DebridService(settings);
let message = "";
try {
await service.unrestrictLink("https://hoster.example/realdebrid-limit.bin");
} catch (error) {
message = String(error);
}
expect(message).toContain("Real-Debrid");
expect(message).toContain("traffic_exhausted");
expect(message).not.toContain("Mega-Debrid nicht verfuegbar");
expect(message).not.toContain("Debrid-Link nicht verfuegbar");
});
it("skips a provider whose daily limit is already reached and uses the next provider", async () => {
const calledUrls: string[] = [];