Comicastle: Fix parsing and search (#10326)

* Comicastle: Fixed parsing and search

* Comicastle: Updated extVersionCode
This commit is contained in:
Troy121 2022-01-04 11:43:37 +01:00 committed by GitHub
parent d3fe7980e4
commit df8b7cd81b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Comicastle' extName = 'Comicastle'
pkgNameSuffix = 'en.comicastle' pkgNameSuffix = 'en.comicastle'
extClass = '.Comicastle' extClass = '.Comicastle'
extVersionCode = 2 extVersionCode = 3
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -35,7 +35,7 @@ class Comicastle : ParsedHttpSource() {
override val client: OkHttpClient = network.cloudflareClient override val client: OkHttpClient = network.cloudflareClient
private fun pageSegments(page: Int): String = if (page > 1) "/index/${(page - 1) * 30}" else "" private fun pageSegments(page: Int): String = if (page > 1) "/index/${(page - 1) * 42}" else ""
// Popular // Popular
@ -43,13 +43,13 @@ class Comicastle : ParsedHttpSource() {
return GET("$baseUrl/library/popular/desc" + pageSegments(page), headers) return GET("$baseUrl/library/popular/desc" + pageSegments(page), headers)
} }
override fun popularMangaSelector() = "div.col-lg-2" override fun popularMangaSelector() = "div.shadow-sm"
override fun popularMangaFromElement(element: Element): SManga { override fun popularMangaFromElement(element: Element): SManga {
return SManga.create().apply { return SManga.create().apply {
title = element.select("p").text() title = element.select("p").text()
setUrlWithoutDomain(element.select("a").first().attr("href")) setUrlWithoutDomain(element.select("a").first().attr("href"))
thumbnail_url = element.select("img").attr("abs:src") thumbnail_url = element.select("img").attr("data-src")
} }
} }
@ -81,7 +81,10 @@ class Comicastle : ParsedHttpSource() {
rBody = filter.toRequestBody() rBody = filter.toRequestBody()
} }
if (rBody == null) rBody = createRequestBody(query) if (rBody == null) {
url.addPathSegment("result")
rBody = createRequestBody(query)
}
return POST(url.toString(), headers, rBody!!) return POST(url.toString(), headers, rBody!!)
} }
@ -96,15 +99,15 @@ class Comicastle : ParsedHttpSource() {
override fun mangaDetailsParse(document: Document): SManga { override fun mangaDetailsParse(document: Document): SManga {
return SManga.create().apply { return SManga.create().apply {
with(document.select("div.card-body > div.mb-5")) { with(document.select("div.card-body > div.mb-2")) {
thumbnail_url = select("img").attr("abs:src") thumbnail_url = select("img").attr("data-src")
val publisher = select("p:contains(Publisher) button") val publisher = select("p:contains(Publisher) + div button")
.firstOrNull()?.let { "Publisher: ${it.text()}\n" } .firstOrNull()?.let { "Publisher: ${it.text()}\n" }
description = publisher + select("h5:contains(Description) + p").text() description = publisher + select("#comic-desc").text()
author = select("p:contains(Writer) button").joinToString { it.text() } author = select("thead:contains(Writer) + tbody button").joinToString { it.text() }
artist = select("p:contains(Artist) button").joinToString { it.text() } artist = select("thead:contains(Artist) + tbody button").joinToString { it.text() }
status = select("p span.mr-1 strong").text().toStatus() status = select("p span.mr-1 strong").text().toStatus()
genre = select("p:contains(Genre) button").joinToString { it.text() } genre = select("p:contains(Genre) ~ div button").joinToString { it.text() }
} }
} }
} }
@ -121,7 +124,7 @@ class Comicastle : ParsedHttpSource() {
return super.chapterListParse(response).reversed() return super.chapterListParse(response).reversed()
} }
override fun chapterListSelector() = "table tr a" override fun chapterListSelector() = "div.card-body > .table-responsive tr a"
override fun chapterFromElement(element: Element): SChapter { override fun chapterFromElement(element: Element): SChapter {
return SChapter.create().apply { return SChapter.create().apply {
@ -162,4 +165,4 @@ class Comicastle : ParsedHttpSource() {
} }
private fun createRequestBody(value: String) = private fun createRequestBody(value: String) =
("search=" + URLEncoder.encode(value, "UTF-8")).toRequestBody("application/x-www-form-urlencoded".toMediaTypeOrNull()) ("submit=Submit&search=" + URLEncoder.encode(value, "UTF-8")).toRequestBody("application/x-www-form-urlencoded".toMediaTypeOrNull())