Mark sparse MangaDex hosted catalogs as partial

This commit is contained in:
Codex committed 2026-10-13 22:01:57 +02:00
1 parent 47de081721
commit 0fc1a7b52a
2 files changed
+9 -2

No files matched your search

+5 -1
View File
@@ -72,6 +72,10 @@ function availabilitySummary(attributes, releases, chapters, externalReleases =
const numbered = chapters.filter(ref => !ref.special);
const expected = chapterNumber(attributes.lastChapter);
const maximum = numbered.length ? Math.max(...numbered.map(ref => Number(ref.number))) : null;
// Reaching the final chapter number is not full coverage when the catalog
// contains fewer distinct numbered releases than the expected chapter span.
const expectedCount = expected && /^\d+$/.test(expected) ? Number(expected) : null;
const sparse = expectedCount && numbered.length < expectedCount;
const reason = chapters.length ? null : externalReleases > 0 ? 'external-only'
: Array.isArray(attributes.availableTranslatedLanguages) && !attributes.availableTranslatedLanguages.includes('en') ? 'no-english' : 'no-hosted-pages';
const message = reason === 'external-only' ? `MangaDex lists ${externalReleases} English external-link releases, but no hosted English pages. External links are not downloaded.`
@@ -80,7 +84,7 @@ function availabilitySummary(attributes, releases, chapters, externalReleases =
return { language: 'en', hostedReleases: releases.filter(r => !r.attributes?.externalUrl && Number(r.attributes?.pages) > 0).length,
selectedChapters: chapters.length, numberedChapters: numbered.length, specialReleases: chapters.length - numbered.length,
externalReleases, expectedLastChapter: expected, highestHostedChapter: maximum,
coverage: expected && (maximum === null || maximum < Number(expected)) ? 'partial' : 'unknown', reason, message };
coverage: expected && (maximum === null || maximum < Number(expected) || sparse) ? 'partial' : 'unknown', reason, message };
}
async function jsonGet(http, url) {