diff --git a/src/en/reaperscans/build.gradle b/src/en/reaperscans/build.gradle index aae4a1a6a..5b77d329a 100644 --- a/src/en/reaperscans/build.gradle +++ b/src/en/reaperscans/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.ReaperScans' themePkg = 'heancms' baseUrl = 'https://reaperscans.com' - overrideVersionCode = 27 + overrideVersionCode = 28 } apply from: "$rootDir/common.gradle" diff --git a/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScans.kt b/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScans.kt index f0ca1a351..f00c6fa71 100644 --- a/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScans.kt +++ b/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScans.kt @@ -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 { + val result = response.parseAs() + + 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 = listOf( SortProperty(intl["sort_by_title"], "title"), SortProperty(intl["sort_by_views"], "total_views"), diff --git a/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScansDto.kt b/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScansDto.kt new file mode 100644 index 000000000..eb61ac2da --- /dev/null +++ b/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScansDto.kt @@ -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? = emptyList(), +) { + fun isPaywalled() = paywall +} + +@Serializable +class ReaperPageDto( + @SerialName("chapter_data") val chapterData: ReaperPageDataDto?, +) + +@Serializable +class ReaperPageDataDto( + private val images: List? = emptyList(), + private val files: List? = emptyList(), +) { + fun images(): List { + return if (images.isNullOrEmpty()) { + files?.map { + it.url + }.orEmpty() + } else { + images + } + } +} + +@Serializable +class ReaperPageFileDto( + val url: String, +)