parent
f0caa39e68
commit
616fafacbf
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'Japanread'
|
extName = 'Japanread'
|
||||||
pkgNameSuffix = 'fr.japanread'
|
pkgNameSuffix = 'fr.japanread'
|
||||||
extClass = '.Japanread'
|
extClass = '.Japanread'
|
||||||
extVersionCode = 8
|
extVersionCode = 9
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import kotlinx.serialization.json.Json
|
|||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
@ -34,6 +35,8 @@ class Japanread : ParsedHttpSource() {
|
|||||||
|
|
||||||
private val json: Json by injectLazy()
|
private val json: Json by injectLazy()
|
||||||
|
|
||||||
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
// Generic (used by popular/latest/search)
|
// Generic (used by popular/latest/search)
|
||||||
private fun mangaListFromElement(element: Element): SManga {
|
private fun mangaListFromElement(element: Element): SManga {
|
||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
@ -108,9 +111,12 @@ class Japanread : ParsedHttpSource() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun apiHeaders() = headersBuilder().apply {
|
private fun apiHeaders(refererURL: String) = headersBuilder().apply {
|
||||||
add("Referer", baseUrl)
|
add("referer", refererURL)
|
||||||
add("x-requested-with", "XMLHttpRequest")
|
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()
|
}.build()
|
||||||
|
|
||||||
// Chapters
|
// Chapters
|
||||||
@ -229,7 +235,7 @@ class Japanread : ParsedHttpSource() {
|
|||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val chapterId = document.select("meta[data-chapter-id]").attr("data-chapter-id")
|
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 apiResponse = client.newCall(apiRequest).execute()
|
||||||
|
|
||||||
val jsonResult = json.parseToJsonElement(apiResponse.body!!.string()).jsonObject
|
val jsonResult = json.parseToJsonElement(apiResponse.body!!.string()).jsonObject
|
||||||
|
Loading…
x
Reference in New Issue
Block a user