ReaperScans: Fix page listing (#4779)

* HeanCMS: Implement alternate chapter page format.

* HeanCMS: Up version code

* Revert "HeanCMS: Up version code"

This reverts commit 16b35d5e0fc9e287addfc19731ebd19b2e93b266.

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

This reverts commit e81de53aec1aade5df17a6303239c70c7c6de808.

* 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 Draff
parent c162877800
commit b00c569c12
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
3 changed files with 59 additions and 1 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.ReaperScans' extClass = '.ReaperScans'
themePkg = 'heancms' themePkg = 'heancms'
baseUrl = 'https://reaperscans.com' baseUrl = 'https://reaperscans.com'
overrideVersionCode = 27 overrideVersionCode = 28
} }
apply from: "$rootDir/common.gradle" 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.multisrc.heancms.SortProperty
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.model.Page
import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Request import okhttp3.Request
import okhttp3.Response
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
@ -38,6 +40,24 @@ class ReaperScans : HeanCms("Reaper Scans", "https://reaperscans.com", "en") {
return GET(url.build(), headers) 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( override fun getSortProperties(): List<SortProperty> = listOf(
SortProperty(intl["sort_by_title"], "title"), SortProperty(intl["sort_by_title"], "title"),
SortProperty(intl["sort_by_views"], "total_views"), 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,
)