Kuaikanmanhua: View paid chapters (#8578)
This commit is contained in:
parent
c673c58b1a
commit
486db23175
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Kuaikanmanhua'
|
extName = 'Kuaikanmanhua'
|
||||||
pkgNameSuffix = 'zh.kuaikanmanhua'
|
pkgNameSuffix = 'zh.kuaikanmanhua'
|
||||||
extClass = '.Kuaikanmanhua'
|
extClass = '.Kuaikanmanhua'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,16 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class Kuaikanmanhua : HttpSource() {
|
class Kuaikanmanhua : HttpSource() {
|
||||||
|
|
||||||
|
@ -138,34 +142,35 @@ class Kuaikanmanhua : HttpSource() {
|
||||||
|
|
||||||
// Chapters & Pages
|
// Chapters & Pages
|
||||||
|
|
||||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
|
||||||
val newUrl = apiUrl + "/v1/topics/" + manga.url.trimEnd('/').substringAfterLast("/")
|
|
||||||
val response = client.newCall(GET(newUrl)).execute()
|
|
||||||
val chapters = chapterListParse(response)
|
|
||||||
return Observable.just(chapters)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
val data = JSONObject(response.body!!.string()).getJSONObject("data")
|
val document = response.asJsoup()
|
||||||
val chaptersJson = data.getJSONArray("comics")
|
|
||||||
val chapters = mutableListOf<SChapter>()
|
val chapters = mutableListOf<SChapter>()
|
||||||
|
val script = document.select("script:containsData(comics)").first().data()
|
||||||
|
val comics = JSONArray(script.substringAfter("comics:").substringBefore(",first_comic_id"))
|
||||||
|
val variable = script.substringAfter("(function(").substringBefore("){").split(",")
|
||||||
|
val value = script.substringAfterLast("}}(").substringBefore("));").split(",")
|
||||||
|
|
||||||
for (i in 0 until chaptersJson.length()) {
|
document.select("div.TopicItem").forEachIndexed { index, element ->
|
||||||
val obj = chaptersJson.getJSONObject(i)
|
|
||||||
chapters.add(
|
chapters.add(
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
url = "/v2/comic/" + obj.getString("id")
|
val idVar = comics.getJSONObject(index).getString("id")
|
||||||
name = obj.getString("title") +
|
val id = value[variable.indexOf(idVar)]
|
||||||
if (!obj.getBoolean("can_view")) {
|
url = "/web/comic/$id"
|
||||||
" \uD83D\uDD12"
|
name = element.select("div.title > a").text()
|
||||||
} else {
|
if (element.select("i.lockedIcon").isNotEmpty()) {
|
||||||
""
|
name += " \uD83D\uDD12"
|
||||||
}
|
}
|
||||||
date_upload = obj.getLong("created_at") * 1000
|
var dateStr = element.select("div.date > span").text()
|
||||||
|
dateStr = if (dateStr.length == 5) {
|
||||||
|
val year = Calendar.getInstance().get(Calendar.YEAR)
|
||||||
|
"$year-$dateStr"
|
||||||
|
} else {
|
||||||
|
"20$dateStr"
|
||||||
|
}
|
||||||
|
date_upload = SimpleDateFormat("yyyy-MM-dd").parse(dateStr).time
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return chapters
|
return chapters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,16 +183,20 @@ class Kuaikanmanhua : HttpSource() {
|
||||||
if (chapter.name.endsWith("🔒")) {
|
if (chapter.name.endsWith("🔒")) {
|
||||||
throw Exception("[此章节为付费内容]")
|
throw Exception("[此章节为付费内容]")
|
||||||
}
|
}
|
||||||
return GET(apiUrl + chapter.url)
|
return GET(baseUrl + chapter.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val pages = ArrayList<Page>()
|
val pages = ArrayList<Page>()
|
||||||
val data = JSONObject(response.body!!.string()).getJSONObject("data")
|
val document = response.asJsoup()
|
||||||
val pagesJson = data.getJSONArray("images")
|
val script = document.selectFirst("script:containsData(comicImages)").data()
|
||||||
|
val images = JSONArray(script.substringAfter("comicImages:").substringBefore("},nextComicInfo"))
|
||||||
for (i in 0 until pagesJson.length()) {
|
val variable = script.substringAfter("(function(").substringBefore("){").split(",")
|
||||||
pages.add(Page(i, pagesJson.getString(i), pagesJson.getString(i)))
|
val value = script.substringAfterLast("}}(").substringBefore("));").split(",")
|
||||||
|
for (i in 0 until images.length()) {
|
||||||
|
val urlVar = images.getJSONObject(i).getString("url")
|
||||||
|
val url = value[variable.indexOf(urlVar)].replace("\\u002F", "/").replace("\"", "")
|
||||||
|
pages.add(Page(i, "", url))
|
||||||
}
|
}
|
||||||
return pages
|
return pages
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue