From 08b1241a68628609d2cb7d3cd1683f9a2f6f2093 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 9 Nov 2024 19:43:23 +0200 Subject: [PATCH] Remove redundant trim and mapNotNullToSet usage --- .../kotatsu/parsers/site/all/BatoToParser.kt | 4 +- .../parsers/site/all/MangaFireParser.kt | 6 +- .../parsers/site/all/MangaReaderToParser.kt | 4 +- .../animebootstrap/AnimeBootstrapParser.kt | 2 +- .../parsers/site/animebootstrap/fr/PapScan.kt | 4 +- .../kotatsu/parsers/site/ar/FlixScans.kt | 2 +- .../kotatsu/parsers/site/ar/MangaStorm.kt | 2 +- .../kotatsu/parsers/site/ar/TeamXNovel.kt | 4 +- .../parsers/site/cupfox/CupFoxParser.kt | 8 +-- .../kotatsu/parsers/site/en/BeeToon.kt | 4 +- .../kotatsu/parsers/site/en/ComicExtra.kt | 6 +- .../kotatsu/parsers/site/en/DynastyScans.kt | 2 +- .../kotatsu/parsers/site/en/FlixScansOrg.kt | 8 +-- .../kotatsu/parsers/site/en/MangaGeko.kt | 6 +- .../kotatsu/parsers/site/en/MangaKawaiiEn.kt | 2 +- .../parsers/site/en/MangaTownParser.kt | 2 +- .../kotatsu/parsers/site/en/Mangaowl.kt | 8 +-- .../kotatsu/parsers/site/en/ManhwasMen.kt | 6 +- .../kotatsu/parsers/site/en/Pururin.kt | 2 +- .../kotatsu/parsers/site/en/VyManga.kt | 4 +- .../parsers/site/es/TuMangaOnlineParser.kt | 6 +- .../parsers/site/fmreader/FmreaderParser.kt | 4 +- .../parsers/site/fr/LegacyScansParser.kt | 4 +- .../kotatsu/parsers/site/fr/LireScan.kt | 4 +- .../kotatsu/parsers/site/fr/MangaKawaii.kt | 2 +- .../kotatsu/parsers/site/fr/MangaMana.kt | 6 +- .../kotatsu/parsers/site/fr/ScansMangasMe.kt | 4 +- .../kotatsu/parsers/site/fr/ScantradUnion.kt | 2 +- .../site/fuzzydoodle/FuzzyDoodleParser.kt | 2 +- .../site/galleryadults/all/NHentaiParser.kt | 2 +- .../kotatsu/parsers/site/id/HentaiCrot.kt | 2 +- .../kotatsu/parsers/site/id/PixHentai.kt | 2 +- .../parsers/site/ja/NicovideoSeigaParser.kt | 4 +- .../parsers/site/keyoapp/KeyoappParser.kt | 4 +- .../parsers/site/likemanga/LikeMangaParser.kt | 8 +-- .../parsers/site/madara/MadaraParser.kt | 6 +- .../parsers/site/madara/all/Manga18Fx.kt | 4 +- .../parsers/site/madara/all/Manhwa18Cc.kt | 4 +- .../parsers/site/madara/en/AdultWebtoon.kt | 8 +-- .../parsers/site/madara/en/HentaiManga.kt | 8 +-- .../parsers/site/madara/en/HentaiWebtoon.kt | 8 +-- .../parsers/site/madara/en/IsekaiScan.kt | 2 +- .../parsers/site/madara/en/MangaDass.kt | 9 +-- .../parsers/site/madara/en/MangaDna.kt | 11 ++-- .../parsers/site/madara/en/MangaPure.kt | 2 +- .../parsers/site/madara/en/ManhwaHentai.kt | 9 +-- .../parsers/site/madara/en/ManyToon.kt | 6 +- .../parsers/site/madara/es/MangasNoSekai.kt | 11 +--- .../parsers/site/madara/id/ManhwaHub.kt | 4 +- .../parsers/site/madara/vi/Saytruyenhay.kt | 11 ++-- .../parsers/site/madtheme/MadthemeParser.kt | 4 +- .../parsers/site/manga18/Manga18Parser.kt | 2 +- .../parsers/site/mangabox/MangaboxParser.kt | 4 +- .../parsers/site/mangabox/en/Mangairo.kt | 4 +- .../parsers/site/mangabox/en/Mangakakalot.kt | 2 +- .../site/mangabox/en/MangakakalotTv.kt | 4 +- .../parsers/site/mangareader/es/TuManhwas.kt | 2 +- .../site/mangaworld/MangaWorldParser.kt | 62 +++++++++---------- .../parsers/site/mmrcms/MmrcmsParser.kt | 2 +- .../kotatsu/parsers/site/mmrcms/ar/Onma.kt | 2 +- .../parsers/site/nepnep/NepnepParser.kt | 2 +- .../otakusanctuary/OtakuSanctuaryParser.kt | 8 +-- .../kotatsu/parsers/site/pt/BrMangas.kt | 4 +- .../kotatsu/parsers/site/pt/LerManga.kt | 8 +-- .../kotatsu/parsers/site/pt/LerMangaOnline.kt | 2 +- .../kotatsu/parsers/site/pt/MangaOnline.kt | 4 +- .../kotatsu/parsers/site/pt/MuitoHentai.kt | 4 +- .../parsers/site/ru/grouple/GroupleParser.kt | 2 +- .../site/ru/multichan/YaoiChanParser.kt | 2 +- .../kotatsu/parsers/site/sinmh/SinmhParser.kt | 4 +- .../kotatsu/parsers/site/tr/TrWebtoon.kt | 4 +- .../parsers/site/vi/BlogTruyenParser.kt | 2 +- .../kotatsu/parsers/site/vi/BlogTruyenVN.kt | 6 +- .../kotatsu/parsers/site/vi/HentaiVNParser.kt | 4 +- .../kotatsu/parsers/site/vi/TruyenQQ.kt | 6 +- .../kotatsu/parsers/site/vmp/VmpParser.kt | 4 +- .../parsers/site/wpcomics/en/XoxoComics.kt | 2 +- .../site/zeistmanga/ZeistMangaParser.kt | 4 +- .../parsers/site/zeistmanga/ar/MangaAiLand.kt | 4 +- .../parsers/site/zeistmanga/ar/MangaHub.kt | 2 +- .../parsers/site/zeistmanga/id/KlManhua.kt | 4 +- .../parsers/site/zeistmanga/id/Mikoroku.kt | 2 +- .../parsers/site/zeistmanga/id/ShiyuraSub.kt | 4 +- .../parsers/site/zeistmanga/id/ToonCubus.kt | 2 +- .../parsers/site/zeistmanga/pt/AnimeXNovel.kt | 2 +- .../site/zeistmanga/pt/GuildaTierDraw.kt | 4 +- .../parsers/site/zeistmanga/tr/EpikMan.kt | 4 +- .../site/zeistmanga/tr/Mikrokosmosfb.kt | 4 +- .../site/zeistmanga/tr/SnscoeurTurkey.kt | 4 +- .../parsers/site/zmanga/ZMangaParser.kt | 4 +- .../kotatsu/parsers/util/Collection.kt | 2 +- 91 files changed, 221 insertions(+), 226 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/BatoToParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/BatoToParser.kt index c6fbce98..6b8a1829 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/BatoToParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/BatoToParser.kt @@ -210,7 +210,7 @@ internal class BatoToParser(context: MangaLoaderContext) : PagedMangaParser( .requireElementById("mainer") val details = root.selectFirstOrThrow(".detail-set") val attrs = details.selectFirst(".attr-main")?.select(".attr-item")?.associate { - it.child(0).text().trim() to it.child(1) + it.child(0).text() to it.child(1) }.orEmpty() return manga.copy( title = root.selectFirst("h3.item-title")?.text() ?: manga.title, @@ -227,7 +227,7 @@ internal class BatoToParser(context: MangaLoaderContext) : PagedMangaParser( "Hiatus" -> MangaState.PAUSED else -> manga.state }, - author = attrs["Authors:"]?.text()?.trim() ?: manga.author, + author = attrs["Authors:"]?.textOrNull() ?: manga.author, chapters = root.selectFirst(".episode-list") ?.selectFirst(".main") ?.children() diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaFireParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaFireParser.kt index 557899e7..8d423bd6 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaFireParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaFireParser.kt @@ -181,7 +181,7 @@ internal abstract class MangaFireParser( coverUrl = document.selectFirstOrThrow("div.manga-detail div.poster img") .attrAsAbsoluteUrl("src"), tags = document.select("div.meta a[href*=/genre/]").mapNotNullToSet { - val tag = it.ownText().trim() + val tag = it.ownText() if (tag == "Hentai" || tag == "Ecchi") { isNsfw = true } @@ -189,7 +189,7 @@ internal abstract class MangaFireParser( }, isNsfw = isNsfw, state = document.selectFirst(".info > p")?.ownText()?.let { - when (it.lowercase().trim()) { + when (it.lowercase()) { "releasing" -> MangaState.ONGOING "completed" -> MangaState.FINISHED "discontinued" -> MangaState.ABANDONED @@ -199,7 +199,7 @@ internal abstract class MangaFireParser( } }, author = document.select("div.meta a[href*=/author/]") - .joinToString { it.ownText().trim() }, + .joinToString { it.ownText() }, description = document.selectFirstOrThrow("#synopsis div.modal-content").html(), chapters = getChapters(manga.url, document), ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaReaderToParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaReaderToParser.kt index 09137f05..0c21a3c6 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaReaderToParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaReaderToParser.kt @@ -62,7 +62,7 @@ internal class MangaReaderToParser(context: MangaLoaderContext) : document.select("div.f-genre-item").map { MangaTag( - title = it.ownText().trim(), + title = it.ownText().toTitleCase(sourceLocale), key = it.attr("data-id"), source = source, ) @@ -176,7 +176,7 @@ internal class MangaReaderToParser(context: MangaLoaderContext) : ?.text()?.toFloatOrNull()?.div(10) ?: RATING_UNKNOWN, coverUrl = document.selectFirst(".manga-poster > img")!!.attr("src"), tags = document.select("div.genres > a[href*=/genre/]").mapNotNullToSet { - val tag = it.ownText().trim() + val tag = it.ownText() if (tag == "Hentai" || tag == "Ecchi") { isNsfw = true } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/animebootstrap/AnimeBootstrapParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/animebootstrap/AnimeBootstrapParser.kt index 6d1590f7..994f65ee 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/animebootstrap/AnimeBootstrapParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/animebootstrap/AnimeBootstrapParser.kt @@ -146,7 +146,7 @@ internal abstract class AnimeBootstrapParser( } manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('='), title = a.text().toTitleCase().replace(",", ""), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/animebootstrap/fr/PapScan.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/animebootstrap/fr/PapScan.kt index 9beffb8d..5dec556c 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/animebootstrap/fr/PapScan.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/animebootstrap/fr/PapScan.kt @@ -81,7 +81,7 @@ internal class PapScan(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain$listUrl").parseHtml() - return doc.select("a.category ").mapNotNullToSet { a -> + return doc.select("a.category ").mapToSet { a -> val key = a.attr("href").substringAfterLast('=') val name = a.text() MangaTag( @@ -103,7 +103,7 @@ internal class PapScan(context: MangaLoaderContext) : MangaState.ONGOING } manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/FlixScans.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/FlixScans.kt index c710c568..94d1a46c 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/FlixScans.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/FlixScans.kt @@ -132,7 +132,7 @@ internal class FlixScans(context: MangaLoaderContext) : PagedMangaParser(context val doc = webClient.httpGet("https://$domain/search/advance").parseHtml() val json = JSONArray(doc.requireElementById("__NUXT_DATA__").data()) val tagsList = json.getJSONArray(3).toString().replace("[", "").replace("]", "").split(",") - return tagsList.mapNotNullToSet { idTag -> + return tagsList.mapToSet { idTag -> val id = idTag.toInt() val idKey = json.getJSONObject(id).getInt("id") val key = json.getInt(idKey).toString() diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/MangaStorm.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/MangaStorm.kt index 23328529..80036124 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/MangaStorm.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/MangaStorm.kt @@ -90,7 +90,7 @@ internal class MangaStorm(context: MangaLoaderContext) : PagedMangaParser(contex return manga.copy( altTitle = null, state = null, - tags = root.select(".flex-wrap a").mapNotNullToSet { a -> + tags = root.select(".flex-wrap a").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('/'), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/TeamXNovel.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/TeamXNovel.kt index 3f55e746..10e2d47e 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/TeamXNovel.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ar/TeamXNovel.kt @@ -125,7 +125,7 @@ internal class TeamXNovel(context: MangaLoaderContext) : PagedMangaParser(contex private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/series").parseHtml() - return doc.requireElementById("select_genre").select("option").mapNotNullToSet { + return doc.requireElementById("select_genre").select("option").mapToSet { MangaTag( key = it.attr("value"), title = it.text().toTitleCase(sourceLocale), @@ -155,7 +155,7 @@ internal class TeamXNovel(context: MangaLoaderContext) : PagedMangaParser(contex "متوقف" -> MangaState.ABANDONED else -> null }, - tags = doc.select(".review-author-info a").mapNotNullToSet { a -> + tags = doc.select(".review-author-info a").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast("="), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/cupfox/CupFoxParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/cupfox/CupFoxParser.kt index 112607e2..9f1f1ebe 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/cupfox/CupFoxParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/cupfox/CupFoxParser.kt @@ -126,9 +126,9 @@ internal abstract class CupFoxParser( return manga.copy( altTitle = doc.selectFirst(selectMangaDetailsAltTitle)?.text()?.substringAfter(":"), state = null, - tags = doc.select(selectMangaDetailsTags).mapNotNullToSet { a -> + tags = doc.select(selectMangaDetailsTags).mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), source = source, ) @@ -198,9 +198,9 @@ internal abstract class CupFoxParser( protected open suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/category/").parseHtml() return doc.select(selectAvailableTags) - .mapNotNullToSet { a -> + .mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/BeeToon.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/BeeToon.kt index 9d118d96..ceda3067 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/BeeToon.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/BeeToon.kt @@ -92,7 +92,7 @@ internal class BeeToon(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/").parseHtml() - return doc.requireElementById("menu-item-3").select("ul.sub-menu li a").mapNotNullToSet { + return doc.requireElementById("menu-item-3").select("ul.sub-menu li a").mapToSet { MangaTag( key = it.attr("href").removeSuffix('/').substringAfterLast('/'), title = it.text(), @@ -106,7 +106,7 @@ internal class BeeToon(context: MangaLoaderContext) : return manga.copy( description = doc.getElementById("desc")?.text().orEmpty(), rating = doc.selectFirst(".counter")?.text()?.toFloatOrNull()?.div(5f) ?: RATING_UNKNOWN, - tags = doc.body().select(".info .genre a").mapNotNullToSet { + tags = doc.body().select(".info .genre a").mapToSet { MangaTag( key = it.attr("href").removeSuffix('/').substringAfterLast('/'), title = it.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/ComicExtra.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/ComicExtra.kt index 0a95edac..878efd6b 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/ComicExtra.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/ComicExtra.kt @@ -114,7 +114,7 @@ internal class ComicExtra(context: MangaLoaderContext) : PagedMangaParser(contex private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/popular-comic").parseHtml() - return doc.select("li.tag-item a").mapNotNullToSet { a -> + return doc.select("li.tag-item a").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('/'), title = a.text(), @@ -133,9 +133,9 @@ internal class ComicExtra(context: MangaLoaderContext) : PagedMangaParser(contex "Completed" -> MangaState.FINISHED else -> null }, - tags = doc.select("dt.movie-dt:contains(Genres:) + dd a").mapNotNullToSet { a -> + tags = doc.select("dt.movie-dt:contains(Genres:) + dd a").mapToSet { a -> MangaTag( - key = a.attr("href").substringAfterLast("/"), + key = a.attr("href").substringAfterLast('/'), title = a.text(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/DynastyScans.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/DynastyScans.kt index 0ab727f2..6d45e882 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/DynastyScans.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/DynastyScans.kt @@ -113,7 +113,7 @@ internal class DynastyScans(context: MangaLoaderContext) : rating = RATING_UNKNOWN, isNsfw = false, coverUrl = "", - tags = div.select("span.tags a").mapNotNullToSet { a -> + tags = div.select("span.tags a").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/FlixScansOrg.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/FlixScansOrg.kt index 0782dd4a..e9412273 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/FlixScansOrg.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/FlixScansOrg.kt @@ -4,11 +4,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import org.json.JSONArray import org.json.JSONObject -import org.koitharu.kotatsu.parsers.Broken -import org.koitharu.kotatsu.parsers.ErrorMessages -import org.koitharu.kotatsu.parsers.MangaLoaderContext -import org.koitharu.kotatsu.parsers.MangaSourceParser -import org.koitharu.kotatsu.parsers.PagedMangaParser +import org.koitharu.kotatsu.parsers.* import org.koitharu.kotatsu.parsers.config.ConfigKey import org.koitharu.kotatsu.parsers.model.* import org.koitharu.kotatsu.parsers.util.* @@ -115,7 +111,7 @@ internal class FlixScansOrg(context: MangaLoaderContext) : val doc = webClient.httpGet("https://$domain/search/advance").parseHtml() val json = JSONArray(doc.requireElementById("__NUXT_DATA__").data()) val tagsList = json.getJSONArray(3).toString().replace("[", "").replace("]", "").split(",") - return tagsList.mapNotNullToSet { idTag -> + return tagsList.mapToSet { idTag -> val id = idTag.toInt() val idKey = json.getJSONObject(id).getInt("id") val key = json.getInt(idKey).toString() diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaGeko.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaGeko.kt index 06beb4f4..d083ce60 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaGeko.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaGeko.kt @@ -96,7 +96,7 @@ internal class MangaGeko(context: MangaLoaderContext) : PagedMangaParser(context private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/browse-comics/").parseHtml() - return doc.selectFirstOrThrow("div.genre-select-i").select("label").mapNotNullToSet { label -> + return doc.selectFirstOrThrow("div.genre-select-i").select("label").mapToSet { label -> MangaTag( key = label.selectFirstOrThrow("input").attr("value"), title = label.text(), @@ -115,9 +115,9 @@ internal class MangaGeko(context: MangaLoaderContext) : PagedMangaParser(context "Completed" -> MangaState.FINISHED else -> null }, - tags = doc.select(".categories ul li a").mapNotNullToSet { a -> + tags = doc.select(".categories ul li a").mapToSet { a -> MangaTag( - key = a.attr("href").substringAfterLast("="), + key = a.attr("href").substringAfterLast('='), title = a.text(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaKawaiiEn.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaKawaiiEn.kt index 03405b47..88e88407 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaKawaiiEn.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaKawaiiEn.kt @@ -164,7 +164,7 @@ internal class MangaKawaiiEn(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/manga-list/").parseHtml() - return doc.select("ul li a.category").mapNotNullToSet { a -> + return doc.select("ul li a.category").mapToSet { a -> val name = a.text() val key = name.lowercase().replace(" ", "-").replace("é", "e").replace("è", "e") MangaTag( diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaTownParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaTownParser.kt index 71f03e67..2916122b 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaTownParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/MangaTownParser.kt @@ -126,7 +126,7 @@ internal class MangaTownParser(context: MangaLoaderContext) : "completed" -> MangaState.FINISHED else -> null }, - tags = li.selectFirst("p.keyWord")?.select("a")?.mapNotNullToSet tags@{ x -> + tags = li.selectFirst("p.keyWord")?.select("a")?.mapToSet tags@{ x -> MangaTag( title = x.attr("title").toTitleCase(), key = x.attr("href").substringAfter("/directory/0-").substringBefore("-0-"), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/Mangaowl.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/Mangaowl.kt index 274e7cc5..f28f9156 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/Mangaowl.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/Mangaowl.kt @@ -119,8 +119,8 @@ internal class Mangaowl(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/10-genres").parseHtml() - return doc.select("div.genres-container span.genre-item a").mapNotNullToSet { a -> - val key = a.attr("href").removeSuffix('/').substringAfterLast('/').substringBefore("-") + return doc.select("div.genres-container span.genre-item a").mapToSet { a -> + val key = a.attr("href").removeSuffix('/').substringAfterLast('/').substringBefore('-') MangaTag( key = key, title = a.text(), @@ -133,9 +133,9 @@ internal class Mangaowl(context: MangaLoaderContext) : val fullUrl = manga.url.toAbsoluteUrl(domain) val doc = webClient.httpGet(fullUrl).parseHtml() manga.copy( - tags = doc.body().select("div.comic-attrs div.column.my-2:contains(Genres) a").mapNotNullToSet { a -> + tags = doc.body().select("div.comic-attrs div.column.my-2:contains(Genres) a").mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/').substringBefore("-"), + key = a.attr("href").removeSuffix('/').substringAfterLast('/').substringBefore('-'), title = a.text().toTitleCase().replace(",", ""), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/ManhwasMen.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/ManhwasMen.kt index b5031864..5b44b12e 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/ManhwasMen.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/ManhwasMen.kt @@ -99,9 +99,9 @@ internal class ManhwasMen(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val tags = webClient.httpGet("https://$domain/manga-list").parseHtml() .selectLastOrThrow(".filter-bx .form-group select.custom-select").select("option").drop(1) - return tags.mapNotNullToSet { option -> + return tags.mapToSet { option -> MangaTag( - key = option.attr("value").substringAfterLast("="), + key = option.attr("value").substringAfterLast('='), title = option.text(), source = source, ) @@ -112,7 +112,7 @@ internal class ManhwasMen(context: MangaLoaderContext) : val doc = webClient.httpGet(manga.url.toAbsoluteUrl(domain)).parseHtml() val simpleDateFormat = SimpleDateFormat("dd/MM/yyyy", sourceLocale) return manga.copy( - tags = doc.body().select(".genres a").mapNotNullToSet { a -> + tags = doc.body().select(".genres a").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('='), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/Pururin.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/Pururin.kt index e8b2b7c0..ff513977 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/Pururin.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/Pururin.kt @@ -136,7 +136,7 @@ internal class Pururin(context: MangaLoaderContext) : manga.copy( description = doc.selectFirst("p.mb-2")?.text().orEmpty(), rating = doc.selectFirst("td span.rating")?.attr("content")?.toFloatOrNull()?.div(5f) ?: RATING_UNKNOWN, - tags = doc.body().select("tr:contains(Contents) ul.list-inline a").mapNotNullToSet { + tags = doc.body().select("tr:contains(Contents) ul.list-inline a").mapToSet { val href = it.attr("href").substringAfterLast("content/").substringBeforeLast('/') MangaTag( key = href, diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/VyManga.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/VyManga.kt index 32cc85ce..40ac23f7 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/VyManga.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/en/VyManga.kt @@ -120,7 +120,7 @@ internal class VyManga(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/search").parseHtml() - return doc.select("#advance-search .check-genre .d-flex").mapNotNullToSet { + return doc.select("#advance-search .check-genre .d-flex").mapToSet { MangaTag( key = it.selectFirstOrThrow(".checkbox-genre").attr("data-value"), title = it.selectFirstOrThrow("label").text(), @@ -133,7 +133,7 @@ internal class VyManga(context: MangaLoaderContext) : val doc = webClient.httpGet(manga.url.toAbsoluteUrl(domain)).parseHtml() val simpleDateFormat = SimpleDateFormat("MMM dd, yyy", sourceLocale) return manga.copy( - tags = doc.select("div.col-md-7 p a[href*=genre]").mapNotNullToSet { a -> + tags = doc.select("div.col-md-7 p a[href*=genre]").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('/'), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/es/TuMangaOnlineParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/es/TuMangaOnlineParser.kt index 68055965..06f18b9f 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/es/TuMangaOnlineParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/es/TuMangaOnlineParser.kt @@ -176,9 +176,9 @@ internal class TuMangaOnlineParser(context: MangaLoaderContext) : PagedMangaPars val contents = doc.body().selectFirstOrThrow("section.element-header-content") return manga.copy( description = contents.selectFirst("p.element-description")?.html(), - tags = contents.select("h6 a").mapNotNullToSet { a -> + tags = contents.select("h6 a").mapToSet { a -> MangaTag( - key = a.attr("href").substringBefore("&").substringAfterLast("="), + key = a.attr("href").substringBefore('&').substringAfterLast('='), title = a.text(), source = source, ) @@ -342,7 +342,7 @@ internal class TuMangaOnlineParser(context: MangaLoaderContext) : PagedMangaPars private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/library", getRequestHeaders()).parseHtml() val elements = doc.body().select("div#books-genders > div > div") - return elements.mapNotNullToSet { element -> + return elements.mapToSet { element -> MangaTag( title = element.select("label").text(), key = element.select("input").attr("value"), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fmreader/FmreaderParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fmreader/FmreaderParser.kt index 2f256e7d..5c4b65e9 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fmreader/FmreaderParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fmreader/FmreaderParser.kt @@ -159,7 +159,7 @@ internal abstract class FmreaderParser( protected open suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/$listUrl").parseHtml() - return doc.select(selectBodyTag).mapNotNullToSet { a -> + return doc.select(selectBodyTag).mapToSet { a -> val href = a.attr("href").substringAfter(tagPrefix).substringBeforeLast(".html") MangaTag( key = href, @@ -192,7 +192,7 @@ internal abstract class FmreaderParser( val alt = doc.body().selectFirst(selectAlt)?.text()?.replace("Other names", "") val auth = doc.body().selectFirst(selectAut)?.text() manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").substringAfter(tagPrefix).substringBeforeLast(".html"), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/LegacyScansParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/LegacyScansParser.kt index f0729279..17497c54 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/LegacyScansParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/LegacyScansParser.kt @@ -172,7 +172,7 @@ internal class LegacyScansParser(context: MangaLoaderContext) : val dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.FRENCH) return manga.copy( altTitle = null, - tags = root.select("div.serieGenre span").mapNotNullToSet { span -> + tags = root.select("div.serieGenre span").mapToSet { span -> MangaTag( key = span.text(), title = span.text(), @@ -221,7 +221,7 @@ internal class LegacyScansParser(context: MangaLoaderContext) : val script = doc.requireElementById("__NUXT_DATA__").data() .substringAfterLast("\"genres\"").substringBeforeLast("\"comics\"") .split("\",\"").drop(1) - return script.mapNotNullToSet { tag -> + return script.mapToSet { tag -> MangaTag( key = tag.substringBeforeLast("\",{"), title = tag.substringBeforeLast("\",{"), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/LireScan.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/LireScan.kt index 50dbeb34..35cb1fe9 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/LireScan.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/LireScan.kt @@ -94,7 +94,7 @@ internal class LireScan(context: MangaLoaderContext) : PagedMangaParser(context, else -> null }, tags = root.select("ul.pmovie__list li:contains(Genre:)").text() - .replace("Genre:", "").split(" / ").mapNotNullToSet { tag -> + .replace("Genre:", "").split(" / ").mapToSet { tag -> MangaTag( key = tag.lowercase(), title = tag, @@ -142,7 +142,7 @@ internal class LireScan(context: MangaLoaderContext) : PagedMangaParser(context, private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/").parseHtml() - return doc.select(".nav-menu li a").mapNotNullToSet { a -> + return doc.select(".nav-menu li a").mapToSet { a -> val key = a.attr("href").removeSuffix('/').substringAfterLast("manga/", "") MangaTag( key = key, diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/MangaKawaii.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/MangaKawaii.kt index e57f58f0..8dc10261 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/MangaKawaii.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/MangaKawaii.kt @@ -163,7 +163,7 @@ internal class MangaKawaii(context: MangaLoaderContext) : PagedMangaParser(conte private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/manga-list/").parseHtml() - return doc.select("ul li a.category").mapNotNullToSet { a -> + return doc.select("ul li a.category").mapToSet { a -> val name = a.text() val key = name.lowercase().replace(" ", "-").replace("é", "e").replace("è", "e") MangaTag( diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/MangaMana.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/MangaMana.kt index c0cb6852..bf768540 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/MangaMana.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/MangaMana.kt @@ -186,7 +186,7 @@ internal class MangaMana(context: MangaLoaderContext) : PagedMangaParser(context isNsfw = isNsfw, coverUrl = img.orEmpty(), description = div.selectFirst(".mangalist_item_description")?.text().orEmpty(), - tags = div.select("div.mb-1 a").mapNotNullToSet { + tags = div.select("div.mb-1 a").mapToSet { val key = it.attr("href").substringAfterLast('=') MangaTag( key = key, @@ -246,7 +246,7 @@ internal class MangaMana(context: MangaLoaderContext) : PagedMangaParser(context author = doc.selectFirst("div.show_details span[itemprop=author]")?.text().orEmpty(), description = doc.selectFirst("dd[itemprop=description]")?.text(), rating = doc.getElementById("avgrating")?.ownText()?.toFloatOrNull()?.div(5f) ?: RATING_UNKNOWN, - tags = doc.select("ul.list-unstyled li a.category").mapNotNullToSet { + tags = doc.select("ul.list-unstyled li a.category").mapToSet { val key = it.attr("href").substringAfterLast('=') MangaTag( key = key, @@ -333,7 +333,7 @@ internal class MangaMana(context: MangaLoaderContext) : PagedMangaParser(context private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/liste-mangas").parseHtml() - return doc.select("select.selectpicker option").drop(1).mapNotNullToSet { + return doc.select("select.selectpicker option").drop(1).mapToSet { MangaTag( key = it.attr("value"), title = it.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/ScansMangasMe.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/ScansMangasMe.kt index e6573d9b..f9a7a771 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/ScansMangasMe.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/ScansMangasMe.kt @@ -97,7 +97,7 @@ internal class ScansMangasMe(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/tous-nos-mangas/").parseHtml() - return doc.select("ul.genre li").mapNotNullToSet { li -> + return doc.select("ul.genre li").mapToSet { li -> val key = li.selectFirstOrThrow("a").attr("href").removeSuffix('/').substringAfterLast('/') val name = li.selectFirstOrThrow("a").text() MangaTag( @@ -116,7 +116,7 @@ internal class ScansMangasMe(context: MangaLoaderContext) : val alt = doc.body().select("div.infox span.alter").text() val aut = doc.select("div.spe span")[2].text().replace("Auteur:", "") manga.copy( - tags = doc.select("div.spe span:contains(Genres) a").mapNotNullToSet { a -> + tags = doc.select("div.spe span:contains(Genres) a").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/ScantradUnion.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/ScantradUnion.kt index afbb9185..52ed4472 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/ScantradUnion.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fr/ScantradUnion.kt @@ -130,7 +130,7 @@ internal class ScantradUnion(context: MangaLoaderContext) : "Terminé", "Abondonné", "One Shot" -> MangaState.FINISHED else -> null }, - tags = root.select("div.project-details a[href*=tag]").mapNotNullToSet { a -> + tags = root.select("div.project-details a[href*=tag]").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fuzzydoodle/FuzzyDoodleParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fuzzydoodle/FuzzyDoodleParser.kt index 3df52aeb..531d12b4 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fuzzydoodle/FuzzyDoodleParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/fuzzydoodle/FuzzyDoodleParser.kt @@ -193,7 +193,7 @@ internal abstract class FuzzyDoodleParser( }, author = doc.selectFirst(selectAuthor)?.text().orEmpty(), description = doc.select(selectDescription).text(), - tags = doc.select(selectTagManga).mapNotNullToSet { + tags = doc.select(selectTagManga).mapToSet { val key = it.attr("href").substringAfterLast('=') MangaTag( key = key, diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/galleryadults/all/NHentaiParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/galleryadults/all/NHentaiParser.kt index fa553330..c8a7ef32 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/galleryadults/all/NHentaiParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/galleryadults/all/NHentaiParser.kt @@ -81,7 +81,7 @@ internal class NHentaiParser(context: MangaLoaderContext) : private suspend fun fetchMangaTitle(url: String): String { val doc = webClient.httpGet(url).parseHtml() - return doc.selectFirstOrThrow("h1.title").text().trim() + return doc.selectFirstOrThrow("h1.title").text() } override fun parseMangaList(doc: Document): List { diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/id/HentaiCrot.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/id/HentaiCrot.kt index 00adfdde..77ef80ca 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/id/HentaiCrot.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/id/HentaiCrot.kt @@ -81,7 +81,7 @@ internal class HentaiCrot(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.select("ul.megamenu li").mapNotNullToSet { li -> + return doc.select("ul.megamenu li").mapToSet { li -> val key = li.selectFirstOrThrow("a").attr("href").removeSuffix('/').substringAfterLast('/') val name = li.selectFirstOrThrow("a").text() MangaTag( diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/id/PixHentai.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/id/PixHentai.kt index fd2feb6e..cfb31772 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/id/PixHentai.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/id/PixHentai.kt @@ -81,7 +81,7 @@ internal class PixHentai(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.select("ul.megamenu li").mapNotNullToSet { li -> + return doc.select("ul.megamenu li").mapToSet { li -> val key = li.selectFirstOrThrow("a").attr("href").removeSuffix('/').substringAfterLast('/') val name = li.selectFirstOrThrow("a").text() MangaTag( diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ja/NicovideoSeigaParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ja/NicovideoSeigaParser.kt index 9b636c36..5f83e0b5 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ja/NicovideoSeigaParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ja/NicovideoSeigaParser.kt @@ -96,7 +96,7 @@ internal class NicovideoSeigaParser(context: MangaLoaderContext) : tags = item.getElementsByAttributeValueContaining("href", "?category=").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('='), - title = a.ownText().trim(), + title = a.ownText(), source = source, ) }, @@ -187,7 +187,7 @@ internal class NicovideoSeigaParser(context: MangaLoaderContext) : url = href, publicUrl = href.toAbsoluteUrl(item.host ?: domain), title = item.selectFirst(".search_result__item__info > .search_result__item__info--title > a") - ?.text()?.trim() ?: return@mapNotNull null, + ?.textOrNull() ?: return@mapNotNull null, altTitle = null, author = null, tags = emptySet(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/keyoapp/KeyoappParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/keyoapp/KeyoappParser.kt index 95389c55..8206b09e 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/keyoapp/KeyoappParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/keyoapp/KeyoappParser.kt @@ -131,7 +131,7 @@ internal abstract class KeyoappParser( title = div.selectFirstOrThrow("h3").text().orEmpty(), altTitle = null, rating = RATING_UNKNOWN, - tags = div.select("div.gap-1 a").mapNotNullToSet { a -> + tags = div.select("div.gap-1 a").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('='), title = a.text().toTitleCase(), @@ -169,7 +169,7 @@ internal abstract class KeyoappParser( val doc = webClient.httpGet(fullUrl).parseHtml() val dateFormat = SimpleDateFormat(datePattern, sourceLocale) manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('='), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/likemanga/LikeMangaParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/likemanga/LikeMangaParser.kt index 2dca899c..3320b246 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/likemanga/LikeMangaParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/likemanga/LikeMangaParser.kt @@ -127,9 +127,9 @@ internal abstract class LikeMangaParser( private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/genres/").parseHtml() - return doc.select("ul.nav-genres li:not(.text-center) a").mapNotNullToSet { a -> + return doc.select("ul.nav-genres li:not(.text-center) a").mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text(), source = source, ) @@ -152,9 +152,9 @@ internal abstract class LikeMangaParser( return manga.copy( altTitle = doc.selectFirstOrThrow(".list-info li.othername h2").text(), state = null, - tags = doc.select("li.kind a").mapNotNullToSet { a -> + tags = doc.select("li.kind a").mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/MadaraParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/MadaraParser.kt index 97f14d82..256ee442 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/MadaraParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/MadaraParser.kt @@ -508,7 +508,7 @@ internal abstract class MadaraParser( val keySet = HashSet(list.size) return list.mapNotNullToSet { li -> val a = li.selectFirst("a") ?: return@mapNotNullToSet null - val href = a.attr("href").removeSuffix("/").substringAfterLast(tagPrefix, "") + val href = a.attr("href").removeSuffix('/').substringAfterLast(tagPrefix, "") if (href.isEmpty() || !keySet.add(href)) { return@mapNotNullToSet null } @@ -560,12 +560,12 @@ internal abstract class MadaraParser( } } - val alt = doc.body().select(selectAlt).firstOrNull()?.tableValue()?.text()?.trim() + val alt = doc.body().select(selectAlt).firstOrNull()?.tableValue()?.textOrNull() manga.copy( url = href, publicUrl = href.toAbsoluteUrl(domain), - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/all/Manga18Fx.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/all/Manga18Fx.kt index 1050bd89..e6f7c0c9 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/all/Manga18Fx.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/all/Manga18Fx.kt @@ -94,8 +94,8 @@ internal class Manga18Fx(context: MangaLoaderContext) : } MangaTag( key = href, - title = a.ownText().trim().ifEmpty { - a.selectFirst(".menu-image-title")?.text()?.trim() ?: return@mapNotNullToSet null + title = a.ownText().ifEmpty { + a.selectFirst(".menu-image-title")?.text() ?: return@mapNotNullToSet null }.toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/all/Manhwa18Cc.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/all/Manhwa18Cc.kt index f31b9dc6..713bf607 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/all/Manhwa18Cc.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/all/Manhwa18Cc.kt @@ -100,8 +100,8 @@ internal class Manhwa18Cc(context: MangaLoaderContext) : } MangaTag( key = href, - title = a.ownText().trim().ifEmpty { - a.selectFirst(".menu-image-title")?.text()?.trim() ?: return@mapNotNullToSet null + title = a.ownText().ifEmpty { + a.selectFirst(".menu-image-title")?.text() ?: return@mapNotNullToSet null }.toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/AdultWebtoon.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/AdultWebtoon.kt index 47601c57..0721c1f8 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/AdultWebtoon.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/AdultWebtoon.kt @@ -15,7 +15,7 @@ import org.koitharu.kotatsu.parsers.model.* import org.koitharu.kotatsu.parsers.site.madara.MadaraParser import org.koitharu.kotatsu.parsers.util.* import java.text.SimpleDateFormat -import java.util.Base64 +import java.util.* @MangaSourceParser("ADULT_WEBTOON", "AdultWebtoon", "en", ContentType.HENTAI) internal class AdultWebtoon(context: MangaLoaderContext) : @@ -106,11 +106,11 @@ internal class AdultWebtoon(context: MangaLoaderContext) : } val alt = - doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue()?.text() - ?.trim() + doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue() + ?.textOrNull() manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/HentaiManga.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/HentaiManga.kt index 0273dc49..40b1d2f6 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/HentaiManga.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/HentaiManga.kt @@ -100,13 +100,13 @@ internal class HentaiManga(context: MangaLoaderContext) : } val alt = - doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue()?.text() - ?.trim() + doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue() + ?.textOrNull() manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/HentaiWebtoon.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/HentaiWebtoon.kt index 97592467..a32c5ef7 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/HentaiWebtoon.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/HentaiWebtoon.kt @@ -100,13 +100,13 @@ internal class HentaiWebtoon(context: MangaLoaderContext) : } val alt = - doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue()?.text() - ?.trim() + doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue() + ?.textOrNull() manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/IsekaiScan.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/IsekaiScan.kt index 0d853c4b..f23b79c1 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/IsekaiScan.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/IsekaiScan.kt @@ -93,7 +93,7 @@ internal class IsekaiScan(context: MangaLoaderContext) : ) }.orEmpty(), author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(), - state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()?.trim() + state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText() ?.lowercase()) { "ongoing" -> MangaState.ONGOING "completed " -> MangaState.FINISHED diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaDass.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaDass.kt index fad44766..0cb703d2 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaDass.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaDass.kt @@ -123,12 +123,13 @@ internal class MangaDass(context: MangaLoaderContext) : } val alt = - doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue()?.text() - ?.trim() ?: doc.body().select(".post-content_item:contains(Nomes alternativos: ) .summary-content") - .firstOrNull()?.tableValue()?.text()?.trim() + doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue() + ?.textOrNull() + ?: doc.body().select(".post-content_item:contains(Nomes alternativos: ) .summary-content") + .firstOrNull()?.tableValue()?.textOrNull() manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaDna.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaDna.kt index 83254e9b..8dca01b6 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaDna.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaDna.kt @@ -116,14 +116,15 @@ internal class MangaDna(context: MangaLoaderContext) : } val alt = - doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue()?.text() - ?.trim() ?: doc.body().select(".post-content_item:contains(Nomes alternativos: ) .summary-content") - .firstOrNull()?.tableValue()?.text()?.trim() + doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue() + ?.textOrNull() + ?: doc.body().select(".post-content_item:contains(Nomes alternativos: ) .summary-content") + .firstOrNull()?.tableValue()?.textOrNull() manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaPure.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaPure.kt index f0207d7b..e31287b3 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaPure.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MangaPure.kt @@ -98,7 +98,7 @@ internal class MangaPure(context: MangaLoaderContext) : ) }.orEmpty(), author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(), - state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()?.trim() + state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText() ?.lowercase()) { "ongoing" -> MangaState.ONGOING "completed" -> MangaState.FINISHED diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/ManhwaHentai.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/ManhwaHentai.kt index 987f358a..c4e01928 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/ManhwaHentai.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/ManhwaHentai.kt @@ -54,12 +54,13 @@ internal class ManhwaHentai(context: MangaLoaderContext) : } val alt = - doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue()?.text() - ?.trim() ?: doc.body().select(".post-content_item:contains(Nomes alternativos: ) .summary-content") - .firstOrNull()?.tableValue()?.text()?.trim() + doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue() + ?.textOrNull() + ?: doc.body().select(".post-content_item:contains(Nomes alternativos: ) .summary-content") + .firstOrNull()?.tableValue()?.textOrNull() manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/ManyToon.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/ManyToon.kt index bc69bcb5..b2baebd4 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/ManyToon.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/ManyToon.kt @@ -103,11 +103,11 @@ internal class ManyToon(context: MangaLoaderContext) : } val alt = - doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue()?.text() - ?.trim() + doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue() + ?.textOrNull() manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/es/MangasNoSekai.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/es/MangasNoSekai.kt index e75bf214..324c54a2 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/es/MangasNoSekai.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/es/MangasNoSekai.kt @@ -6,12 +6,7 @@ import org.jsoup.nodes.Document import org.koitharu.kotatsu.parsers.MangaLoaderContext import org.koitharu.kotatsu.parsers.MangaSourceParser import org.koitharu.kotatsu.parsers.exception.ParseException -import org.koitharu.kotatsu.parsers.model.Manga -import org.koitharu.kotatsu.parsers.model.MangaChapter -import org.koitharu.kotatsu.parsers.model.MangaPage -import org.koitharu.kotatsu.parsers.model.MangaParserSource -import org.koitharu.kotatsu.parsers.model.MangaState -import org.koitharu.kotatsu.parsers.model.MangaTag +import org.koitharu.kotatsu.parsers.model.* import org.koitharu.kotatsu.parsers.site.madara.MadaraParser import org.koitharu.kotatsu.parsers.util.* import java.text.SimpleDateFormat @@ -26,9 +21,9 @@ internal class MangasNoSekai(context: MangaLoaderContext) : val body = doc.body() val chaptersDeferred = async { loadChapters(manga.url, doc) } manga.copy( - tags = doc.body().select("#section-sinopsis a[href*=genre]").mapNotNullToSet { a -> + tags = doc.body().select("#section-sinopsis a[href*=genre]").mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/id/ManhwaHub.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/id/ManhwaHub.kt index 34b3b304..5fe6d88a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/id/ManhwaHub.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/id/ManhwaHub.kt @@ -102,8 +102,8 @@ internal class ManhwaHub(context: MangaLoaderContext) : val href = a.attr("href").removeSuffix("/").substringAfterLast(tagPrefix, "") MangaTag( key = href, - title = a.ownText().trim().ifEmpty { - a.selectFirst(".menu-image-title")?.text()?.trim() ?: return@mapNotNullToSet null + title = a.ownText().ifEmpty { + a.selectFirst(".menu-image-title")?.text() ?: return@mapNotNullToSet null }.toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/Saytruyenhay.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/Saytruyenhay.kt index 7b6315e3..14b8692c 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/Saytruyenhay.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/vi/Saytruyenhay.kt @@ -139,14 +139,15 @@ internal class Saytruyenhay(context: MangaLoaderContext) : } val alt = - doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue()?.text() - ?.trim() ?: doc.body().select(".post-content_item:contains(Nomes alternativos: ) .summary-content") - .firstOrNull()?.tableValue()?.text()?.trim() + doc.body().select(".post-content_item:contains(Alt) .summary-content").firstOrNull()?.tableValue() + ?.textOrNull() + ?: doc.body().select(".post-content_item:contains(Nomes alternativos: ) .summary-content") + .firstOrNull()?.tableValue()?.textOrNull() manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast('/'), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madtheme/MadthemeParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madtheme/MadthemeParser.kt index 1790b7bf..8fd66c81 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madtheme/MadthemeParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madtheme/MadthemeParser.kt @@ -123,7 +123,7 @@ internal abstract class MadthemeParser( title = div.selectFirst("div.meta")?.selectFirst("div.title")?.text().orEmpty(), altTitle = null, rating = div.selectFirst("div.meta span.score")?.ownText()?.toFloatOrNull()?.div(5f) ?: RATING_UNKNOWN, - tags = doc.body().select("div.meta div.genres span").mapNotNullToSet { span -> + tags = doc.body().select("div.meta div.genres span").mapToSet { span -> MangaTag( key = span.attr("class"), title = span.text().toTitleCase(), @@ -179,7 +179,7 @@ internal abstract class MadthemeParser( val nsfw = doc.getElementById("adt-warning") != null manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase().replace(",", ""), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/manga18/Manga18Parser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/manga18/Manga18Parser.kt index e67cfee0..2eaa4d1f 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/manga18/Manga18Parser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/manga18/Manga18Parser.kt @@ -157,7 +157,7 @@ internal abstract class Manga18Parser( val alt = body.selectFirst(selectAlt)?.text().takeIf { it != "Updating" || it.isNotEmpty() } val author = body.selectFirst(selectAuthor)?.text().takeIf { it != "Updating" } manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/MangaboxParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/MangaboxParser.kt index 0ddbe2c8..894f1a11 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/MangaboxParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/MangaboxParser.kt @@ -144,7 +144,7 @@ internal abstract class MangaboxParser( protected open suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/$listUrl").parseHtml() val tags = doc.select(selectTagMap).drop(1) // remove all tags - return tags.mapNotNullToSet { a -> + return tags.mapToSet { a -> val key = a.attr("href").removeSuffix('/').substringAfterLast('/') val name = a.attr("title").replace(" Manga", "") MangaTag( @@ -177,7 +177,7 @@ internal abstract class MangaboxParser( val alt = doc.body().select(selectAlt).text().replace("Alternative : ", "") val aut = doc.body().select(selectAut).eachText().joinToString() manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast("category=").substringBefore("&"), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/Mangairo.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/Mangairo.kt index f10cc12a..a41df4ae 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/Mangairo.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/Mangairo.kt @@ -111,7 +111,7 @@ internal class Mangairo(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/$listUrl/type-latest/ctg-all/state-all/page-1").parseHtml() - return doc.select("div.panel_category a:not(.ctg_select)").mapNotNullToSet { a -> + return doc.select("div.panel_category a:not(.ctg_select)").mapToSet { a -> val key = a.attr("href").substringAfterLast("ctg-").substringBefore("/") val name = a.attr("title").replace("Category ", "") MangaTag( @@ -139,7 +139,7 @@ internal class Mangairo(context: MangaLoaderContext) : val alt = doc.body().select(selectAlt).text().replace("Alternative : ", "") val aut = doc.body().select(selectAut).eachText().joinToString() manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href") .substringAfterLast("page-"), // Yes the site, it's crashing between page is tag id diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/Mangakakalot.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/Mangakakalot.kt index 8b9285eb..8c77b79a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/Mangakakalot.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/Mangakakalot.kt @@ -101,7 +101,7 @@ internal class Mangakakalot(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/$listUrl").parseHtml() val tags = doc.select("ul.tag li a").drop(1) - return tags.mapNotNullToSet { a -> + return tags.mapToSet { a -> val key = a.attr("href").substringAfterLast("category=").substringBefore("&") val name = a.attr("title").replace(" Manga", "") MangaTag( diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/MangakakalotTv.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/MangakakalotTv.kt index 4941e55f..b3125d25 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/MangakakalotTv.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangabox/en/MangakakalotTv.kt @@ -111,7 +111,7 @@ internal class MangakakalotTv(context: MangaLoaderContext) : val alt = doc.body().select(selectAlt).text().replace("Alternative : ", "") val aut = doc.body().select(selectAut).eachText().joinToString() manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast("category=").substringBefore("&"), title = a.text().toTitleCase(), @@ -131,7 +131,7 @@ internal class MangakakalotTv(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/$listUrl").parseHtml() - return doc.select(selectTagMap).mapNotNullToSet { a -> + return doc.select(selectTagMap).mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast("category=").substringBefore("&"), title = a.attr("title"), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/es/TuManhwas.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/es/TuManhwas.kt index 33056dd8..db4de19f 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/es/TuManhwas.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/es/TuManhwas.kt @@ -95,7 +95,7 @@ internal class TuManhwas(context: MangaLoaderContext) : state = mangaState, author = null, isNsfw = manga.isNsfw || nsfw, - tags = docs.select(".wd-full .mgen > a").mapNotNullToSet { a -> + tags = docs.select(".wd-full .mgen > a").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('='), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangaworld/MangaWorldParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangaworld/MangaWorldParser.kt index 5aa9ffae..5c8e6661 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangaworld/MangaWorldParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangaworld/MangaWorldParser.kt @@ -143,7 +143,7 @@ internal abstract class MangaWorldParser( return doc.select(".comics-grid .entry").map { div -> val href = div.selectFirstOrThrow("a.thumb").attrAsRelativeUrl("href") val tags = div.select(".genres a[href*=/archive?genre=]") - .mapNotNullToSet { MangaTag(it.ownText().toTitleCase(sourceLocale), it.attr("href"), source) } + .mapToSet { MangaTag(it.ownText().toTitleCase(sourceLocale), it.attr("href"), source) } Manga( id = generateUid(href), url = href, @@ -155,13 +155,13 @@ internal abstract class MangaWorldParser( tags = tags, author = div.selectFirst(".author a")?.text(), state = - when (div.selectFirst(".status a")?.text()?.lowercase()) { - "in corso" -> MangaState.ONGOING - "finito" -> MangaState.FINISHED - "droppato" -> MangaState.ABANDONED - "in pausa" -> MangaState.PAUSED - else -> null - }, + when (div.selectFirst(".status a")?.text()?.lowercase()) { + "in corso" -> MangaState.ONGOING + "finito" -> MangaState.FINISHED + "droppato" -> MangaState.ABANDONED + "in pausa" -> MangaState.PAUSED + else -> null + }, source = source, isNsfw = isNsfwSource, ) @@ -171,7 +171,7 @@ internal abstract class MangaWorldParser( private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/").parseHtml() - return doc.select("div[aria-labelledby=genresDropdown] a").mapNotNullToSet { + return doc.select("div[aria-labelledby=genresDropdown] a").mapToSet { MangaTag( key = it.attr("href").substringAfterLast('='), title = it.text().toTitleCase(sourceLocale), @@ -184,30 +184,30 @@ internal abstract class MangaWorldParser( val doc = webClient.httpGet(manga.url.toAbsoluteUrl(domain)).parseHtml() return manga.copy( altTitle = - doc.selectFirst(".meta-data .font-weight-bold:contains(Titoli alternativi:)") - ?.parent() - ?.ownText() - ?.substringAfter(": ") - ?.trim(), + doc.selectFirst(".meta-data .font-weight-bold:contains(Titoli alternativi:)") + ?.parent() + ?.ownText() + ?.substringAfter(": ") + ?.trim(), description = doc.getElementById("noidungm")?.text().orEmpty(), chapters = - doc.select(".chapters-wrapper .chapter a").mapChapters(reversed = true) { i, a -> - val url = a.attrAsRelativeUrl("href").toAbsoluteUrl(domain) - MangaChapter( - id = generateUid(url), - name = a.selectFirst("span.d-inline-block")?.text() ?: "Chapter : ${i + 1f}", - number = i + 1f, - volume = 0, - url = "$url?style=list", - scanlator = null, - uploadDate = - SimpleDateFormat("dd MMMM yyyy", Locale.ITALIAN).tryParse( - a.selectFirst(".chap-date")?.text(), - ), - branch = null, - source = source, - ) - }, + doc.select(".chapters-wrapper .chapter a").mapChapters(reversed = true) { i, a -> + val url = a.attrAsRelativeUrl("href").toAbsoluteUrl(domain) + MangaChapter( + id = generateUid(url), + name = a.selectFirst("span.d-inline-block")?.text() ?: "Chapter : ${i + 1f}", + number = i + 1f, + volume = 0, + url = "$url?style=list", + scanlator = null, + uploadDate = + SimpleDateFormat("dd MMMM yyyy", Locale.ITALIAN).tryParse( + a.selectFirst(".chap-date")?.text(), + ), + branch = null, + source = source, + ) + }, ) } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mmrcms/MmrcmsParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mmrcms/MmrcmsParser.kt index b51207ee..41f0abf5 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mmrcms/MmrcmsParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mmrcms/MmrcmsParser.kt @@ -197,7 +197,7 @@ internal abstract class MmrcmsParser( val auth = doc.body().selectFirst(selectAut)?.nextElementSibling()?.text() val tags = doc.body().selectFirst(selectTag)?.nextElementSibling()?.select("a") ?: emptySet() manga.copy( - tags = tags.mapNotNullToSet { a -> + tags = tags.mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mmrcms/ar/Onma.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mmrcms/ar/Onma.kt index 814b7dd9..ce899000 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mmrcms/ar/Onma.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mmrcms/ar/Onma.kt @@ -59,7 +59,7 @@ internal class Onma(context: MangaLoaderContext) : val auth = doc.body().selectFirst(selectAut)?.text() val tags = doc.body().selectFirst(selectTag)?.select("a") ?: emptySet() manga.copy( - tags = tags.mapNotNullToSet { a -> + tags = tags.mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/nepnep/NepnepParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/nepnep/NepnepParser.kt index 55514c30..525e3e55 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/nepnep/NepnepParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/nepnep/NepnepParser.kt @@ -201,7 +201,7 @@ internal abstract class NepnepParser( else -> null }, - tags = doc.select(".list-group-item:contains(Genre(s):) a").mapNotNullToSet { a -> + tags = doc.select(".list-group-item:contains(Genre(s):) a").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('='), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/otakusanctuary/OtakuSanctuaryParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/otakusanctuary/OtakuSanctuaryParser.kt index 7204f223..20753d36 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/otakusanctuary/OtakuSanctuaryParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/otakusanctuary/OtakuSanctuaryParser.kt @@ -127,8 +127,8 @@ internal abstract class OtakuSanctuaryParser( private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/Home/LoadingGenresMenu").parseHtml() - return doc.select(selectBodyTag).mapNotNullToSet { a -> - val href = a.attr("href").substringAfterLast("/").substringBefore("?") + return doc.select(selectBodyTag).mapToSet { a -> + val href = a.attr("href").substringAfterLast('/').substringBefore('?') MangaTag( key = href, title = a.text(), @@ -165,8 +165,8 @@ internal abstract class OtakuSanctuaryParser( val dateFormat = SimpleDateFormat(datePattern, sourceLocale) manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> - val href = a.attr("href").substringAfterLast("/").substringBefore("?") + tags = doc.body().select(selectTag).mapToSet { a -> + val href = a.attr("href").substringAfterLast('/').substringBefore('?') MangaTag( key = href, title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/BrMangas.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/BrMangas.kt index 6a45cc7c..b58c3e13 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/BrMangas.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/BrMangas.kt @@ -110,7 +110,7 @@ internal class BrMangas(context: MangaLoaderContext) : PagedMangaParser(context, private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/lista-de-generos-de-manga/").parseHtml() - return doc.select(".genres_page a").mapNotNullToSet { a -> + return doc.select(".genres_page a").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text(), @@ -124,7 +124,7 @@ internal class BrMangas(context: MangaLoaderContext) : PagedMangaParser(context, return manga.copy( altTitle = null, state = null, - tags = doc.select("div.serie-infos li:contains(Categorias:) a").mapNotNullToSet { a -> + tags = doc.select("div.serie-infos li:contains(Categorias:) a").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/LerManga.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/LerManga.kt index e6b82061..0bba5038 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/LerManga.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/LerManga.kt @@ -103,9 +103,9 @@ internal class LerManga(context: MangaLoaderContext) : PagedMangaParser(context, private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml().requireElementById("menu-header") - return doc.select("#menu-item:contains(GÊNERO) ul li a").mapNotNullToSet { a -> + return doc.select("#menu-item:contains(GÊNERO) ul li a").mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast("/"), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text(), source = source, ) @@ -117,9 +117,9 @@ internal class LerManga(context: MangaLoaderContext) : PagedMangaParser(context, val dateFormat = SimpleDateFormat("dd-MM-yyyy", sourceLocale) return manga.copy( description = doc.selectFirstOrThrow("div.boxAnimeSobreLast p").html(), - tags = doc.selectFirst("ul.genre-list")?.select("li a")?.mapNotNullToSet { a -> + tags = doc.selectFirst("ul.genre-list")?.select("li a")?.mapToSet { a -> MangaTag( - key = a.attr("href").removeSuffix("/").substringAfterLast("/"), + key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text(), source = source, ) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/LerMangaOnline.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/LerMangaOnline.kt index dd103ffd..c11f2fd1 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/LerMangaOnline.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/LerMangaOnline.kt @@ -92,7 +92,7 @@ internal class LerMangaOnline(context: MangaLoaderContext) : private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/").parseHtml().requireElementById("sub-menu") - return doc.select("ul.container li a").mapNotNullToSet { a -> + return doc.select("ul.container li a").mapToSet { a -> MangaTag( key = a.attr("href").removePrefix("/"), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/MangaOnline.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/MangaOnline.kt index 9219a4cd..f11ab9a6 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/MangaOnline.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/MangaOnline.kt @@ -84,7 +84,7 @@ internal class MangaOnline(context: MangaLoaderContext) : PagedMangaParser(conte private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/generos/").parseHtml() - return doc.select(".wp-content p a").mapNotNullToSet { a -> + return doc.select(".wp-content p a").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast("/", ""), title = a.text(), @@ -98,7 +98,7 @@ internal class MangaOnline(context: MangaLoaderContext) : PagedMangaParser(conte val dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.ROOT) return manga.copy( description = doc.selectLast(".data p")?.html(), - tags = doc.selectFirst(".sgeneros")?.select("a")?.mapNotNullToSet { a -> + tags = doc.selectFirst(".sgeneros")?.select("a")?.mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast("/", ""), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/MuitoHentai.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/MuitoHentai.kt index 1d3c1ee7..49d5282e 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/MuitoHentai.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/pt/MuitoHentai.kt @@ -79,7 +79,7 @@ internal class MuitoHentai(context: MangaLoaderContext) : PagedMangaParser(conte private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/generos-dos-mangas/").parseHtml() - return doc.select("div.content a.profileSideBar").mapNotNullToSet { a -> + return doc.select("div.content a.profileSideBar").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast("/"), title = a.text(), @@ -92,7 +92,7 @@ internal class MuitoHentai(context: MangaLoaderContext) : PagedMangaParser(conte val doc = webClient.httpGet(manga.url.toAbsoluteUrl(domain)).parseHtml() return manga.copy( description = doc.selectFirstOrThrow(".backgroundpost:contains(Sinopse)").html(), - tags = doc.select("a.genero_btn").mapNotNullToSet { a -> + tags = doc.select("a.genero_btn").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast("/"), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/GroupleParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/GroupleParser.kt index 46cb5b7e..a94400fe 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/GroupleParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/GroupleParser.kt @@ -493,7 +493,7 @@ internal abstract class GroupleParser( ?: throw ParseException("Genres filter element not found", url) val result = MutableScatterMap(properties.size) properties.forEach { li -> - val name = li.text().trim().lowercase() + val name = li.text().lowercase() val id = li.selectFirstOrThrow("input").id() result[name] = id } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/multichan/YaoiChanParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/multichan/YaoiChanParser.kt index 8eb2c5d3..10cae236 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/multichan/YaoiChanParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/multichan/YaoiChanParser.kt @@ -33,7 +33,7 @@ internal class YaoiChanParser(context: MangaLoaderContext) : ChanParser(context, val href = a.attrAsRelativeUrl("href") MangaChapter( id = generateUid(href), - name = a.text().trim(), + name = a.text(), number = i + 1f, volume = 0, url = href, diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/sinmh/SinmhParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/sinmh/SinmhParser.kt index 38ad8366..28a1eccf 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/sinmh/SinmhParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/sinmh/SinmhParser.kt @@ -125,7 +125,7 @@ internal abstract class SinmhParser( private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/$listUrl").parseHtml() - return doc.select(".filter-item:contains(按剧情) li a:not(.active)").mapNotNullToSet { a -> + return doc.select(".filter-item:contains(按剧情) li a:not(.active)").mapToSet { a -> val href = a.attr("href").removeSuffix('/').substringAfterLast('/') MangaTag( key = href, @@ -152,7 +152,7 @@ internal abstract class SinmhParser( } } manga.copy( - tags = doc.body().select(selectGenre).mapNotNullToSet { a -> + tags = doc.body().select(selectGenre).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/tr/TrWebtoon.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/tr/TrWebtoon.kt index e3035964..50ed1f46 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/tr/TrWebtoon.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/tr/TrWebtoon.kt @@ -150,7 +150,7 @@ internal class TrWebtoon(context: MangaLoaderContext) : val tags = webClient.httpGet("https://$domain/webtoon-listesi").parseHtml().requireElementById("collapseExample") .select(".pt-12 a").drop(1) - return tags.mapNotNullToSet { a -> + return tags.mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast("genre=").substringBefore("&sort"), title = a.text(), @@ -162,7 +162,7 @@ internal class TrWebtoon(context: MangaLoaderContext) : override suspend fun getDetails(manga: Manga): Manga { val doc = webClient.httpGet(manga.url.toAbsoluteUrl(domain)).parseHtml() return manga.copy( - tags = doc.body().select("li.movie__year a").mapNotNullToSet { a -> + tags = doc.body().select("li.movie__year a").mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast('='), title = a.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/BlogTruyenParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/BlogTruyenParser.kt index a806b177..b6ea6895 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/BlogTruyenParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/BlogTruyenParser.kt @@ -120,7 +120,7 @@ internal class BlogTruyenParser(context: MangaLoaderContext) : val tagMap = availableTags().associateBy { it.title } val tags = descriptionElement.select("p > span.category").mapNotNullToSet { - val tagName = it.selectFirst("a")?.text()?.trim() ?: return@mapNotNullToSet null + val tagName = it.selectFirst("a")?.textOrNull() ?: return@mapNotNullToSet null tagMap[tagName] } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/BlogTruyenVN.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/BlogTruyenVN.kt index da1b5fbb..87fb7ce7 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/BlogTruyenVN.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/BlogTruyenVN.kt @@ -135,8 +135,8 @@ internal class BlogTruyenVN(context: MangaLoaderContext) : val tagItems = doc.select("li[data-id]") val tagMap = ArrayMap(tagItems.size) for (tag in tagItems) { - val title = tag.text().trim() - tagMap[tag.text().trim()] = MangaTag( + val title = tag.text() + tagMap[title] = MangaTag( title = title, key = tag.attr("data-id"), source = source, @@ -173,7 +173,7 @@ internal class BlogTruyenVN(context: MangaLoaderContext) : val tags = cacheTags.getOrNull()?.let { tagMap -> descriptionElement.select("p > span.category").mapNotNullToSet { - val tagName = it.selectFirst("a")?.text()?.trim() ?: return@mapNotNullToSet null + val tagName = it.selectFirst("a")?.textOrNull() ?: return@mapNotNullToSet null tagMap[tagName] } } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/HentaiVNParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/HentaiVNParser.kt index 7485f7fe..5c986048 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/HentaiVNParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/HentaiVNParser.kt @@ -122,8 +122,8 @@ internal class HentaiVNParser(context: MangaLoaderContext) : MangaParser(context } }, rating = docs.selectFirst("div.page_like")?.let { - val like = it.selectFirst("div.but_like")?.text()?.trim()?.toIntOrNull() ?: return@let null - val dislike = it.selectFirst("div.but_unlike")?.text()?.trim()?.toIntOrNull() ?: return@let null + val like = it.selectFirst("div.but_like")?.text()?.toIntOrNull() ?: return@let null + val dislike = it.selectFirst("div.but_unlike")?.text()?.toIntOrNull() ?: return@let null when { like == 0 && dislike == 0 -> RATING_UNKNOWN else -> like.toFloat() / (like + dislike) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/TruyenQQ.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/TruyenQQ.kt index dec7601a..056b79cd 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/TruyenQQ.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/TruyenQQ.kt @@ -4,8 +4,8 @@ import org.koitharu.kotatsu.parsers.MangaLoaderContext import org.koitharu.kotatsu.parsers.MangaSourceParser import org.koitharu.kotatsu.parsers.PagedMangaParser import org.koitharu.kotatsu.parsers.config.ConfigKey -import org.koitharu.kotatsu.parsers.network.UserAgents import org.koitharu.kotatsu.parsers.model.* +import org.koitharu.kotatsu.parsers.network.UserAgents import org.koitharu.kotatsu.parsers.util.* import java.text.SimpleDateFormat import java.util.* @@ -146,7 +146,7 @@ internal class TruyenQQ(context: MangaLoaderContext) : PagedMangaParser(context, private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/tim-kiem-nang-cao.html").parseHtml() - return doc.select(".advsearch-form div.genre-item").mapNotNullToSet { + return doc.select(".advsearch-form div.genre-item").mapToSet { MangaTag( key = it.selectFirstOrThrow("span").attr("data-id"), title = it.text(), @@ -160,7 +160,7 @@ internal class TruyenQQ(context: MangaLoaderContext) : PagedMangaParser(context, val dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH) return manga.copy( altTitle = doc.selectFirst("h2.other-name")?.text(), - tags = doc.select("ul.list01 li").mapNotNullToSet { + tags = doc.select("ul.list01 li").mapToSet { val key = it.attr("href").substringAfterLast("-").substringBeforeLast(".") MangaTag( key = key, diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vmp/VmpParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vmp/VmpParser.kt index 3989b25a..afe57c31 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vmp/VmpParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vmp/VmpParser.kt @@ -98,7 +98,7 @@ internal abstract class VmpParser( private suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/$listUrl").parseHtml() - return doc.select("div.tagcloud a").mapNotNullToSet { a -> + return doc.select("div.tagcloud a").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast(geneUrl, ""), title = a.text().toTitleCase(), @@ -112,7 +112,7 @@ internal abstract class VmpParser( val doc = webClient.httpGet(fullUrl).parseHtml() manga.copy( - tags = doc.select("div.tax_box div.links ul:not(.post-categories) li a").mapNotNullToSet { a -> + tags = doc.select("div.tax_box div.links ul:not(.post-categories) li a").mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix("/").substringAfterLast(geneUrl, ""), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/en/XoxoComics.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/en/XoxoComics.kt index d218fa33..b9d0cd4c 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/en/XoxoComics.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/en/XoxoComics.kt @@ -130,7 +130,7 @@ internal class XoxoComics(context: MangaLoaderContext) : } val aut = doc.body().select(selectAut).text() manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ZeistMangaParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ZeistMangaParser.kt index 54552b43..6548aa31 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ZeistMangaParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ZeistMangaParser.kt @@ -185,7 +185,7 @@ internal abstract class ZeistMangaParser( protected open suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.selectFirstOrThrow("div.filter").select("ul li").mapNotNullToSet { + return doc.selectFirstOrThrow("div.filter").select("ul li").mapToSet { MangaTag( key = it.selectFirstOrThrow("input").attr("value"), title = it.selectFirstOrThrow("label").text().toTitleCase(sourceLocale), @@ -225,7 +225,7 @@ internal abstract class ZeistMangaParser( val chaptersDeferred = async { loadChapters(manga.url, doc) } manga.copy( author = author?.text(), - tags = doc.select(selectTags).mapNotNullToSet { a -> + tags = doc.select(selectTags).mapToSet { a -> MangaTag( key = a.attr("href").substringAfterLast("label/").substringBefore("?"), title = a.text().toTitleCase(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ar/MangaAiLand.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ar/MangaAiLand.kt index 57fa20aa..d70ba7b8 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ar/MangaAiLand.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ar/MangaAiLand.kt @@ -6,7 +6,7 @@ import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.site.zeistmanga.ZeistMangaParser import org.koitharu.kotatsu.parsers.util.domain -import org.koitharu.kotatsu.parsers.util.mapNotNullToSet +import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.parseHtml import org.koitharu.kotatsu.parsers.util.requireElementById @@ -19,7 +19,7 @@ internal class MangaAiLand(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.requireElementById("LinkList1").select("ul li a").mapNotNullToSet { + return doc.requireElementById("LinkList1").select("ul li a").mapToSet { MangaTag( key = it.attr("href").substringBefore("?").substringAfterLast('/'), title = it.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ar/MangaHub.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ar/MangaHub.kt index 0531544e..ea46f9e8 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ar/MangaHub.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/ar/MangaHub.kt @@ -23,7 +23,7 @@ internal class MangaHub(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.requireElementById("Genre").select("div.items-center").mapNotNullToSet { + return doc.requireElementById("Genre").select("div.items-center").mapToSet { MangaTag( key = it.selectFirstOrThrow("input").attr("value"), title = it.selectFirstOrThrow("label").text().substringBefore(')').toTitleCase(sourceLocale), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/KlManhua.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/KlManhua.kt index 7d690171..1e9932a5 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/KlManhua.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/KlManhua.kt @@ -7,7 +7,7 @@ import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.site.zeistmanga.ZeistMangaParser import org.koitharu.kotatsu.parsers.util.domain -import org.koitharu.kotatsu.parsers.util.mapNotNullToSet +import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.parseHtml import org.koitharu.kotatsu.parsers.util.requireElementById @@ -17,7 +17,7 @@ internal class KlManhua(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.requireElementById("LinkList1").select("ul li a").mapNotNullToSet { + return doc.requireElementById("LinkList1").select("ul li a").mapToSet { MangaTag( key = it.attr("href").substringBefore("?").substringAfterLast('/'), title = it.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/Mikoroku.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/Mikoroku.kt index 9d370097..b5a0950a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/Mikoroku.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/Mikoroku.kt @@ -14,7 +14,7 @@ internal class Mikoroku(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.requireElementById("Genre").select("div.items-center").mapNotNullToSet { + return doc.requireElementById("Genre").select("div.items-center").mapToSet { MangaTag( key = it.selectFirstOrThrow("input").attr("value"), title = it.selectFirstOrThrow("label").text().substringBefore('('), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/ShiyuraSub.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/ShiyuraSub.kt index 69feebd1..cd3f95bb 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/ShiyuraSub.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/id/ShiyuraSub.kt @@ -6,7 +6,7 @@ import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.site.zeistmanga.ZeistMangaParser import org.koitharu.kotatsu.parsers.util.domain -import org.koitharu.kotatsu.parsers.util.mapNotNullToSet +import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.parseHtml @MangaSourceParser("SHIYURASUB", "ShiyuraSub", "id") @@ -17,7 +17,7 @@ internal class ShiyuraSub(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.select("div.list-label-widget-content ul li a").mapNotNullToSet { + return doc.select("div.list-label-widget-content ul li a").mapToSet { MangaTag( key = it.attr("href").removeSuffix("/").substringAfterLast('/'), title = it.html().substringBefore(" { val doc = webClient.httpGet("https://$domain/p/genre-list.html").parseHtml() - return doc.select(".dzdes-genre ul li a").mapNotNullToSet { + return doc.select(".dzdes-genre ul li a").mapToSet { MangaTag( key = it.attr("href").removeSuffix("/").substringAfterLast("/"), title = it.selectFirstOrThrow("span").text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/pt/AnimeXNovel.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/pt/AnimeXNovel.kt index 99a25337..65d39166 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/pt/AnimeXNovel.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/pt/AnimeXNovel.kt @@ -19,7 +19,7 @@ internal class AnimeXNovel(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.requireElementById("LinkList1").select("ul li a").mapNotNullToSet { + return doc.requireElementById("LinkList1").select("ul li a").mapToSet { MangaTag( key = it.attr("href").removeSuffix("/").substringAfterLast('/'), title = it.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/pt/GuildaTierDraw.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/pt/GuildaTierDraw.kt index 7d1a5776..f5258f04 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/pt/GuildaTierDraw.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/pt/GuildaTierDraw.kt @@ -6,7 +6,7 @@ import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.site.zeistmanga.ZeistMangaParser import org.koitharu.kotatsu.parsers.util.domain -import org.koitharu.kotatsu.parsers.util.mapNotNullToSet +import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.parseHtml import org.koitharu.kotatsu.parsers.util.requireElementById @@ -16,7 +16,7 @@ internal class GuildaTierDraw(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.requireElementById("LinkList2").select("ul li a").mapNotNullToSet { + return doc.requireElementById("LinkList2").select("ul li a").mapToSet { MangaTag( key = it.attr("href").substringBefore("?").substringAfterLast('/'), title = it.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/EpikMan.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/EpikMan.kt index df04089c..af431b59 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/EpikMan.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/EpikMan.kt @@ -6,7 +6,7 @@ import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.site.zeistmanga.ZeistMangaParser import org.koitharu.kotatsu.parsers.util.domain -import org.koitharu.kotatsu.parsers.util.mapNotNullToSet +import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.parseHtml import org.koitharu.kotatsu.parsers.util.requireElementById @@ -19,7 +19,7 @@ internal class EpikMan(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain").parseHtml() - return doc.requireElementById("LinkList1").select("ul li a").mapNotNullToSet { + return doc.requireElementById("LinkList1").select("ul li a").mapToSet { MangaTag( key = it.attr("href").substringBefore("?").substringAfterLast('/'), title = it.text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/Mikrokosmosfb.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/Mikrokosmosfb.kt index 03ffd999..909f5947 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/Mikrokosmosfb.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/Mikrokosmosfb.kt @@ -7,7 +7,7 @@ import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.site.zeistmanga.ZeistMangaParser import org.koitharu.kotatsu.parsers.util.domain -import org.koitharu.kotatsu.parsers.util.mapNotNullToSet +import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.parseHtml import org.koitharu.kotatsu.parsers.util.selectFirstOrThrow @@ -22,7 +22,7 @@ internal class Mikrokosmosfb(context: MangaLoaderContext) : val doc = webClient.httpGet("https://$domain").parseHtml() val tags = doc.selectFirstOrThrow("script:containsData(label: )").data() .substringAfter("label: [").substringBefore("]").replace("\"", "").split(", ") - return tags.mapNotNullToSet { + return tags.mapToSet { MangaTag( key = it, title = it, diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/SnscoeurTurkey.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/SnscoeurTurkey.kt index a5ad5d90..f018b9cb 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/SnscoeurTurkey.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zeistmanga/tr/SnscoeurTurkey.kt @@ -7,7 +7,7 @@ import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.site.zeistmanga.ZeistMangaParser import org.koitharu.kotatsu.parsers.util.domain -import org.koitharu.kotatsu.parsers.util.mapNotNullToSet +import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.parseHtml import org.koitharu.kotatsu.parsers.util.selectFirstOrThrow @@ -22,7 +22,7 @@ internal class SnscoeurTurkey(context: MangaLoaderContext) : override suspend fun fetchAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/p/gelismis-arama.html").parseHtml() - return doc.selectFirstOrThrow("div.filter").select("ul li").mapNotNullToSet { + return doc.selectFirstOrThrow("div.filter").select("ul li").mapToSet { MangaTag( key = it.selectFirstOrThrow("input").attr("value"), title = it.selectFirstOrThrow("label").text(), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zmanga/ZMangaParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zmanga/ZMangaParser.kt index db6512d0..2c36b2a1 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zmanga/ZMangaParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/zmanga/ZMangaParser.kt @@ -168,7 +168,7 @@ internal abstract class ZMangaParser( altTitle = null, rating = div.selectFirstOrThrow("div.info div.score").ownText().toFloatOrNull()?.div(10f) ?: RATING_UNKNOWN, - tags = doc.body().select("div.genres a").mapNotNullToSet { span -> + tags = doc.body().select("div.genres a").mapToSet { span -> MangaTag( key = span.attr("class"), title = span.text().toTitleCase(), @@ -225,7 +225,7 @@ internal abstract class ZMangaParser( val aut = doc.body().select(selectAut).text() manga.copy( - tags = doc.body().select(selectTag).mapNotNullToSet { a -> + tags = doc.body().select(selectTag).mapToSet { a -> MangaTag( key = a.attr("href").removeSuffix('/').substringAfterLast('/'), title = a.text().toTitleCase().replace(",", ""), diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/util/Collection.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/util/Collection.kt index 03013deb..2b63f76a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/util/Collection.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/util/Collection.kt @@ -27,7 +27,7 @@ public inline fun Collection.mapToSet(transform: (T) -> R): Set { return mapTo(ArraySet(size), transform) } -public inline fun Collection.mapNotNullToSet(transform: (T) -> R?): Set { +public inline fun Collection.mapNotNullToSet(transform: (T) -> R?): Set { val destination = ArraySet(size) for (item in this) { destination.add(transform(item) ?: continue)