BacaKomik: fix img issue, clean series info, add artist (#19548)

- tweak ratelimit

Closes #19454
This commit is contained in:
Luqman 2024-01-06 00:24:33 +07:00 committed by GitHub
parent 4373270a9d
commit 47cb163ab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'BacaKomik'
pkgNameSuffix = 'id.bacakomik'
extClass = '.BacaKomik'
extVersionCode = 9
extVersionCode = 10
}
apply from: "$rootDir/common.gradle"

View File

@ -13,6 +13,7 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
@ -30,7 +31,7 @@ class BacaKomik : ParsedHttpSource() {
override val id = 4383360263234319058
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.rateLimit(20, 5)
.rateLimit(12, 3)
.build()
override fun popularMangaRequest(page: Int): Request {
@ -56,7 +57,7 @@ class BacaKomik : ParsedHttpSource() {
val manga = SManga.create()
manga.setUrlWithoutDomain(element.select("div.animposx > a").first()!!.attr("href"))
manga.title = element.select(".animposx .tt h4").text()
manga.thumbnail_url = element.select("div.limit img").attr("src")
manga.thumbnail_url = element.select("div.limit img").imgAttr()
return manga
}
@ -103,20 +104,17 @@ class BacaKomik : ParsedHttpSource() {
val descElement = document.select("div.desc > .entry-content.entry-content-single").first()!!
val manga = SManga.create()
manga.title = document.select("#breadcrumbs li:last-child span").text()
// need authorCleaner to take "pengarang:" string to remove it from author
val authorCleaner = document.select(".infox .spe b:contains(Author)").text()
manga.author = document.select(".infox .spe span:contains(Author)").text().substringAfter(authorCleaner)
manga.artist = manga.author
manga.author = document.select(".infox .spe span:contains(Author) :not(b)").text()
manga.artist = document.select(".infox .spe span:contains(Artis) :not(b)").text()
val genres = mutableListOf<String>()
infoElement.select(".infox > .genre-info > a, .infox .spe span:contains(Jenis Komik) a").forEach { element ->
val genre = element.text()
genres.add(genre)
}
manga.genre = genres.joinToString(", ")
val statusCleaner = document.select(".infox .spe b:contains(Status)").text()
manga.status = parseStatus(document.select(".infox .spe span:contains(Status)").text().substringAfter(statusCleaner))
manga.status = parseStatus(document.select(".infox .spe span:contains(Status)").text())
manga.description = descElement.select("p").text().substringAfter("bercerita tentang ")
manga.thumbnail_url = document.select(".thumb > img:nth-child(1)").attr("src")
manga.thumbnail_url = document.select(".thumb > img:nth-child(1)").imgAttr()
return manga
}
@ -325,6 +323,14 @@ class BacaKomik : ParsedHttpSource() {
Genre("Yuri", "yuri"),
)
private fun Element.imgAttr(): String = when {
hasAttr("data-lazy-src") -> attr("abs:data-lazy-src")
hasAttr("data-src") -> attr("abs:data-src")
else -> attr("abs:src")
}
private fun Elements.imgAttr(): String = this.first()!!.imgAttr()
private open class UriPartFilter(displayName: String, val vals: Array<Pair<String, String>>) :
Filter.Select<String>(displayName, vals.map { it.first }.toTypedArray()) {
fun toUriPart() = vals[state].second