Comic Newtype: fix parsing of images with links (#13004)

This commit is contained in:
stevenyomi 2022-08-16 03:28:02 +08:00 committed by GitHub
parent c9e86fbbf7
commit 4b0c3a8a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Comic Newtype'
pkgNameSuffix = 'ja.comicnewtype'
extClass = '.ComicNewtype'
extVersionCode = 1
extVersionCode = 2
}
apply from: "$rootDir/common.gradle"

View File

@ -8,8 +8,9 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.asJsoup
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import okhttp3.HttpUrl.Companion.toHttpUrl
@ -115,7 +116,11 @@ class ComicNewtype : HttpSource() {
override fun pageListRequest(chapter: SChapter) = GET(baseUrl + chapter.url + "json/", headers)
override fun pageListParse(response: Response): List<Page> =
Json.decodeFromString<List<String>>(response.body!!.string()).mapIndexed { index, path ->
Json.parseToJsonElement(response.body!!.string()).jsonArray.mapIndexed { index, jsonElement ->
val path = when (jsonElement) {
is JsonArray -> jsonElement[0]
else -> jsonElement
}.jsonPrimitive.content
val newPath = path.removeSuffix("/h1200q75nc/")
Page(index, imageUrl = baseUrl + newPath)
}