Merge pull request #1491 - dragonx943/sources/cbhentai
[CBHentai] Fix tags
This commit is contained in:
@@ -6,21 +6,27 @@ 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) :
|
||||
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 tagPrefix = "the-loai/"
|
||||
override val postReq = true
|
||||
|
||||
override suspend fun getFilterOptions() = MangaListFilterOptions(
|
||||
availableTags = fetchTags(),
|
||||
)
|
||||
|
||||
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
|
||||
val fullUrl = chapter.url.toAbsoluteUrl(domain)
|
||||
val doc = webClient.httpGet(fullUrl).parseHtml()
|
||||
@@ -36,4 +42,19 @@ internal class HentaiCube(context: MangaLoaderContext) :
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun fetchTags(): Set<MangaTag> {
|
||||
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("/")
|
||||
val title = element.text().replace(Regex("\\(\\d+\\)"), "")
|
||||
MangaTag(
|
||||
key = key,
|
||||
title = title.toTitleCase(sourceLocale),
|
||||
source = source,
|
||||
)
|
||||
}.toSet()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user