parent
f0caa39e68
commit
616fafacbf
@ -6,7 +6,7 @@ ext {
|
||||
extName = 'Japanread'
|
||||
pkgNameSuffix = 'fr.japanread'
|
||||
extClass = '.Japanread'
|
||||
extVersionCode = 8
|
||||
extVersionCode = 9
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
@ -34,6 +35,8 @@ class Japanread : ParsedHttpSource() {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
override val client: OkHttpClient = network.cloudflareClient
|
||||
|
||||
// Generic (used by popular/latest/search)
|
||||
private fun mangaListFromElement(element: Element): SManga {
|
||||
return SManga.create().apply {
|
||||
@ -108,9 +111,12 @@ class Japanread : ParsedHttpSource() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun apiHeaders() = headersBuilder().apply {
|
||||
add("Referer", baseUrl)
|
||||
private fun apiHeaders(refererURL: String) = headersBuilder().apply {
|
||||
add("referer", refererURL)
|
||||
add("x-requested-with", "XMLHttpRequest")
|
||||
// without this we get 404 but I don't know why, I cannot find any information about this 'a' header.
|
||||
// In chrome the value is constantly changing on each request, but giving this fixed value seems to work
|
||||
add("a", "1df19bce590b")
|
||||
}.build()
|
||||
|
||||
// Chapters
|
||||
@ -229,7 +235,7 @@ class Japanread : ParsedHttpSource() {
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val chapterId = document.select("meta[data-chapter-id]").attr("data-chapter-id")
|
||||
|
||||
val apiRequest = GET("$baseUrl/api/?id=$chapterId&type=chapter", apiHeaders())
|
||||
val apiRequest = GET("$baseUrl/api/?id=$chapterId&type=chapter", apiHeaders("${document.location()}"))
|
||||
val apiResponse = client.newCall(apiRequest).execute()
|
||||
|
||||
val jsonResult = json.parseToJsonElement(apiResponse.body!!.string()).jsonObject
|
||||
|
Loading…
x
Reference in New Issue
Block a user