MangaPark v3 Genre Search Fix (#7938)
* Update build.gradle * Update MangaPark.kt * Update MangaPark.kt
This commit is contained in:
parent
9c45ca3a68
commit
774b0a3de4
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'MangaPark v3'
|
extName = 'MangaPark v3'
|
||||||
pkgNameSuffix = 'all.mangapark'
|
pkgNameSuffix = 'all.mangapark'
|
||||||
extClass = '.MangaParkFactory'
|
extClass = '.MangaParkFactory'
|
||||||
extVersionCode = 6
|
extVersionCode = 7
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
containsNsfw = true
|
containsNsfw = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,12 +130,24 @@ open class MangaPark(
|
||||||
|
|
||||||
client.newCall(GET(url.build().toString(), headers)).asObservableSuccess()
|
client.newCall(GET(url.build().toString(), headers)).asObservableSuccess()
|
||||||
.map { response ->
|
.map { response ->
|
||||||
searchMangaParse(response)
|
genreSearchMangaParse(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun genreSearchMangaParse(response: Response): MangasPage {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
|
||||||
|
val mangas = document.select("div#subject-list div.col").map { element ->
|
||||||
|
searchMangaFromElement(element)
|
||||||
|
}
|
||||||
|
|
||||||
|
val hasNextPage = document.select(latestUpdatesNextPageSelector()).first() != null
|
||||||
|
|
||||||
|
return MangasPage(mangas, hasNextPage)
|
||||||
|
}
|
||||||
|
|
||||||
private fun mangaFromID(response: Response, id: String): MangasPage {
|
private fun mangaFromID(response: Response, id: String): MangasPage {
|
||||||
val infoElement = response.asJsoup().select("div#mainer div.container-fluid")
|
val infoElement = response.asJsoup().select("div#mainer div.container-fluid")
|
||||||
val manga = SManga.create().apply {
|
val manga = SManga.create().apply {
|
||||||
|
@ -166,18 +178,18 @@ open class MangaPark(
|
||||||
.joinToString("\n\n") { it.text() }
|
.joinToString("\n\n") { it.text() }
|
||||||
author = infoElement.select("div.attr-item:contains(author) a")
|
author = infoElement.select("div.attr-item:contains(author) a")
|
||||||
.joinToString { it.text().trim() }
|
.joinToString { it.text().trim() }
|
||||||
status = parseStatus(statusStr)
|
status = statusStr.parseStatus()
|
||||||
thumbnail_url = infoElement.select("div.detail-set div.attr-cover img").attr("abs:src")
|
thumbnail_url = infoElement.select("div.detail-set div.attr-cover img").attr("abs:src")
|
||||||
genre = infoElement.select("div.attr-item:contains(genres) span span")
|
genre = infoElement.select("div.attr-item:contains(genres) span span")
|
||||||
.joinToString { it.text().trim() }
|
.joinToString { it.text().trim() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseStatus(status: String?) = when {
|
private fun String?.parseStatus() = when {
|
||||||
status == null -> SManga.UNKNOWN
|
this == null -> SManga.UNKNOWN
|
||||||
status.contains("Ongoing") -> SManga.ONGOING
|
this.contains("Ongoing") -> SManga.ONGOING
|
||||||
status.contains("Hiatus") -> SManga.ONGOING
|
this.contains("Hiatus") -> SManga.ONGOING
|
||||||
status.contains("Completed") -> SManga.COMPLETED
|
this.contains("Completed") -> SManga.COMPLETED
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,16 +236,15 @@ open class MangaPark(
|
||||||
return SChapter.create().apply {
|
return SChapter.create().apply {
|
||||||
name = urlElement.text()
|
name = urlElement.text()
|
||||||
chapter_number = urlElement.attr("href").substringAfterLast("/").toFloat()
|
chapter_number = urlElement.attr("href").substringAfterLast("/").toFloat()
|
||||||
if (time != "") { date_upload = parseChapterDate(time) }
|
if (time != "") { date_upload = time.parseChapterDate() }
|
||||||
setUrlWithoutDomain(urlElement.attr("href"))
|
setUrlWithoutDomain(urlElement.attr("href"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseChapterDate(date: String): Long {
|
private fun String.parseChapterDate(): Long {
|
||||||
val value = date.split(' ')[0].toInt()
|
val value = this.split(' ')[0].toInt()
|
||||||
val timeStr = date.split(' ')[1].removeSuffix("s")
|
|
||||||
|
|
||||||
return when (timeStr) {
|
return when (this.split(' ')[1].removeSuffix("s")) {
|
||||||
"sec" -> Calendar.getInstance().apply {
|
"sec" -> Calendar.getInstance().apply {
|
||||||
add(Calendar.SECOND, value * -1)
|
add(Calendar.SECOND, value * -1)
|
||||||
}.timeInMillis
|
}.timeInMillis
|
||||||
|
|
Loading…
Reference in New Issue