Update desu source. Genre and Time support (#404)
This commit is contained in:
parent
e399c958fb
commit
b4ba560787
|
@ -5,8 +5,8 @@ ext {
|
||||||
appName = 'Tachiyomi: Desu'
|
appName = 'Tachiyomi: Desu'
|
||||||
pkgNameSuffix = "ru.desu"
|
pkgNameSuffix = "ru.desu"
|
||||||
extClass = '.Desu'
|
extClass = '.Desu'
|
||||||
extVersionCode = 3
|
extVersionCode = 4
|
||||||
extVersionSuffix = 2
|
extVersionSuffix = 3
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,19 +30,28 @@ class Desu : HttpSource() {
|
||||||
for (i in 0 until arr.length()) {
|
for (i in 0 until arr.length()) {
|
||||||
var obj = arr.getJSONObject(i)
|
var obj = arr.getJSONObject(i)
|
||||||
ret.add(SManga.create().apply {
|
ret.add(SManga.create().apply {
|
||||||
mangaFromJSON(obj)
|
mangaFromJSON(obj, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return MangasPage(ret, next)
|
return MangasPage(ret, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SManga.mangaFromJSON(obj: JSONObject) {
|
private fun SManga.mangaFromJSON(obj: JSONObject, chapter: Boolean) {
|
||||||
val id = obj.getInt("id")
|
val id = obj.getInt("id")
|
||||||
url = "/$id"
|
url = "/$id"
|
||||||
title = obj.getString("name")
|
title = obj.getString("name")
|
||||||
thumbnail_url = obj.getJSONObject("image").getString("original")
|
thumbnail_url = obj.getJSONObject("image").getString("original")
|
||||||
description = obj.getString("description")
|
description = obj.getString("description")
|
||||||
|
genre = if (chapter) {
|
||||||
|
val jsonArray = obj.getJSONArray("genres")
|
||||||
|
var genreList = kotlin.collections.mutableListOf<String>()
|
||||||
|
for (i in 0 until jsonArray.length()) {
|
||||||
|
genreList.add(jsonArray.getJSONObject(i).getString("russian"))
|
||||||
|
}
|
||||||
|
genreList.joinToString()
|
||||||
|
} else {
|
||||||
|
obj.getString("genres")
|
||||||
|
}
|
||||||
status = when (obj.getString("status")) {
|
status = when (obj.getString("status")) {
|
||||||
"ongoing" -> SManga.ONGOING
|
"ongoing" -> SManga.ONGOING
|
||||||
"released" -> SManga.COMPLETED
|
"released" -> SManga.COMPLETED
|
||||||
|
@ -95,7 +104,7 @@ class Desu : HttpSource() {
|
||||||
|
|
||||||
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
|
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
|
||||||
val obj = JSONObject(response.body()!!.string()).getJSONObject("response")
|
val obj = JSONObject(response.body()!!.string()).getJSONObject("response")
|
||||||
mangaFromJSON(obj)
|
mangaFromJSON(obj, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
|
@ -110,9 +119,15 @@ class Desu : HttpSource() {
|
||||||
ret.add(SChapter.create().apply {
|
ret.add(SChapter.create().apply {
|
||||||
val ch = obj2.getString("ch")
|
val ch = obj2.getString("ch")
|
||||||
val title = if (obj2.getString("title") == "null") "" else obj2.getString("title")
|
val title = if (obj2.getString("title") == "null") "" else obj2.getString("title")
|
||||||
|
if (title.isEmpty()) {
|
||||||
|
name = "Глава $ch"
|
||||||
|
} else {
|
||||||
name = "$ch - $title"
|
name = "$ch - $title"
|
||||||
|
}
|
||||||
val id = obj2.getString("id")
|
val id = obj2.getString("id")
|
||||||
url = "/$cid/chapter/$id"
|
url = "/$cid/chapter/$id"
|
||||||
|
chapter_number = ch.toFloat()
|
||||||
|
date_upload = obj2.getLong("date")*1000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue