Merge pull request #1557 from dragonx943/kuma/tweak

[Kumapage] Fixes + Tweak
master
Draken 1 year ago committed by GitHub
commit 3c62f4280f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -12,6 +12,8 @@ import org.koitharu.kotatsu.parsers.util.*
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
// TODO: Check if manga is NSFW by checking the genre
@MangaSourceParser("KUMAPAGE", "Kumapage", "id") @MangaSourceParser("KUMAPAGE", "Kumapage", "id")
internal class Kumapage(context: MangaLoaderContext) : internal class Kumapage(context: MangaLoaderContext) :
LegacyPagedMangaParser(context, MangaParserSource.KUMAPAGE, 14) { LegacyPagedMangaParser(context, MangaParserSource.KUMAPAGE, 14) {
@ -116,7 +118,6 @@ internal class Kumapage(context: MangaLoaderContext) :
rating = RATING_UNKNOWN, rating = RATING_UNKNOWN,
state = null, state = null,
coverUrl = img, coverUrl = img,
// TODO: Check if manga is NSFW by checking the genre
contentRating = if (isNsfwSource) ContentRating.ADULT else null, contentRating = if (isNsfwSource) ContentRating.ADULT else null,
source = source, source = source,
) )
@ -139,6 +140,9 @@ internal class Kumapage(context: MangaLoaderContext) :
MangaTag(title = tag.text(), key = "", source = source) MangaTag(title = tag.text(), key = "", source = source)
}.toSet() }.toSet()
val checkTags = setOf("Adult", "Ecchi", "Hentai", "Incest", "Josei(W)", "Loli", "Netorare", "Smut", "Violence")
val contentRating = if (tags.any { it.title in checkTags }) ContentRating.ADULT else null
val chapters = doc.select("tbody#result-comic tr").mapIndexed { i, row -> val chapters = doc.select("tbody#result-comic tr").mapIndexed { i, row ->
MangaChapter( MangaChapter(
id = generateUid(row.select("td:nth-child(4) a").attr("href")), id = generateUid(row.select("td:nth-child(4) a").attr("href")),
@ -158,6 +162,7 @@ internal class Kumapage(context: MangaLoaderContext) :
description = description, description = description,
state = state, state = state,
tags = tags, tags = tags,
contentRating = contentRating,
chapters = chapters, chapters = chapters,
) )
} }
@ -166,21 +171,29 @@ internal class Kumapage(context: MangaLoaderContext) :
val doc = webClient.httpGet(chapter.url.toAbsoluteUrl(domain)).parseHtml() val doc = webClient.httpGet(chapter.url.toAbsoluteUrl(domain)).parseHtml()
return doc.select("div.content_place img").mapNotNull { img -> return doc.select("div.content_place img").mapNotNull { img ->
val url = img.attr("src") val url = img.attr("src")
MangaPage( if (!img.hasClass("ui") && !img.hasClass("avatar") && !img.hasClass("image")) {
id = generateUid(url), MangaPage(
url = url, id = generateUid(url),
preview = null, url = url,
source = source, preview = null,
) source = source,
)
} else {
null
}
} }
} }
private suspend fun fetchTags(): Set<MangaTag> { private suspend fun fetchTags(): Set<MangaTag> {
val doc = webClient.httpGet("https://$domain/search").parseHtml() val doc = webClient.httpGet("https://$domain/search").parseHtml()
return doc.select("select#genre option").map { option -> return doc.select("select#genre option").mapNotNull { option ->
val key = option.attr("value") val key = option.attr("value")
val title = option.text() val title = option.text()
MangaTag(title = title, key = key, source = source) if (title != "All Genres") { // remove "all" tags to avoid "Nothing found"
}.toSet() MangaTag(title = title, key = key, source = source)
} } else {
null
}
}.toSet()
}
} }
Loading…
Cancel
Save