Fix chapters not loading in AS (closes #11950). (#12116)

This commit is contained in:
Alessandro Jean 2022-06-07 20:49:41 -03:00 committed by GitHub
parent e2fbf8c3d0
commit 1c873f63ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 51 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Argos Scan' extName = 'Argos Scan'
pkgNameSuffix = 'pt.argosscan' pkgNameSuffix = 'pt.argosscan'
extClass = '.ArgosScan' extClass = '.ArgosScan'
extVersionCode = 21 extVersionCode = 22
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -50,7 +50,7 @@ class ArgosScan : HttpSource(), ConfigurableSource {
override val lang = "pt-BR" override val lang = "pt-BR"
override val supportsLatest = true override val supportsLatest = false
override val client: OkHttpClient = network.cloudflareClient.newBuilder() override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.addInterceptor(::loginIntercept) .addInterceptor(::loginIntercept)
@ -71,7 +71,11 @@ class ArgosScan : HttpSource(), ConfigurableSource {
private fun genericMangaFromObject(project: ArgosProjectDto): SManga = SManga.create().apply { private fun genericMangaFromObject(project: ArgosProjectDto): SManga = SManga.create().apply {
title = project.name!! title = project.name!!
url = "/obras/${project.id}" url = "/obras/${project.id}"
thumbnail_url = "$baseUrl/images/${project.id}/${project.cover!!}" thumbnail_url = if (project.cover!! == "default.jpg") {
"$baseUrl/img/default.jpg"
} else {
"$baseUrl/images/${project.id}/${project.cover}"
}
} }
override fun popularMangaRequest(page: Int): Request { override fun popularMangaRequest(page: Int): Request {
@ -104,20 +108,9 @@ class ArgosScan : HttpSource(), ConfigurableSource {
return MangasPage(mangaList, hasNextPage) return MangasPage(mangaList, hasNextPage)
} }
override fun latestUpdatesRequest(page: Int): Request { override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException()
val payload = buildLatestQueryPayload(page)
val body = payload.toString().toRequestBody(JSON_MEDIA_TYPE) override fun latestUpdatesParse(response: Response): MangasPage = throw UnsupportedOperationException()
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 = popularMangaParse(response)
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val payload = buildSearchQueryPayload(query, page) val payload = buildSearchQueryPayload(query, page)
@ -168,7 +161,11 @@ class ArgosScan : HttpSource(), ConfigurableSource {
val project = result.data["project"]!! val project = result.data["project"]!!
title = project.name!! title = project.name!!
thumbnail_url = "$baseUrl/images/${project.id}/${project.cover!!}" thumbnail_url = if (project.cover!! == "default.jpg") {
"$baseUrl/img/default.jpg"
} else {
"$baseUrl/images/${project.id}/${project.cover}"
}
description = project.description.orEmpty() description = project.description.orEmpty()
author = project.authors.orEmpty().joinToString() author = project.authors.orEmpty().joinToString()
status = SManga.ONGOING status = SManga.ONGOING
@ -196,6 +193,10 @@ class ArgosScan : HttpSource(), ConfigurableSource {
} }
override fun pageListRequest(chapter: SChapter): Request { override fun pageListRequest(chapter: SChapter): Request {
if (chapter.url.removePrefix("/leitor/").toIntOrNull() != null) {
throw Exception(REFRESH_WARNING)
}
val chapterId = chapter.url.substringAfter("leitor/") val chapterId = chapter.url.substringAfter("leitor/")
val payload = buildPagesQueryPayload(chapterId) val payload = buildPagesQueryPayload(chapterId)
@ -369,6 +370,7 @@ class ArgosScan : HttpSource(), ConfigurableSource {
private const val CLOUDFLARE_ERROR = "Falha ao contornar o Cloudflare." private const val CLOUDFLARE_ERROR = "Falha ao contornar o Cloudflare."
private const val REQUEST_ERROR = "Erro na requisição. Tente novamente mais tarde." private const val REQUEST_ERROR = "Erro na requisição. Tente novamente mais tarde."
private const val REFRESH_WARNING = "Atualize a lista de capítulos para atualizar os IDs."
private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaTypeOrNull() private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaTypeOrNull()

View File

@ -34,7 +34,7 @@ data class ArgosProjectDto(
@Serializable @Serializable
data class ArgosChapterDto( data class ArgosChapterDto(
val createAt: String? = "", val createAt: String? = "",
val id: Int = 0, val id: String = "",
val images: List<String>? = emptyList(), val images: List<String>? = emptyList(),
val number: Int? = 0, val number: Int? = 0,
val project: ArgosProjectDto? = null, val project: ArgosProjectDto? = null,

View File

@ -93,39 +93,6 @@ fun buildPopularQueryPayload(page: Int) = buildJsonObject {
} }
} }
fun buildLatestQueryPayload(page: Int) = buildJsonObject {
put("operationName", "getProjects")
put("query", POPULAR_QUERY)
putJsonObject("variables") {
putJsonObject("filters") {
putJsonObject("childExpressions") {
putJsonObject("filters") {
put("field", "Chapter.id")
put("op", "GE")
put("relationField", "Project.chapters")
putJsonArray("values") {
add("1")
}
}
put("operator", "AND")
}
put("operator", "AND")
}
putJsonObject("orders") {
putJsonArray("orders") {
addJsonObject {
put("field", "Chapter.createAt")
put("or", "DESC")
}
}
}
putJsonObject("pagination") {
put("limit", 12)
put("page", page)
}
}
}
fun buildSearchQueryPayload(query: String, page: Int) = buildJsonObject { fun buildSearchQueryPayload(query: String, page: Int) = buildJsonObject {
put("operationName", "getProjects") put("operationName", "getProjects")
put("query", POPULAR_QUERY) put("query", POPULAR_QUERY)