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 <BrutuZ@users.noreply.github.com>
This commit is contained in:
Fermín Cirella 2024-05-16 13:54:09 -03:00 committed by Draff
parent 47af581f6d
commit 3cb723b12b
3 changed files with 19 additions and 13 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Anchira' extName = 'Anchira'
extClass = '.Anchira' extClass = '.Anchira'
extVersionCode = 12 extVersionCode = 13
isNsfw = true isNsfw = true
} }

View File

@ -81,7 +81,7 @@ class Anchira : HttpSource(), ConfigurableSource {
SManga.create().apply { SManga.create().apply {
url = "/g/${it.id}/${it.key}" url = "/g/${it.id}/${it.key}"
title = it.title 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 } val art = it.tags.filter { it.namespace == 1 }.joinToString(", ") { it.name }
.ifEmpty { null } .ifEmpty { null }
artist = art artist = art
@ -242,7 +242,7 @@ class Anchira : HttpSource(), ConfigurableSource {
url = "/g/${data.id}/${data.key}" url = "/g/${data.id}/${data.key}"
title = data.title title = data.title
thumbnail_url = 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 } val art = data.tags.filter { it.namespace == 1 }.joinToString(", ") { it.name }
.ifEmpty { null } .ifEmpty { null }
artist = art artist = art
@ -316,10 +316,10 @@ class Anchira : HttpSource(), ConfigurableSource {
val data = json.decodeFromString<Entry>(response.body.string()) val data = json.decodeFromString<Entry>(response.body.string())
val imageData = getImageData(data) val imageData = getImageData(data)
return imageData.names.mapIndexed { i, name -> return data.images.mapIndexed { i, image ->
Page( Page(
i, 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 } val keys = anchiraData.find { it.id == entry.id }
if (keys?.key != null && keys.hash != null) { 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 { try {

View File

@ -4,13 +4,13 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@Serializable @Serializable
data class Tag( class Tag(
var name: String, var name: String,
var namespace: Int? = null, var namespace: Int? = null,
) )
@Serializable @Serializable
data class LibraryResponse( class LibraryResponse(
val entries: List<Entry> = emptyList(), val entries: List<Entry> = emptyList(),
val total: Int, val total: Int,
val page: Int, val page: Int,
@ -18,7 +18,7 @@ data class LibraryResponse(
) )
@Serializable @Serializable
data class Entry( class Entry(
val id: Int, val id: Int,
val key: String, val key: String,
@SerialName("published_at") val publishedAt: Long = 0L, @SerialName("published_at") val publishedAt: Long = 0L,
@ -27,21 +27,27 @@ data class Entry(
val tags: List<Tag> = emptyList(), val tags: List<Tag> = emptyList(),
val url: String? = null, val url: String? = null,
val pages: Int = 1, val pages: Int = 1,
val cover: Image? = null,
@SerialName("data")
val images: List<Image> = emptyList(),
) )
@Serializable @Serializable
data class ImageData( class ImageData(
val id: Int, val id: Int,
val key: String, val key: String,
val hash: String, val hash: String,
val names: List<String>,
) )
@Serializable @Serializable
data class EntryKey( class EntryKey(
val id: Int, val id: Int,
val key: String? = null, val key: String? = null,
val hash: String? = null, val hash: String? = null,
val url: String? = null, val url: String? = null,
val names: List<String> = emptyList(), )
@Serializable
class Image(
@SerialName("n") val name: String,
) )