From 1c873f63abaaa0f9dc69086d39e6d79e1e71723b Mon Sep 17 00:00:00 2001 From: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> Date: Tue, 7 Jun 2022 20:49:41 -0300 Subject: [PATCH] Fix chapters not loading in AS (closes #11950). (#12116) --- src/pt/argosscan/build.gradle | 2 +- .../extension/pt/argosscan/ArgosScan.kt | 34 ++++++++++--------- .../extension/pt/argosscan/ArgosScanDto.kt | 2 +- .../pt/argosscan/ArgosScanQueries.kt | 33 ------------------ 4 files changed, 20 insertions(+), 51 deletions(-) diff --git a/src/pt/argosscan/build.gradle b/src/pt/argosscan/build.gradle index b64851d47..3aa8806c7 100644 --- a/src/pt/argosscan/build.gradle +++ b/src/pt/argosscan/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Argos Scan' pkgNameSuffix = 'pt.argosscan' extClass = '.ArgosScan' - extVersionCode = 21 + extVersionCode = 22 } apply from: "$rootDir/common.gradle" diff --git a/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScan.kt b/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScan.kt index 12b2a4a9d..af1d6606a 100644 --- a/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScan.kt +++ b/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScan.kt @@ -50,7 +50,7 @@ class ArgosScan : HttpSource(), ConfigurableSource { override val lang = "pt-BR" - override val supportsLatest = true + override val supportsLatest = false override val client: OkHttpClient = network.cloudflareClient.newBuilder() .addInterceptor(::loginIntercept) @@ -71,7 +71,11 @@ class ArgosScan : HttpSource(), ConfigurableSource { private fun genericMangaFromObject(project: ArgosProjectDto): SManga = SManga.create().apply { title = project.name!! 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 { @@ -104,20 +108,9 @@ class ArgosScan : HttpSource(), ConfigurableSource { return MangasPage(mangaList, hasNextPage) } - override fun latestUpdatesRequest(page: Int): Request { - val payload = buildLatestQueryPayload(page) + override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException() - 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 = popularMangaParse(response) + override fun latestUpdatesParse(response: Response): MangasPage = throw UnsupportedOperationException() override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { val payload = buildSearchQueryPayload(query, page) @@ -168,7 +161,11 @@ class ArgosScan : HttpSource(), ConfigurableSource { val project = result.data["project"]!! 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() author = project.authors.orEmpty().joinToString() status = SManga.ONGOING @@ -196,6 +193,10 @@ class ArgosScan : HttpSource(), ConfigurableSource { } override fun pageListRequest(chapter: SChapter): Request { + if (chapter.url.removePrefix("/leitor/").toIntOrNull() != null) { + throw Exception(REFRESH_WARNING) + } + val chapterId = chapter.url.substringAfter("leitor/") 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 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() diff --git a/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScanDto.kt b/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScanDto.kt index 3475c62f4..a9fc1ad38 100644 --- a/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScanDto.kt +++ b/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScanDto.kt @@ -34,7 +34,7 @@ data class ArgosProjectDto( @Serializable data class ArgosChapterDto( val createAt: String? = "", - val id: Int = 0, + val id: String = "", val images: List? = emptyList(), val number: Int? = 0, val project: ArgosProjectDto? = null, diff --git a/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScanQueries.kt b/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScanQueries.kt index bd28f62c8..ab10dabfa 100644 --- a/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScanQueries.kt +++ b/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScanQueries.kt @@ -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 { put("operationName", "getProjects") put("query", POPULAR_QUERY)