Fixed Kuaikanmanhua and changed name (#9830)
* Changed name to chinese, fixed chapter list * Added some regex to fix some json * Fixed page parse, gave explicit id
This commit is contained in:
parent
57c1078f80
commit
9dd19d66e6
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Kuaikanmanhua'
|
extName = 'Kuaikanmanhua'
|
||||||
pkgNameSuffix = 'zh.kuaikanmanhua'
|
pkgNameSuffix = 'zh.kuaikanmanhua'
|
||||||
extClass = '.Kuaikanmanhua'
|
extClass = '.Kuaikanmanhua'
|
||||||
extVersionCode = 6
|
extVersionCode = 7
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -12,23 +12,25 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonArray
|
import kotlinx.serialization.json.JsonArray
|
||||||
|
import kotlinx.serialization.json.boolean
|
||||||
import kotlinx.serialization.json.int
|
import kotlinx.serialization.json.int
|
||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
import kotlinx.serialization.json.long
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
|
|
||||||
class Kuaikanmanhua : HttpSource() {
|
class Kuaikanmanhua : HttpSource() {
|
||||||
|
|
||||||
override val name = "Kuaikanmanhua"
|
override val name = "快看漫画"
|
||||||
|
|
||||||
|
override val id: Long = 8099870292642776005
|
||||||
|
|
||||||
override val baseUrl = "https://www.kuaikanmanhua.com"
|
override val baseUrl = "https://www.kuaikanmanhua.com"
|
||||||
|
|
||||||
|
@ -150,40 +152,36 @@ class Kuaikanmanhua : HttpSource() {
|
||||||
|
|
||||||
// Chapters & Pages
|
// Chapters & Pages
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
||||||
val document = response.asJsoup()
|
val newUrl = apiUrl + "/v1/topics/" + manga.url.trimEnd('/').substringAfterLast("/")
|
||||||
val script = document.select("script:containsData(comics)").first().data()
|
val response = client.newCall(GET(newUrl)).execute()
|
||||||
val comics = script.substringAfter("comics:")
|
val chapters = chapterListParse(response)
|
||||||
.substringBefore(",first_comic_id")
|
return Observable.just(chapters)
|
||||||
.let { json.parseToJsonElement(it).jsonArray }
|
}
|
||||||
val variable = script.substringAfter("(function(")
|
|
||||||
.substringBefore("){")
|
|
||||||
.split(",")
|
|
||||||
val value = script.substringAfterLast("}}(")
|
|
||||||
.substringBefore("));")
|
|
||||||
.split(",")
|
|
||||||
|
|
||||||
return document.select("div.TopicItem")
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
.mapIndexed { index, element ->
|
val data = json.parseToJsonElement(response.body!!.string())
|
||||||
|
.jsonObject["data"]!!
|
||||||
|
.jsonObject
|
||||||
|
val chaptersJson = data["comics"]!!.jsonArray
|
||||||
|
val chapters = mutableListOf<SChapter>()
|
||||||
|
|
||||||
|
for (i in 0 until chaptersJson.size) {
|
||||||
|
val obj = chaptersJson[i].jsonObject
|
||||||
|
chapters.add(
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
val idVar = comics[index].jsonObject["id"]!!.jsonPrimitive.content
|
url = "/web/comic/" + obj["id"]!!.jsonPrimitive.content
|
||||||
val id = value[variable.indexOf(idVar)]
|
name = obj["title"]!!.jsonPrimitive.content +
|
||||||
url = "/web/comic/$id"
|
if (!obj["can_view"]!!.jsonPrimitive.boolean) {
|
||||||
name = element.select("div.title > a").text()
|
" \uD83D\uDD12"
|
||||||
if (element.select("i.lockedIcon").isNotEmpty()) {
|
} else {
|
||||||
name += " \uD83D\uDD12"
|
""
|
||||||
}
|
}
|
||||||
var dateStr = element.select("div.date > span").text()
|
date_upload = obj["created_at"]!!.jsonPrimitive.long * 1000
|
||||||
dateStr = if (dateStr.length == 5) {
|
|
||||||
val year = Calendar.getInstance().get(Calendar.YEAR)
|
|
||||||
"$year-$dateStr"
|
|
||||||
} else {
|
|
||||||
"20$dateStr"
|
|
||||||
}
|
|
||||||
date_upload = runCatching { DATE_FORMAT.parse(dateStr)?.time }
|
|
||||||
.getOrNull() ?: 0L
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
return chapters
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
||||||
|
@ -192,17 +190,26 @@ class Kuaikanmanhua : HttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListRequest(chapter: SChapter): Request {
|
override fun pageListRequest(chapter: SChapter): Request {
|
||||||
if (chapter.name.endsWith("🔒")) {
|
// if (chapter.name.endsWith("🔒")) {
|
||||||
throw Exception("[此章节为付费内容]")
|
// throw Exception("[此章节为付费内容]")
|
||||||
}
|
// }
|
||||||
return GET(baseUrl + chapter.url)
|
return GET(baseUrl + chapter.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val fixJson: (MatchResult) -> CharSequence = {
|
||||||
|
match: MatchResult ->
|
||||||
|
val str = match.value
|
||||||
|
val out = str[0] + "\"" + str.subSequence(1, str.length - 1) + "\"" + str[str.length - 1]
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
val script = document.selectFirst("script:containsData(comicImages)").data()
|
val script = document.selectFirst("script:containsData(comicImages)").data()
|
||||||
val images = script.substringAfter("comicImages:")
|
val images = script.substringAfter("comicImages:")
|
||||||
.substringBefore("},nextComicInfo")
|
.substringBefore("},nextComicInfo")
|
||||||
|
.replace("""(:([^\[\{\"]+?)[\},])""".toRegex(), fixJson)
|
||||||
|
.replace("""([,{]([^\[\{\"]+?)[\}:])""".toRegex(), fixJson)
|
||||||
.let { json.parseToJsonElement(it).jsonArray }
|
.let { json.parseToJsonElement(it).jsonArray }
|
||||||
val variable = script.substringAfter("(function(")
|
val variable = script.substringAfter("(function(")
|
||||||
.substringBefore("){")
|
.substringBefore("){")
|
||||||
|
|
Loading…
Reference in New Issue