opds封面获取优化
This commit is contained in:
+21
-2
@@ -111,9 +111,28 @@ function isNavigationLink(link: ParsedFeedLink): boolean {
|
|||||||
return isNavigationRel(link.rel) || type.includes('kind=navigation') || (type.includes('opds-catalog') && !isAcquisitionRel(link.rel));
|
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 {
|
function pickCoverLink(links: ParsedFeedLink[]): string | undefined {
|
||||||
const cover = links.find((link) => link.rel?.includes('image/thumbnail'))
|
const thumbnail = links.find((link) => {
|
||||||
|| links.find((link) => link.rel?.includes('image'));
|
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;
|
return cover?.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user