From 3cb723b12baa8a980d7c9c24483b2bed80a69e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Cirella?= Date: Thu, 16 May 2024 13:54:09 -0300 Subject: [PATCH] Anchira: Fix API changes (#3038) * Anchira: Fix API changes * Fix thumbnails on library response * Anchira: Remove data class * Update src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/AnchiraDto.kt --------- Co-authored-by: BrutuZ --- src/en/anchira/build.gradle | 2 +- .../tachiyomi/extension/en/anchira/Anchira.kt | 10 +++++----- .../extension/en/anchira/AnchiraDto.kt | 20 ++++++++++++------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/en/anchira/build.gradle b/src/en/anchira/build.gradle index c0ef7fe1b..73350b955 100644 --- a/src/en/anchira/build.gradle +++ b/src/en/anchira/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Anchira' extClass = '.Anchira' - extVersionCode = 12 + extVersionCode = 13 isNsfw = true } diff --git a/src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/Anchira.kt b/src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/Anchira.kt index 7b685aa83..419714ee8 100644 --- a/src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/Anchira.kt +++ b/src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/Anchira.kt @@ -81,7 +81,7 @@ class Anchira : HttpSource(), ConfigurableSource { SManga.create().apply { url = "/g/${it.id}/${it.key}" title = it.title - thumbnail_url = "$cdnUrl/${it.id}/${it.key}/m/${it.thumbnailIndex + 1}" + thumbnail_url = "$cdnUrl/${it.id}/${it.key}/m/${it.cover?.name}" val art = it.tags.filter { it.namespace == 1 }.joinToString(", ") { it.name } .ifEmpty { null } artist = art @@ -242,7 +242,7 @@ class Anchira : HttpSource(), ConfigurableSource { url = "/g/${data.id}/${data.key}" title = data.title thumbnail_url = - "$cdnUrl/${data.id}/${data.key}/b/${data.thumbnailIndex + 1}" + "$cdnUrl/${data.id}/${data.key}/l/${data.images[data.thumbnailIndex].name}" val art = data.tags.filter { it.namespace == 1 }.joinToString(", ") { it.name } .ifEmpty { null } artist = art @@ -316,10 +316,10 @@ class Anchira : HttpSource(), ConfigurableSource { val data = json.decodeFromString(response.body.string()) val imageData = getImageData(data) - return imageData.names.mapIndexed { i, name -> + return data.images.mapIndexed { i, image -> Page( i, - imageUrl = "$cdnUrl/${imageData.id}/${imageData.key}/${imageData.hash}/b/$name", + imageUrl = "$cdnUrl/${imageData.id}/${imageData.key}/${imageData.hash}/b/${image.name}", ) } } @@ -328,7 +328,7 @@ class Anchira : HttpSource(), ConfigurableSource { val keys = anchiraData.find { it.id == entry.id } if (keys?.key != null && keys.hash != null) { - return ImageData(keys.id, keys.key, keys.hash, keys.names) + return ImageData(keys.id, keys.key, keys.hash) } try { diff --git a/src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/AnchiraDto.kt b/src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/AnchiraDto.kt index e4c821281..9e12771a1 100644 --- a/src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/AnchiraDto.kt +++ b/src/en/anchira/src/eu/kanade/tachiyomi/extension/en/anchira/AnchiraDto.kt @@ -4,13 +4,13 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class Tag( +class Tag( var name: String, var namespace: Int? = null, ) @Serializable -data class LibraryResponse( +class LibraryResponse( val entries: List = emptyList(), val total: Int, val page: Int, @@ -18,7 +18,7 @@ data class LibraryResponse( ) @Serializable -data class Entry( +class Entry( val id: Int, val key: String, @SerialName("published_at") val publishedAt: Long = 0L, @@ -27,21 +27,27 @@ data class Entry( val tags: List = emptyList(), val url: String? = null, val pages: Int = 1, + val cover: Image? = null, + @SerialName("data") + val images: List = emptyList(), ) @Serializable -data class ImageData( +class ImageData( val id: Int, val key: String, val hash: String, - val names: List, ) @Serializable -data class EntryKey( +class EntryKey( val id: Int, val key: String? = null, val hash: String? = null, val url: String? = null, - val names: List = emptyList(), +) + +@Serializable +class Image( + @SerialName("n") val name: String, )