SussyToons: Fix page loading (#7176)

Fix page loading
This commit is contained in:
Chopper 2025-01-14 03:01:06 -03:00 committed by Draff
parent 4ceef9ca9b
commit 5687f616b2
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
3 changed files with 34 additions and 10 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Sussy Toons' extName = 'Sussy Toons'
extClass = '.SussyToons' extClass = '.SussyToons'
extVersionCode = 46 extVersionCode = 47
isNsfw = true isNsfw = true
} }

View File

@ -232,14 +232,22 @@ class SussyToons : HttpSource(), ConfigurableSource {
.build() .build()
val res = client.newCall(GET(url, headers)).execute() val res = client.newCall(GET(url, headers)).execute()
val dto = res.parseAs<WrapperDto<ChapterPageDto>>().results val dto = res.parseAs<WrapperDto<ChapterPageDto>>().results
return dto.pages.mapIndexed { index, image -> return dto.pages.mapIndexed { index, image ->
val imageUrl = CDN_URL.toHttpUrl().newBuilder() val imageUrl = when {
image.isWordPressContent() -> {
CDN_URL.toHttpUrl().newBuilder()
.addPathSegments("wp-content/uploads/WP-manga/data") .addPathSegments("wp-content/uploads/WP-manga/data")
.addPathSegments(image.src.toPathSegment()) .addPathSegments(image.src.toPathSegment())
.build().toString() .build()
Page(index, imageUrl = imageUrl) }
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 return sManga
} }
private inline fun <reified T> Response.parseAs(): T { private inline fun <reified T> Response.parseAs(): T = use {
return json.decodeFromStream(body.byteStream()) return json.decodeFromStream(body.byteStream())
} }

View File

@ -72,9 +72,25 @@ class WrapperChapterDto(
class ChapterPageDto( class ChapterPageDto(
@SerialName("cap_paginas") @SerialName("cap_paginas")
val pages: List<PageDto>, val pages: List<PageDto>,
) @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 @Serializable
class PageDto( class PageDto(
val src: String, val src: String,
) @SerialName("numero")
val number: Int? = null,
) {
fun isWordPressContent(): Boolean = number == null
}