diff --git a/src/fr/japanread/build.gradle b/src/fr/japanread/build.gradle index 6c8317760..f97f583cd 100644 --- a/src/fr/japanread/build.gradle +++ b/src/fr/japanread/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Japanread' pkgNameSuffix = 'fr.japanread' extClass = '.Japanread' - extVersionCode = 9 + extVersionCode = 10 isNsfw = true } diff --git a/src/fr/japanread/src/eu/kanade/tachiyomi/extension/fr/japanread/Japanread.kt b/src/fr/japanread/src/eu/kanade/tachiyomi/extension/fr/japanread/Japanread.kt index fd6360487..77b2243ad 100644 --- a/src/fr/japanread/src/eu/kanade/tachiyomi/extension/fr/japanread/Japanread.kt +++ b/src/fr/japanread/src/eu/kanade/tachiyomi/extension/fr/japanread/Japanread.kt @@ -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.Headers import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response @@ -37,6 +38,9 @@ class Japanread : ParsedHttpSource() { override val client: OkHttpClient = network.cloudflareClient + override fun headersBuilder(): Headers.Builder = Headers.Builder() + .add("Referer", "$baseUrl/") + // Generic (used by popular/latest/search) private fun mangaListFromElement(element: Element): SManga { return SManga.create().apply { @@ -111,8 +115,8 @@ class Japanread : ParsedHttpSource() { } } - private fun apiHeaders(refererURL: String) = headersBuilder().apply { - add("referer", refererURL) + private fun apiHeaders(refererURL: String) = headers.newBuilder().apply { + set("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 @@ -235,7 +239,7 @@ class Japanread : ParsedHttpSource() { override fun pageListParse(document: Document): List { val chapterId = document.select("meta[data-chapter-id]").attr("data-chapter-id") - val apiRequest = GET("$baseUrl/api/?id=$chapterId&type=chapter", apiHeaders("${document.location()}")) + 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 @@ -243,14 +247,18 @@ class Japanread : ParsedHttpSource() { val baseImagesUrl = jsonResult["baseImagesUrl"]!!.jsonPrimitive.content return jsonResult["page_array"]!!.jsonArray.mapIndexed { i, jsonEl -> - Page(i, baseUrl, "$baseUrl$baseImagesUrl/${jsonEl.jsonPrimitive.content}") + Page(i, document.location(), "$baseUrl$baseImagesUrl/${jsonEl.jsonPrimitive.content}") } } override fun imageUrlParse(document: Document) = "" override fun imageRequest(page: Page): Request { - return GET(page.imageUrl!!, headers) + val newHeaders = headers.newBuilder() + .set("Referer", page.url) + .build() + + return GET(page.imageUrl!!, newHeaders) } // Filters