Comicabc: Fixes (#5089)

Update baseUrl
Fix popularMangaSelector
Fix popularMangaFromElement
Fix latestUpdatesSelector
Fix mangaDetailsParse
Fix chapterListSelector
Fix pageListParse
This commit is contained in:
anenasa 2024-09-17 14:06:52 +08:00 committed by GitHub
parent 120f3b4a03
commit 83a2c48ef5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 25 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Comicabc'
extClass = '.Comicabc'
extVersionCode = 1
extVersionCode = 2
}
apply from: "$rootDir/common.gradle"

View File

@ -17,16 +17,16 @@ class Comicabc : ParsedHttpSource() {
override val name: String = "無限動漫"
override val lang: String = "zh"
override val supportsLatest: Boolean = true
override val baseUrl: String = "https://www.comicabc.com"
override val baseUrl: String = "https://www.8comic.com"
// Popular
override fun popularMangaRequest(page: Int) = GET("$baseUrl/comic/h-$page.html", headers)
override fun popularMangaNextPageSelector(): String = "div.pager a span.mdi-skip-next"
override fun popularMangaSelector(): String = "div.default_row_width > div.col-2"
override fun popularMangaSelector(): String = ".container .row a.comicpic_col6"
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
title = element.selectFirst("li.cat2_list_name")!!.text()
setUrlWithoutDomain(element.selectFirst("a")!!.attr("abs:href"))
title = element.selectFirst("li.nowraphide")!!.text()
setUrlWithoutDomain(element.attr("abs:href"))
thumbnail_url = element.selectFirst("img")!!.attr("abs:src")
}
@ -34,7 +34,7 @@ class Comicabc : ParsedHttpSource() {
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/comic/u-$page.html", headers)
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
override fun latestUpdatesSelector() = popularMangaSelector()
override fun latestUpdatesSelector() = ".container .row .cat2_list a"
override fun latestUpdatesFromElement(element: Element) = popularMangaFromElement(element)
// Search
@ -50,21 +50,21 @@ class Comicabc : ParsedHttpSource() {
// Details
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
title = document.selectFirst("div.item-top-content h3.item_name")!!.text()
thumbnail_url = document.selectFirst("div.item-topbar img.item_cover")!!.attr("abs:src")
author = document.selectFirst("div.item-top-content > li:nth-of-type(3)")!!.ownText()
title = document.selectFirst(".item_content_box .h2")!!.text()
thumbnail_url = document.selectFirst(".item-cover img")!!.attr("abs:src")
author = document.selectFirst(".item_content_box .item-info-author")?.text()?.substringAfter("作者: ")
artist = author
description = document.selectFirst("div.item-top-content > li.item_info_detail")!!.text()
status = when {
document.selectFirst("div.item_comic_eps_div")!!.text().contains("連載中") -> SManga.ONGOING
document.selectFirst("div.item_comic_eps_div")!!.text().contains("已完結") -> SManga.COMPLETED
description = document.selectFirst(".item_content_box .item_info_detail")?.text()
status = when (document.selectFirst(".item_content_box .item-info-status")?.text()) {
"連載中" -> SManga.ONGOING
"已完結" -> SManga.COMPLETED
else -> SManga.UNKNOWN
}
}
// Chapters
override fun chapterListSelector(): String = "div#div_li1 td > a"
override fun chapterListSelector(): String = "#chapters a"
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
val onclick = element.attr("onclick")
val comicId = onclick.substringAfter("cview('").substringBefore("-")
@ -78,20 +78,20 @@ class Comicabc : ParsedHttpSource() {
// Pages
override fun pageListParse(response: Response): List<Page> = mutableListOf<Page>().apply {
override fun pageListParse(response: Response): List<Page> {
val document = response.asJsoup()
val url = response.request.url.toString()
val script = document.selectFirst("script:containsData(function request)")!!.data()
.replace("function ge(e){return document.getElementById(e);}", "")
.replace("ge\\(.*\\).src".toRegex(), "imageUrl")
.replace("spp()", "")
.replace("document.location", "\"$url\"")
.replace("\$(\"#comics-pics\").html(xx);", "")
.substringBefore("\$(\"#pt,#ptb\")")
val quickJs = QuickJs.create()
val totalPage = quickJs.evaluate(nview + script.replace("document.location", "\"$url\"") + "ps") as Int
for (i in 1..totalPage) {
val imageUrl = quickJs.evaluate(nview + script.replace("document.location", "\"$url-$i\"") + "imageUrl") as String
add(Page(i - 1, "", "https:$imageUrl"))
}
val variableName = script.substringAfter("img s=\"").substringBefore("'")
val images = quickJs.evaluate(nview + script + lazyloadx.format(variableName)) as Array<*>
quickJs.close()
return images.mapIndexed { index, it ->
Page(index, "", it.toString())
}
}
override fun pageListParse(document: Document): List<Page> = throw UnsupportedOperationException()
@ -99,8 +99,20 @@ class Comicabc : ParsedHttpSource() {
companion object {
// Functions required by script in pageListParse()
// Taken from https://www.comicabc.com/js/nview.js?20180806
// Taken from https://www.8comic.com/js/j.js?9989588541
const val nview = """function lc(l){if(l.length!=2 ) return l;var az="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";var a=l.substring(0,1);var b=l.substring(1,2);if(a=="Z") return 8000+az.indexOf(b);else return az.indexOf(a)*52+az.indexOf(b);}
function nn(n){return n<10?'00'+n:n<100?'0'+n:n;}function mm(p){return (parseInt((p-1)/10)%10)+(((p-1)%10)*3)};"""
function nn(n){return n<10?'00'+n:n<100?'0'+n:n;}function mm(p){return (parseInt((p-1)/10)%10)+(((p-1)%10)*3)};
function su(a,b,c){var e=(a+'').substring(b,b+c);return (e);}var y=46;"""
// Modified from https://www.8comic.com/js/lazyloadx.js?9989588541
const val lazyloadx = """src="%s"
var b=eval(src.substring(0,5));
var c=eval(src.substring(5,10));
var d=eval(src.substring(10,15));
var arr=[];
for(var i=1;i<=ps;i++){
arr.push('https://img'+su(b,0,1)+'.8comic.com/'+su(b,1,1)+'/' + ti + '/'+c+'/' + nn(i) + '_' + su(d,mm(i),3) + '.jpg');
}
arr"""
}
}