Detect dead links as permanent errors, fix last-episode extraction race
Build and Release / build (push) Has been cancelled
Build and Release / build (push) Has been cancelled
Dead link detection: - Mega-Web: parse hoster error messages (hosterNotAvailable, etc.) from HTML and throw specific error instead of returning null - MegaDebridClient: stop retrying on permanent hoster errors - download-manager: isPermanentLinkError() immediately fails items with dead links instead of retrying forever Extraction race condition: - package_done cleanup policy checked if all items were "completed" (downloaded) but not if they were "extracted" — removing the package before the last episode could be extracted - Both applyCompletedCleanupPolicy and applyPackageDoneCleanup now guard against premature removal when autoExtract is enabled Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
3ed31b7994
commit
09bc354c18
@@ -42,6 +42,45 @@ function parseSetCookieFromHeaders(headers: Headers): string {
|
||||
.join("; ");
|
||||
}
|
||||
|
||||
const PERMANENT_HOSTER_ERRORS = [
|
||||
"hosternotavailable",
|
||||
"filenotfound",
|
||||
"file_unavailable",
|
||||
"file not found",
|
||||
"link is dead",
|
||||
"file has been removed",
|
||||
"file has been deleted",
|
||||
"file was deleted",
|
||||
"file was removed",
|
||||
"not available",
|
||||
"file is no longer available"
|
||||
];
|
||||
|
||||
function parsePageErrors(html: string): string[] {
|
||||
const errors: string[] = [];
|
||||
const errorRegex = /class=["'][^"']*\berror\b[^"']*["'][^>]*>([^<]+)</gi;
|
||||
let m: RegExpExecArray | null;
|
||||
while ((m = errorRegex.exec(html)) !== null) {
|
||||
const text = m[1].replace(/^Fehler:\s*/i, "").trim();
|
||||
if (text) {
|
||||
errors.push(text);
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
function isPermanentHosterError(errors: string[]): string | null {
|
||||
for (const err of errors) {
|
||||
const lower = err.toLowerCase();
|
||||
for (const pattern of PERMANENT_HOSTER_ERRORS) {
|
||||
if (lower.includes(pattern)) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function parseCodes(html: string): CodeEntry[] {
|
||||
const entries: CodeEntry[] = [];
|
||||
const cardRegex = /<div[^>]*class=['"][^'"]*acp-box[^'"]*['"][^>]*>[\s\S]*?<\/div>/gi;
|
||||
@@ -306,6 +345,14 @@ export class MegaWebFallback {
|
||||
});
|
||||
|
||||
const html = await page.text();
|
||||
|
||||
// Check for permanent hoster errors before looking for debrid codes
|
||||
const pageErrors = parsePageErrors(html);
|
||||
const permanentError = isPermanentHosterError(pageErrors);
|
||||
if (permanentError) {
|
||||
throw new Error(`Mega-Web: Link permanent ungültig (${permanentError})`);
|
||||
}
|
||||
|
||||
const code = pickCode(parseCodes(html), link);
|
||||
if (!code) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user