From 4a88a93e8dbdb73778618bf23948eee762f328dc Mon Sep 17 00:00:00 2001 From: Draken <131387159+dragonx943@users.noreply.github.com> Date: Mon, 24 Feb 2025 13:29:34 +0700 Subject: [PATCH 1/2] [CBHentai] Fix tags Fix "Root not found" / "Content not found or removed" error [CBHentai] --- .../parsers/site/madara/vi/HentaiCube.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt index 2a81af34..c2266f3a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt @@ -6,10 +6,13 @@ import org.koitharu.kotatsu.parsers.exception.ParseException import org.koitharu.kotatsu.parsers.model.ContentType import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaPage +import org.koitharu.kotatsu.parsers.model.MangaTag +import org.koitharu.kotatsu.parsers.model.MangaListFilterOptions import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.site.madara.MadaraParser import org.koitharu.kotatsu.parsers.config.ConfigKey import org.koitharu.kotatsu.parsers.util.* +import java.util.* @MangaSourceParser("HENTAICUBE", "CBHentai", "vi", ContentType.HENTAI) internal class HentaiCube(context: MangaLoaderContext) : @@ -18,9 +21,12 @@ internal class HentaiCube(context: MangaLoaderContext) : override val configKeyDomain = ConfigKey.Domain("hentaicb.love", "hentaicube.xyz") override val datePattern = "dd/MM/yyyy" - override val tagPrefix = "the-loai/" override val postReq = true + override suspend fun getFilterOptions() = MangaListFilterOptions( + availableTags = fetchTags(), + ) + override suspend fun getPages(chapter: MangaChapter): List { val fullUrl = chapter.url.toAbsoluteUrl(domain) val doc = webClient.httpGet(fullUrl).parseHtml() @@ -36,4 +42,18 @@ internal class HentaiCube(context: MangaLoaderContext) : ) } } + + private suspend fun fetchTags(): Set { + val doc = webClient.httpGet("https://$domain/the-loai-genres").parseHtml() + val elements = doc.select("ul.list-unstyled li a") + return elements.mapToSet { element -> + val href = element.attr("href") + val key = href.substringAfter("/the-loai/").removeSuffix("/") + MangaTag( + key = key, + title = element.text().toTitleCase(sourceLocale), + source = source, + ) + }.toSet() + } } From df03c65d5a102d9e0fba0488096099e6a22cd708 Mon Sep 17 00:00:00 2001 From: Draken <131387159+dragonx943@users.noreply.github.com> Date: Mon, 24 Feb 2025 15:44:08 +0700 Subject: [PATCH 2/2] [CBHentai] Small fixes --- .../koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt index c2266f3a..933ef03c 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiCube.kt @@ -16,9 +16,9 @@ import java.util.* @MangaSourceParser("HENTAICUBE", "CBHentai", "vi", ContentType.HENTAI) internal class HentaiCube(context: MangaLoaderContext) : - MadaraParser(context, MangaParserSource.HENTAICUBE, "hentaicb.love") { + MadaraParser(context, MangaParserSource.HENTAICUBE, "hentaicube.xyz") { - override val configKeyDomain = ConfigKey.Domain("hentaicb.love", "hentaicube.xyz") + override val configKeyDomain = ConfigKey.Domain("hentaicube.xyz", "hentaicb.love") // hentaicb.love broken override val datePattern = "dd/MM/yyyy" override val postReq = true @@ -49,9 +49,10 @@ internal class HentaiCube(context: MangaLoaderContext) : return elements.mapToSet { element -> val href = element.attr("href") val key = href.substringAfter("/the-loai/").removeSuffix("/") + val title = element.text().replace(Regex("\\(\\d+\\)"), "") MangaTag( key = key, - title = element.text().toTitleCase(sourceLocale), + title = title.toTitleCase(sourceLocale), source = source, ) }.toSet()