diff --git a/.github/summary.yaml b/.github/summary.yaml index 3d183a6f..c1982aff 100644 --- a/.github/summary.yaml +++ b/.github/summary.yaml @@ -1 +1 @@ -total: 1192 +total: 1192 \ No newline at end of file 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 1e9ddd3c..df64bf90 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 @@ -1,5 +1,7 @@ package org.koitharu.kotatsu.parsers.site.madara.vi +import kotlinx.coroutines.async +import kotlinx.coroutines.coroutineScope import org.koitharu.kotatsu.parsers.MangaLoaderContext import org.koitharu.kotatsu.parsers.MangaSourceParser import org.koitharu.kotatsu.parsers.exception.ParseException @@ -11,6 +13,7 @@ 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.model.* import org.koitharu.kotatsu.parsers.util.* import java.util.* @@ -27,6 +30,53 @@ internal class HentaiCube(context: MangaLoaderContext) : availableTags = fetchTags(), ) + override suspend fun getDetails(manga: Manga): Manga = coroutineScope { + val fullUrl = manga.url.toAbsoluteUrl(domain) + val doc = webClient.httpGet(fullUrl).parseHtml() + + val href = doc.selectFirst("head meta[property='og:url']")?.attr("content")?.toRelativeUrl(domain) ?: manga.url + val testCheckAsync = doc.select(selectTestAsync) + val chaptersDeferred = if (testCheckAsync.isNullOrEmpty()) { + async { loadChapters(href, doc) } + } else { + async { getChapters(manga, doc) } + } + + val desc = doc.select(selectDesc).html() + + val stateDiv = doc.selectFirst(selectState)?.selectLast("div.summary-content") + + val state = stateDiv?.let { + when (it.text().lowercase()) { + in ongoing -> MangaState.ONGOING + in finished -> MangaState.FINISHED + in abandoned -> MangaState.ABANDONED + in paused -> MangaState.PAUSED + else -> null + } + } + + val alt = doc.body().select(selectAlt).firstOrNull()?.tableValue()?.textOrNull() + + manga.copy( + title = doc.selectFirst("h1")?.textOrNull() ?: manga.title, + url = href, + publicUrl = href.toAbsoluteUrl(domain), + tags = doc.body().select(selectGenre).mapToSet { a -> + MangaTag( + key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + title = a.text().toTitleCase(), + source = source, + ) + }, + description = desc, + altTitles = setOfNotNull(alt), + state = state, + chapters = chaptersDeferred.await(), + contentRating = ContentRating.ADULT, + ) + } + override suspend fun getPages(chapter: MangaChapter): List { val fullUrl = chapter.url.toAbsoluteUrl(domain) val doc = webClient.httpGet(fullUrl).parseHtml() diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiZ.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiZ.kt index f96831ee..7b63960a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiZ.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/HentaiZ.kt @@ -1,15 +1,66 @@ package org.koitharu.kotatsu.parsers.site.madara.vi +import kotlinx.coroutines.async +import kotlinx.coroutines.coroutineScope import org.koitharu.kotatsu.parsers.MangaLoaderContext import org.koitharu.kotatsu.parsers.MangaSourceParser import org.koitharu.kotatsu.parsers.model.ContentType import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.site.madara.MadaraParser +import org.koitharu.kotatsu.parsers.model.* +import org.koitharu.kotatsu.parsers.util.* +import java.util.* @MangaSourceParser("HENTAIZ", "HentaiZ", "vi", ContentType.HENTAI) internal class HentaiZ(context: MangaLoaderContext) : - MadaraParser(context, MangaParserSource.HENTAIZ, "hentaiz.pw", 24) { + MadaraParser(context, MangaParserSource.HENTAIZ, "hentaiz.run", 24) { override val listUrl = "truyen-hentai/" override val tagPrefix = "the-loai/" override val datePattern = "dd/MM/yyyy" + + override suspend fun getDetails(manga: Manga): Manga = coroutineScope { + val fullUrl = manga.url.toAbsoluteUrl(domain) + val doc = webClient.httpGet(fullUrl).parseHtml() + + val href = doc.selectFirst("head meta[property='og:url']")?.attr("content")?.toRelativeUrl(domain) ?: manga.url + val testCheckAsync = doc.select(selectTestAsync) + val chaptersDeferred = if (testCheckAsync.isNullOrEmpty()) { + async { loadChapters(href, doc) } + } else { + async { getChapters(manga, doc) } + } + + val desc = doc.select(selectDesc).html() + + val stateDiv = doc.selectFirst(selectState)?.selectLast("div.summary-content") + + val state = stateDiv?.let { + when (it.text().lowercase()) { + in ongoing -> MangaState.ONGOING + in finished -> MangaState.FINISHED + in abandoned -> MangaState.ABANDONED + in paused -> MangaState.PAUSED + else -> null + } + } + + val alt = doc.body().select(selectAlt).firstOrNull()?.tableValue()?.textOrNull() + + manga.copy( + url = href, + publicUrl = href.toAbsoluteUrl(domain), + tags = doc.body().select(selectGenre).mapToSet { a -> + MangaTag( + key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + title = a.text().toTitleCase(), + source = source, + ) + }, + description = desc, + altTitles = setOfNotNull(alt), + state = state, + chapters = chaptersDeferred.await(), + contentRating = ContentRating.ADULT, + ) + } }