Fix JSON error in MangasProject. (#6476)
This commit is contained in:
parent
e2a7cf1013
commit
8aa1497d4d
|
@ -17,11 +17,8 @@ class LeitorNet : MangasProject("Leitor.net", "https://leitor.net", "pt-BR") {
|
|||
// Existing mangas and other titles in the library still work.
|
||||
override val id: Long = 2225174659569980836
|
||||
|
||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||
override val client: OkHttpClient = super.client.newBuilder()
|
||||
.addInterceptor(RateLimitInterceptor(5, 1, TimeUnit.SECONDS))
|
||||
.connectTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.MINUTES)
|
||||
.writeTimeout(1, TimeUnit.MINUTES)
|
||||
.build()
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,11 +16,8 @@ class MangaLivre : MangasProject("Mangá Livre", "https://mangalivre.net", "pt-B
|
|||
// Hardcode the id because the language wasn't specific.
|
||||
override val id: Long = 4762777556012432014
|
||||
|
||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||
override val client: OkHttpClient = super.client.newBuilder()
|
||||
.addInterceptor(RateLimitInterceptor(5, 1, TimeUnit.SECONDS))
|
||||
.connectTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.MINUTES)
|
||||
.writeTimeout(1, TimeUnit.MINUTES)
|
||||
.build()
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
|
|
|
@ -8,11 +8,8 @@ import java.util.concurrent.TimeUnit
|
|||
|
||||
class Toonei : MangasProject("Toonei", "https://toonei.com", "pt-BR") {
|
||||
|
||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||
override val client: OkHttpClient = super.client.newBuilder()
|
||||
.addInterceptor(RateLimitInterceptor(5, 1, TimeUnit.SECONDS))
|
||||
.connectTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.MINUTES)
|
||||
.writeTimeout(1, TimeUnit.MINUTES)
|
||||
.build()
|
||||
|
||||
override fun getReaderToken(document: Document): String? {
|
||||
|
|
|
@ -232,7 +232,7 @@ abstract class MangasProject(
|
|||
(if (chapterName == "") "" else " - $chapterName")
|
||||
date_upload = obj["date_created"].string.substringBefore("T").toDate()
|
||||
scanlator = release["scanlators"]!!.array
|
||||
.map { scanObj -> scanObj.obj["name"].string }
|
||||
.mapNotNull { scanObj -> scanObj.obj["name"].string.ifEmpty { null } }
|
||||
.sorted()
|
||||
.joinToString()
|
||||
url = release["link"].string
|
||||
|
@ -299,7 +299,13 @@ abstract class MangasProject(
|
|||
return GET(page.imageUrl!!, newHeaders)
|
||||
}
|
||||
|
||||
private fun Response.asJsonObject(): JsonObject = JSON_PARSER.parse(body()!!.string()).obj
|
||||
private fun Response.asJsonObject(): JsonObject {
|
||||
if (!isSuccessful) {
|
||||
throw Exception("HTTP error ${code()}")
|
||||
}
|
||||
|
||||
return JSON_PARSER.parse(body()!!.string()).obj
|
||||
}
|
||||
|
||||
private fun String.toDate(): Long {
|
||||
return try {
|
||||
|
@ -315,7 +321,7 @@ abstract class MangasProject(
|
|||
private const val ACCEPT_JSON = "application/json, text/javascript, */*; q=0.01"
|
||||
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,es;q=0.6,gl;q=0.5"
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class MangasProjectGenerator : ThemeSourceGenerator {
|
|||
|
||||
override val themeClass = "MangasProject"
|
||||
|
||||
override val baseVersionCode: Int = 1
|
||||
override val baseVersionCode: Int = 2
|
||||
|
||||
override val sources = listOf(
|
||||
SingleLang("Leitor.net", "https://leitor.net", "pt-BR", className = "LeitorNet", isNsfw = true, overrideVersionCode = 1),
|
||||
|
|
Loading…
Reference in New Issue