diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/MangaInUaParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/MangaInUaParser.kt index caf50c450..71db3c94a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/MangaInUaParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/MangaInUaParser.kt @@ -81,14 +81,16 @@ class MangaInUaParser(override val context: MangaLoaderContext) : MangaParser(Ma val root = doc.body().getElementById("dle-content") ?: parseFailed("Cannot find root") val dateFormat = SimpleDateFormat("dd.MM.yyyy", Locale.US) - val chaptersRoot = root.selectFirst(".linkstocomics") + val chapterNodes = root.selectFirstOrThrow(".linkstocomics") + .select(".ltcitems") + .filterNot { x -> x.selectFirst(".foruserreadedbar") != null } var prevChapterName: String? = null var i = 0 return manga.copy( description = root.selectFirst("div.item__full-description")?.text(), largeCoverUrl = root.selectFirst("div.item__full-sidebar--poster")?.selectFirst("img") ?.attrAsAbsoluteUrlOrNull("src"), - chapters = chaptersRoot?.select("div.ltcitems")?.mapNotNull { item -> + chapters = chapterNodes.mapNotNull { item -> val href = item?.selectFirst("a")?.attrAsRelativeUrlOrNull("href") ?: return@mapNotNull null val isAlternative = item.styleValueOrNull("background") != null @@ -113,7 +115,7 @@ class MangaInUaParser(override val context: MangaLoaderContext) : MangaParser(Ma uploadDate = dateFormat.tryParse(item.selectFirst("div.ltcright")?.text()), source = source, ) - }.orEmpty(), + }, ) } diff --git a/src/test/kotlin/org/koitharu/kotatsu/test_util/Util.kt b/src/test/kotlin/org/koitharu/kotatsu/test_util/Util.kt index f31c27772..8e41abdde 100644 --- a/src/test/kotlin/org/koitharu/kotatsu/test_util/Util.kt +++ b/src/test/kotlin/org/koitharu/kotatsu/test_util/Util.kt @@ -1,6 +1,11 @@ package org.koitharu.kotatsu.test_util import androidx.collection.ArraySet +import okhttp3.HttpUrl.Companion.toHttpUrl +import org.koitharu.kotatsu.parsers.model.Manga +import org.koitharu.kotatsu.parsers.model.MangaSource +import org.koitharu.kotatsu.parsers.model.RATING_UNKNOWN +import org.koitharu.kotatsu.parsers.util.toRelativeUrl private val PATTERN_URL_ABSOLUTE = Regex("^https?://[\\s\\S]+", setOf(RegexOption.IGNORE_CASE)) private val PATTERN_URL_RELATIVE = Regex("^/[\\s\\S]+", setOf(RegexOption.IGNORE_CASE)) @@ -36,4 +41,28 @@ internal inline fun Collection.maxDuplicates(selector: (T) -> K): K? { inline operator fun List.component6(): T = get(5) @Suppress("NOTHING_TO_INLINE") -inline operator fun List.component7(): T = get(6) \ No newline at end of file +inline operator fun List.component7(): T = get(6) + +fun mangaOf(source: MangaSource, url: String): Manga { + val httpUrl = url.toHttpUrl() + var id = 1125899906842597L + source.name.forEach { c -> id = 31 * id + c.code } + url.forEach { c -> id = 31 * id + c.code } + return Manga( + id = id, + title = httpUrl.pathSegments.last(), + altTitle = null, + url = url.toRelativeUrl(httpUrl.host), + publicUrl = url, + rating = RATING_UNKNOWN, + isNsfw = false, + coverUrl = "", + tags = emptySet(), + state = null, + author = null, + largeCoverUrl = null, + description = null, + chapters = null, + source = source, + ) +} \ No newline at end of file