Madara: Improve thumbnail (#5762)

* Improve thumbnail

* Bump version
This commit is contained in:
Chopper 2024-10-30 12:11:05 -03:00 committed by GitHub
parent fa3e73e2ae
commit 2830a0a1a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -2,7 +2,7 @@ plugins {
id("lib-multisrc")
}
baseVersionCode = 36
baseVersionCode = 37
dependencies {
api(project(":lib:cryptoaes"))

View File

@ -767,12 +767,21 @@ abstract class Madara(
return when {
element.hasAttr("data-src") -> element.attr("abs:data-src")
element.hasAttr("data-lazy-src") -> element.attr("abs:data-lazy-src")
element.hasAttr("srcset") -> element.attr("abs:srcset").substringBefore(" ")
element.hasAttr("srcset") -> element.attr("abs:srcset").getSrcSetImage()
element.hasAttr("data-cfsrc") -> element.attr("abs:data-cfsrc")
else -> element.attr("abs:src")
}
}
/**
* Get the best image quality available from srcset
*/
private fun String.getSrcSetImage(): String? {
return this.split(" ")
.filter(URL_REGEX::matches)
.maxOfOrNull(String::toString)
}
/**
* Set it to true if the source uses the new AJAX endpoint to
* fetch the manga chapters instead of the old admin-ajax.php one.
@ -1106,6 +1115,7 @@ abstract class Madara(
companion object {
const val URL_SEARCH_PREFIX = "slug:"
val URL_REGEX = """^(https?://[^\s/$.?#].[^\s]*)${'$'}""".toRegex()
}
}