From 191d24ac5de79c6fcc6b3d801314dd75d8c40be6 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Sun, 10 May 2026 16:33:49 +0800 Subject: [PATCH] =?UTF-8?q?opds=E5=B0=81=E9=9D=A2=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/opds.client.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/lib/opds.client.ts b/src/lib/opds.client.ts index db538c0..e82da71 100644 --- a/src/lib/opds.client.ts +++ b/src/lib/opds.client.ts @@ -111,9 +111,28 @@ function isNavigationLink(link: ParsedFeedLink): boolean { return isNavigationRel(link.rel) || type.includes('kind=navigation') || (type.includes('opds-catalog') && !isAcquisitionRel(link.rel)); } +function isCoverRel(rel?: string): boolean { + if (!rel) return false; + const normalized = rel.toLowerCase(); + return normalized.includes('opds-spec.org/cover') + || normalized.includes('opds-spec.org/image') + || normalized.includes('image/thumbnail') + || normalized === 'thumbnail' + || normalized === 'cover'; +} + +function isImageType(type?: string): boolean { + return !!type && type.toLowerCase().startsWith('image/'); +} + function pickCoverLink(links: ParsedFeedLink[]): string | undefined { - const cover = links.find((link) => link.rel?.includes('image/thumbnail')) - || links.find((link) => link.rel?.includes('image')); + const thumbnail = links.find((link) => { + const rel = (link.rel || '').toLowerCase(); + return rel.includes('thumbnail') && (isCoverRel(link.rel) || isImageType(link.type)); + }); + const cover = thumbnail + || links.find((link) => isCoverRel(link.rel)) + || links.find((link) => isImageType(link.type) && !isAcquisitionRel(link.rel)); return cover?.href; }