This commit is contained in:
2 files changed
+95
-43
No files matched your search
@@ -767,27 +767,9 @@ replace_exact(
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
* Fallback in case Niadd removes the "N of M"
|
||||
* image link but leaves the actual image element.
|
||||
*/
|
||||
val imageUrlRegex = Regex(
|
||||
"""(?i)\\.(?:jpe?g|png|gif|webp|avif)(?:\\?|$)"""
|
||||
)
|
||||
|
||||
val image = root
|
||||
.select("img[src]")
|
||||
.firstOrNull { element ->
|
||||
val src = element.attr("src")
|
||||
|
||||
imageUrlRegex.containsMatchIn(src) &&
|
||||
!src.contains("logo", ignoreCase = true) &&
|
||||
!src.contains("avatar", ignoreCase = true)
|
||||
}
|
||||
|
||||
if (image != null) {
|
||||
return image.attrAsAbsoluteUrl("src")
|
||||
}
|
||||
// Do not fall back to an arbitrary <img>. Niadd may return a
|
||||
// service/notice page with a perfectly valid static image, which
|
||||
// would otherwise be cached as every manga page.
|
||||
|
||||
error(
|
||||
"Cannot find Niadd reader image for ${page.url}"
|
||||
|
||||
Reference in new issue
Block a user