Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/zh/jcomic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

keiyoushi {
name = "JComic"
versionCode = 2
versionCode = 3
contentWarning = ContentWarning.NSFW
libVersion = "1.6"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import keiyoushi.annotation.Source
import keiyoushi.network.get
import keiyoushi.source.KeiSource
import keiyoushi.utils.asJsoup
import keiyoushi.utils.long
import keiyoushi.utils.longOrNull
import keiyoushi.utils.tryParse
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.async
import kotlinx.coroutines.supervisorScope
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.Response
Expand All @@ -31,11 +32,15 @@ import java.util.Locale
@Source
abstract class JComic : KeiSource() {

override fun Headers.Builder.configureHeaders() = apply {
set("Cookie", "jcomic_access=verified_user")
}

override fun OkHttpClient.Builder.configureClient() = apply {
addInterceptor { chain ->
val origin = chain.request()
chain.proceed(origin).also {
if (it.code == 403 && origin.url.toString().contains("jcomic-content")) {
if (it.code == 403 && (origin.url.host.startsWith("images.") || origin.url.toString().contains("jcomic-content"))) {
it.close()
throw IOException("图片已失效,清除章节缓存后重试\n(链接有效期只有1分钟,建议以后下载完章节再看)")
}
Expand Down Expand Up @@ -129,7 +134,7 @@ abstract class JComic : KeiSource() {

val asyncChapters = if (fetchChapters) {
async {
val time = manga.memo["time"]!!.long
val time = manga.memo["time"]?.longOrNull ?: 0L
if (manga.url.contains("/page")) {
listOf(
SChapter.create().apply {
Expand Down Expand Up @@ -160,7 +165,13 @@ abstract class JComic : KeiSource() {
override suspend fun getPageList(chapter: SChapter): List<Page> {
val response = client.get(baseUrl + chapter.url)
return response.asJsoup().select(".comic-thumb").mapIndexed { i, img ->
Page(i, imageUrl = String(Base64.decode(img.attr("data-locked").removePrefix("JCOMIC_TRAP_").reversed(), Base64.NO_WRAP)))
val locked = img.attr("data-locked")
val url = if (locked.isNotEmpty()) {
String(Base64.decode(locked.removePrefix("JCOMIC_TRAP_").reversed(), Base64.NO_WRAP))
} else {
img.attr("data-src").ifEmpty { img.attr("src") }
}
Page(i, imageUrl = url)
}
}
}
Loading