Get all chapters (#9362)

Co-authored-by: Le Cong Hau <hau.le@brains-tech.co.jp>
This commit is contained in:
Le Cong Hau 2021-10-05 02:03:35 +09:00 committed by GitHub
parent 93988e8990
commit 835b61a042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MeDocTruyenTranh'
pkgNameSuffix = 'vi.medoctruyentranh'
extClass = '.MeDocTruyenTranh'
extVersionCode = 3
extVersionCode = 4
}
apply from: "$rootDir/common.gradle"

View File

@ -45,6 +45,17 @@ class MeDocTruyenTranh : ParsedHttpSource() {
return list
}
private fun JSONArray.flatten(): JSONArray {
val list = mutableListOf<Any>()
for (i in 0 until this.length()) {
val childArray = this[i] as JSONArray
for (j in 0 until childArray.length()) {
list.add(childArray[j])
}
}
return JSONArray(list)
}
override fun popularMangaParse(response: Response): MangasPage {
val document = response.asJsoup()
@ -134,7 +145,7 @@ class MeDocTruyenTranh : ParsedHttpSource() {
.getJSONObject("initialState")
.getJSONObject("detail")
.getJSONArray("story_chapters")
.getJSONArray(0)
.flatten()
.mapJSONArray { _, jsonObject: JSONObject ->
SChapter.create().apply {
name = jsonObject.getString("title")