ReaperScans: Fix page listing (#4779)

* HeanCMS: Implement alternate chapter page format.

* HeanCMS: Up version code

* Revert "HeanCMS: Up version code"

This reverts commit 16b35d5e0f.

* Revert "HeanCMS: Implement alternate chapter page format."

This reverts commit e81de53aec.

* ReaperScans: Fix chapter page list

* ReaperScans: Remove unused import

* ReaperScans: Up version number + whitespace

* ReaperScans: Actually put the Dto in the same package.

* ReaperScans: Formatting...
This commit is contained in:
Wackery 2024-08-26 22:41:12 -07:00 committed by GitHub
parent b827f37549
commit 8214d5694a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 59 additions and 1 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.ReaperScans'
themePkg = 'heancms'
baseUrl = 'https://reaperscans.com'
overrideVersionCode = 27
overrideVersionCode = 28
}
apply from: "$rootDir/common.gradle"

View File

@ -4,8 +4,10 @@ import eu.kanade.tachiyomi.multisrc.heancms.HeanCms
import eu.kanade.tachiyomi.multisrc.heancms.SortProperty
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.model.Page
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Request
import okhttp3.Response
import java.text.SimpleDateFormat
import java.util.Locale
@ -38,6 +40,24 @@ class ReaperScans : HeanCms("Reaper Scans", "https://reaperscans.com", "en") {
return GET(url.build(), headers)
}
override fun pageListParse(response: Response): List<Page> {
val result = response.parseAs<ReaperPagePayloadDto>()
if (result.isPaywalled() && result.chapter.chapterData == null) {
throw Exception(intl["paid_chapter_error"])
}
return if (useNewChapterEndpoint) {
result.chapter.chapterData?.images().orEmpty().mapIndexed { i, img ->
Page(i, imageUrl = img.toAbsoluteUrl())
}
} else {
result.data.orEmpty().mapIndexed { i, img ->
Page(i, imageUrl = img.toAbsoluteUrl())
}
}
}
override fun getSortProperties(): List<SortProperty> = listOf(
SortProperty(intl["sort_by_title"], "title"),
SortProperty(intl["sort_by_views"], "total_views"),

View File

@ -0,0 +1,38 @@
package eu.kanade.tachiyomi.extension.en.reaperscans
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
class ReaperPagePayloadDto(
val chapter: ReaperPageDto,
private val paywall: Boolean = false,
val data: List<String>? = emptyList(),
) {
fun isPaywalled() = paywall
}
@Serializable
class ReaperPageDto(
@SerialName("chapter_data") val chapterData: ReaperPageDataDto?,
)
@Serializable
class ReaperPageDataDto(
private val images: List<String>? = emptyList(),
private val files: List<ReaperPageFileDto>? = emptyList(),
) {
fun images(): List<String> {
return if (images.isNullOrEmpty()) {
files?.map {
it.url
}.orEmpty()
} else {
images
}
}
}
@Serializable
class ReaperPageFileDto(
val url: String,
)