From 5687f616b2bdf4e53678d1222380130b56069c26 Mon Sep 17 00:00:00 2001 From: Chopper <156493704+choppeh@users.noreply.github.com> Date: Tue, 14 Jan 2025 03:01:06 -0300 Subject: [PATCH] SussyToons: Fix page loading (#7176) Fix page loading --- src/pt/sussyscan/build.gradle | 2 +- .../extension/pt/sussyscan/SussyToons.kt | 22 +++++++++++++------ .../extension/pt/sussyscan/SussyToonsDto.kt | 20 +++++++++++++++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/pt/sussyscan/build.gradle b/src/pt/sussyscan/build.gradle index 6c7440046..78fa2c373 100644 --- a/src/pt/sussyscan/build.gradle +++ b/src/pt/sussyscan/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Sussy Toons' extClass = '.SussyToons' - extVersionCode = 46 + extVersionCode = 47 isNsfw = true } diff --git a/src/pt/sussyscan/src/eu/kanade/tachiyomi/extension/pt/sussyscan/SussyToons.kt b/src/pt/sussyscan/src/eu/kanade/tachiyomi/extension/pt/sussyscan/SussyToons.kt index 66c6b354b..83fe4ef17 100644 --- a/src/pt/sussyscan/src/eu/kanade/tachiyomi/extension/pt/sussyscan/SussyToons.kt +++ b/src/pt/sussyscan/src/eu/kanade/tachiyomi/extension/pt/sussyscan/SussyToons.kt @@ -232,14 +232,22 @@ class SussyToons : HttpSource(), ConfigurableSource { .build() val res = client.newCall(GET(url, headers)).execute() - val dto = res.parseAs>().results + return dto.pages.mapIndexed { index, image -> - val imageUrl = CDN_URL.toHttpUrl().newBuilder() - .addPathSegments("wp-content/uploads/WP-manga/data") - .addPathSegments(image.src.toPathSegment()) - .build().toString() - Page(index, imageUrl = imageUrl) + val imageUrl = when { + image.isWordPressContent() -> { + CDN_URL.toHttpUrl().newBuilder() + .addPathSegments("wp-content/uploads/WP-manga/data") + .addPathSegments(image.src.toPathSegment()) + .build() + } + else -> { + "$CDN_URL/scans/${dto.manga.scanId}/obras/${dto.manga.id}/capitulos/${dto.chapterNumber}/${image.src}" + .toHttpUrl() + } + } + Page(index, imageUrl = imageUrl.toString()) } } @@ -550,7 +558,7 @@ class SussyToons : HttpSource(), ConfigurableSource { return sManga } - private inline fun Response.parseAs(): T { + private inline fun Response.parseAs(): T = use { return json.decodeFromStream(body.byteStream()) } diff --git a/src/pt/sussyscan/src/eu/kanade/tachiyomi/extension/pt/sussyscan/SussyToonsDto.kt b/src/pt/sussyscan/src/eu/kanade/tachiyomi/extension/pt/sussyscan/SussyToonsDto.kt index a1bc46d1e..4ef358691 100644 --- a/src/pt/sussyscan/src/eu/kanade/tachiyomi/extension/pt/sussyscan/SussyToonsDto.kt +++ b/src/pt/sussyscan/src/eu/kanade/tachiyomi/extension/pt/sussyscan/SussyToonsDto.kt @@ -72,9 +72,25 @@ class WrapperChapterDto( class ChapterPageDto( @SerialName("cap_paginas") val pages: List, -) + @SerialName("obra") + val manga: MangaReferenceDto, + @SerialName("cap_numero") + val chapterNumber: Int, +) { + @Serializable + class MangaReferenceDto( + @SerialName("obr_id") + val id: Int, + @SerialName("scan_id") + val scanId: Int, + ) +} @Serializable class PageDto( val src: String, -) + @SerialName("numero") + val number: Int? = null, +) { + fun isWordPressContent(): Boolean = number == null +}