Skip to content

Commit

Permalink
Madara: Improve thumbnail (#5762)
Browse files Browse the repository at this point in the history
* Improve thumbnail

* Bump version
  • Loading branch information
choppeh authored and cuong-tran committed Oct 30, 2024
1 parent a8a11ad commit aebd1b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib-multisrc/madara/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("lib-multisrc")
}

baseVersionCode = 36
baseVersionCode = 37

dependencies {
api(project(":lib:cryptoaes"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1106,6 +1115,7 @@ abstract class Madara(

companion object {
const val URL_SEARCH_PREFIX = "slug:"
val URL_REGEX = """^(https?://[^\s/$.?#].[^\s]*)${'$'}""".toRegex()
}
}

Expand Down

0 comments on commit aebd1b6

Please sign in to comment.