mirror of
https://github.com/keiyoushi/extensions-source.git
synced 2024-11-23 02:42:35 +01:00
ReaperScans: Fix page listing (#4779)
* HeanCMS: Implement alternate chapter page format. * HeanCMS: Up version code * Revert "HeanCMS: Up version code" This reverts commit16b35d5e0f
. * Revert "HeanCMS: Implement alternate chapter page format." This reverts commite81de53aec
. * 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:
parent
b827f37549
commit
8214d5694a
@ -3,7 +3,7 @@ ext {
|
||||
extClass = '.ReaperScans'
|
||||
themePkg = 'heancms'
|
||||
baseUrl = 'https://reaperscans.com'
|
||||
overrideVersionCode = 27
|
||||
overrideVersionCode = 28
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
@ -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"),
|
||||
|
@ -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,
|
||||
)
|
Loading…
Reference in New Issue
Block a user