Fix Bato.to status and artist parsing (#12215)

Fixes #12085.
This commit is contained in:
MajorTanya 2022-06-17 15:32:26 +02:00 committed by GitHub
parent b11102c1bb
commit 72f14fb4e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 8 deletions

View File

@ -1,3 +1,10 @@
## 1.2.25
### Fix
* Status parsing
* Artist name parsing
## 1.2.23 ## 1.2.23
### Fix ### Fix

View File

@ -6,7 +6,7 @@ ext {
extName = 'Bato.to' extName = 'Bato.to'
pkgNameSuffix = 'all.batoto' pkgNameSuffix = 'all.batoto'
extClass = '.BatoToFactory' extClass = '.BatoToFactory'
extVersionCode = 24 extVersionCode = 25
isNsfw = true isNsfw = true
} }

View File

@ -323,11 +323,12 @@ open class BatoTo(
override fun mangaDetailsParse(document: Document): SManga { override fun mangaDetailsParse(document: Document): SManga {
val infoElement = document.select("div#mainer div.container-fluid") val infoElement = document.select("div#mainer div.container-fluid")
val manga = SManga.create() val manga = SManga.create()
val status = infoElement.select("div.attr-item:contains(status) span").text() val workStatus = infoElement.select("div.attr-item:contains(original work) span").text()
val uploadStatus = infoElement.select("div.attr-item:contains(upload status) span").text()
manga.title = infoElement.select("h3").text().removeEntities() manga.title = infoElement.select("h3").text().removeEntities()
manga.author = infoElement.select("div.attr-item:contains(author) a:first-child").text() manga.author = infoElement.select("div.attr-item:contains(author) a:first-child").text()
manga.artist = infoElement.select("div.attr-item:contains(author) a:last-child").text() manga.artist = infoElement.select("div.attr-item:contains(artist) a:last-child").text()
manga.status = parseStatus(status) manga.status = parseStatus(workStatus, uploadStatus)
manga.genre = infoElement.select(".attr-item b:contains(genres) + span ").joinToString { it.text() } manga.genre = infoElement.select(".attr-item b:contains(genres) + span ").joinToString { it.text() }
manga.description = infoElement.select("div.limit-html").text() + "\n" + infoElement.select(".episode-list > .alert-warning").text().trim() manga.description = infoElement.select("div.limit-html").text() + "\n" + infoElement.select(".episode-list > .alert-warning").text().trim()
manga.thumbnail_url = document.select("div.attr-cover img") manga.thumbnail_url = document.select("div.attr-cover img")
@ -335,10 +336,15 @@ open class BatoTo(
return manga return manga
} }
private fun parseStatus(status: String?) = when { private fun parseStatus(workStatus: String?, uploadStatus: String?) = when {
status == null -> SManga.UNKNOWN workStatus == null -> SManga.UNKNOWN
status.contains("Ongoing") -> SManga.ONGOING workStatus.contains("Ongoing") -> SManga.ONGOING
status.contains("Completed") -> SManga.COMPLETED workStatus.contains("Cancelled") -> SManga.CANCELLED
workStatus.contains("Hiatus") -> SManga.ON_HIATUS
workStatus.contains("Completed") -> when {
uploadStatus?.contains("Ongoing") == true -> SManga.PUBLISHING_FINISHED
else -> SManga.COMPLETED
}
else -> SManga.UNKNOWN else -> SManga.UNKNOWN
} }