MyReadingManga: Fix broken last image, whitespace in description (#19239)

This commit is contained in:
Vetle Ledaal 2023-12-09 14:35:26 +00:00 committed by GitHub
parent 49be52f52d
commit 74cb5ba984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MyReadingManga'
pkgNameSuffix = 'all.myreadingmanga'
extClass = '.MyReadingMangaFactory'
extVersionCode = 48
extVersionCode = 49
isNsfw = true
}

View File

@ -108,12 +108,14 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
private val extensionRegex = Regex("""\.(jpg|png|jpeg|webp)""")
private fun getImage(element: Element): String {
return when {
private fun getImage(element: Element): String? {
val url = when {
element.attr("data-src").contains(extensionRegex) -> element.attr("abs:data-src")
element.attr("src").contains(extensionRegex) -> element.attr("abs:src")
else -> element.attr("abs:data-lazy-src")
}
return if (URLUtil.isValidUrl(url)) url else null
}
// removes resizing
@ -151,7 +153,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
val scanlatedBy = document.select(".entry-terms:has(a[href*=group])").firstOrNull()
?.select("a[href*=group]")?.joinToString(prefix = "Scanlated by: ") { it.text() }
val extendedDescription = document.select(".entry-content p:not(p:containsOwn(|)):not(.chapter-class + p)").joinToString("\n") { it.text() }
description = listOfNotNull(basicDescription, scanlatedBy, extendedDescription).joinToString("\n")
description = listOfNotNull(basicDescription, scanlatedBy, extendedDescription).joinToString("\n").trim()
status = when (document.select("a[href*=status]").first()?.text()) {
"Ongoing" -> SManga.ONGOING
"Completed" -> SManga.COMPLETED
@ -218,7 +220,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
override fun pageListParse(document: Document): List<Page> {
return (document.select("div img") + document.select("div.separator img[data-src]"))
.map { getImage(it) }
.mapNotNull { getImage(it) }
.distinct()
.mapIndexed { i, url -> Page(i, "", url) }
}