Fix HTTP error 400 in HN. (#13096)
This commit is contained in:
parent
05070ea80b
commit
1ad891e202
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'HQ Now!'
|
extName = 'HQ Now!'
|
||||||
pkgNameSuffix = 'pt.hqnow'
|
pkgNameSuffix = 'pt.hqnow'
|
||||||
extClass = '.HQNow'
|
extClass = '.HQNow'
|
||||||
extVersionCode = 6
|
extVersionCode = 7
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
@ -11,12 +11,12 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
|||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.buildJsonObject
|
import kotlinx.serialization.json.buildJsonObject
|
||||||
import kotlinx.serialization.json.decodeFromJsonElement
|
import kotlinx.serialization.json.decodeFromJsonElement
|
||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.put
|
import kotlinx.serialization.json.put
|
||||||
import kotlinx.serialization.json.putJsonObject
|
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
@ -32,7 +32,7 @@ class HQNow : HttpSource() {
|
|||||||
|
|
||||||
override val name = "HQ Now!"
|
override val name = "HQ Now!"
|
||||||
|
|
||||||
override val baseUrl = "http://www.hq-now.com"
|
override val baseUrl = "https://www.hq-now.com"
|
||||||
|
|
||||||
override val lang = "pt-BR"
|
override val lang = "pt-BR"
|
||||||
|
|
||||||
@ -79,24 +79,15 @@ class HQNow : HttpSource() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
val payload = buildJsonObject {
|
return queryRequest(
|
||||||
put("operationName", "getHqsByFilters")
|
query = query,
|
||||||
put("query", query)
|
operationName = "getHqsByFilters",
|
||||||
putJsonObject("variables") {
|
variables = buildJsonObject {
|
||||||
put("orderByViews", true)
|
put("orderByViews", true)
|
||||||
put("loadCovers", true)
|
put("loadCovers", true)
|
||||||
put("limit", 300)
|
put("limit", 300)
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
val body = payload.toString().toRequestBody(JSON_MEDIA_TYPE)
|
|
||||||
|
|
||||||
val newHeaders = headersBuilder()
|
|
||||||
.add("Content-Length", body.contentLength().toString())
|
|
||||||
.add("Content-Type", body.contentType().toString())
|
|
||||||
.build()
|
|
||||||
|
|
||||||
return POST(GRAPHQL_URL, newHeaders, body)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaParse(response: Response): MangasPage {
|
override fun popularMangaParse(response: Response): MangasPage {
|
||||||
@ -125,19 +116,7 @@ class HQNow : HttpSource() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
val payload = buildJsonObject {
|
return queryRequest(query = query, operationName = "getRecentlyUpdatedHqs")
|
||||||
put("operationName", "getRecentlyUpdatedHqs")
|
|
||||||
put("query", query)
|
|
||||||
}
|
|
||||||
|
|
||||||
val body = payload.toString().toRequestBody(JSON_MEDIA_TYPE)
|
|
||||||
|
|
||||||
val newHeaders = headersBuilder()
|
|
||||||
.add("Content-Length", body.contentLength().toString())
|
|
||||||
.add("Content-Type", body.contentType().toString())
|
|
||||||
.build()
|
|
||||||
|
|
||||||
return POST(GRAPHQL_URL, newHeaders, body)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||||
@ -166,22 +145,13 @@ class HQNow : HttpSource() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
val payload = buildJsonObject {
|
return queryRequest(
|
||||||
put("operationName", "getHqsByName")
|
query = queryStr,
|
||||||
put("query", queryStr)
|
operationName = "getHqsByName",
|
||||||
putJsonObject("variables") {
|
variables = buildJsonObject {
|
||||||
put("name", query)
|
put("name", query)
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
val body = payload.toString().toRequestBody(JSON_MEDIA_TYPE)
|
|
||||||
|
|
||||||
val newHeaders = headersBuilder()
|
|
||||||
.add("Content-Length", body.contentLength().toString())
|
|
||||||
.add("Content-Type", body.contentType().toString())
|
|
||||||
.build()
|
|
||||||
|
|
||||||
return POST(GRAPHQL_URL, newHeaders, body)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchMangaParse(response: Response): MangasPage {
|
override fun searchMangaParse(response: Response): MangasPage {
|
||||||
@ -228,22 +198,13 @@ class HQNow : HttpSource() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
val payload = buildJsonObject {
|
return queryRequest(
|
||||||
put("operationName", "getHqsById")
|
query = query,
|
||||||
put("query", query)
|
operationName = "getHqsById",
|
||||||
putJsonObject("variables") {
|
variables = buildJsonObject {
|
||||||
put("id", comicBookId.toInt())
|
put("id", comicBookId.toInt())
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
val body = payload.toString().toRequestBody(JSON_MEDIA_TYPE)
|
|
||||||
|
|
||||||
val newHeaders = headersBuilder()
|
|
||||||
.add("Content-Length", body.contentLength().toString())
|
|
||||||
.add("Content-Type", body.contentType().toString())
|
|
||||||
.build()
|
|
||||||
|
|
||||||
return POST(GRAPHQL_URL, newHeaders, body)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mangaDetailsParse(response: Response): SManga = SManga.create().apply {
|
override fun mangaDetailsParse(response: Response): SManga = SManga.create().apply {
|
||||||
@ -298,22 +259,13 @@ class HQNow : HttpSource() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
val payload = buildJsonObject {
|
return queryRequest(
|
||||||
put("operationName", "getChapterById")
|
query = query,
|
||||||
put("query", query)
|
operationName = "getChapterById",
|
||||||
putJsonObject("variables") {
|
variables = buildJsonObject {
|
||||||
put("chapterId", chapterId.toInt())
|
put("chapterId", chapterId.toInt())
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
val body = payload.toString().toRequestBody(JSON_MEDIA_TYPE)
|
|
||||||
|
|
||||||
val newHeaders = headersBuilder()
|
|
||||||
.add("Content-Length", body.contentLength().toString())
|
|
||||||
.add("Content-Type", body.contentType().toString())
|
|
||||||
.build()
|
|
||||||
|
|
||||||
return POST(GRAPHQL_URL, newHeaders, body)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
@ -339,6 +291,23 @@ class HQNow : HttpSource() {
|
|||||||
|
|
||||||
private fun buildQuery(queryAction: () -> String) = queryAction().replace("%", "$")
|
private fun buildQuery(queryAction: () -> String) = queryAction().replace("%", "$")
|
||||||
|
|
||||||
|
private fun queryRequest(query: String, operationName: String, variables: JsonObject? = null): Request {
|
||||||
|
val payload = buildJsonObject {
|
||||||
|
put("operationName", operationName)
|
||||||
|
put("query", query)
|
||||||
|
variables?.let { put("variables", it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
val body = payload.toString().toRequestBody(JSON_MEDIA_TYPE)
|
||||||
|
|
||||||
|
val newHeaders = headersBuilder()
|
||||||
|
.add("Content-Length", body.contentLength().toString())
|
||||||
|
.add("Content-Type", body.contentType().toString())
|
||||||
|
.build()
|
||||||
|
|
||||||
|
return POST(GRAPHQL_URL, newHeaders, body)
|
||||||
|
}
|
||||||
|
|
||||||
private fun String.toSlug(): String {
|
private fun String.toSlug(): String {
|
||||||
return Normalizer
|
return Normalizer
|
||||||
.normalize(this, Normalizer.Form.NFD)
|
.normalize(this, Normalizer.Form.NFD)
|
||||||
@ -355,8 +324,8 @@ class HQNow : HttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val STATIC_URL = "http://static.hq-now.com/"
|
private const val STATIC_URL = "https://static.hq-now.com/"
|
||||||
private const val GRAPHQL_URL = "http://admin.hq-now.com/graphql"
|
private const val GRAPHQL_URL = "https://admin.hq-now.com/graphql"
|
||||||
|
|
||||||
private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaTypeOrNull()
|
private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaTypeOrNull()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user