[MangaInUa] Fix chapters parsing
This commit is contained in:
@@ -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(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <T, K> Collection<T>.maxDuplicates(selector: (T) -> K): K? {
|
||||
inline operator fun <T> List<T>.component6(): T = get(5)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline operator fun <T> List<T>.component7(): T = get(6)
|
||||
inline operator fun <T> List<T>.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,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user