[ExHentai] Improvements
This commit is contained in:
@@ -59,6 +59,10 @@ public abstract class AbstractMangaParser @InternalParsersApi constructor(
|
||||
@JvmField
|
||||
protected val webClient: WebClient = OkHttpWebClient(context.httpClient, source)
|
||||
|
||||
@Deprecated("Please check searchQueryCapabilities")
|
||||
final override val filterCapabilities: MangaListFilterCapabilities
|
||||
get() = super.filterCapabilities
|
||||
|
||||
/**
|
||||
* Fetch direct link to the page image.
|
||||
*/
|
||||
|
||||
@@ -49,6 +49,8 @@ internal class ExHentaiParser(
|
||||
get() = "https://${domain}/bounce_login.php"
|
||||
|
||||
private val ratingPattern = Regex("-?[0-9]+px")
|
||||
private val titleCleanupPattern = Regex("(\\[.*?]|\\([C0-9]*\\))")
|
||||
private val spacesCleanupPattern = Regex("(^\\s+|\\s+\$|\\s+(?=\\s))")
|
||||
private val authCookies = arrayOf("ipb_member_id", "ipb_pass_hash")
|
||||
private val nextPages = SparseArrayCompat<Long>()
|
||||
private val suspiciousContentKey = ConfigKey.ShowSuspiciousContent(false)
|
||||
@@ -350,6 +352,15 @@ internal class ExHentaiParser(
|
||||
keys.add(suspiciousContentKey)
|
||||
}
|
||||
|
||||
override suspend fun getRelatedManga(seed: Manga): List<Manga> {
|
||||
val query = seed.title
|
||||
return getListPage(
|
||||
page = 0,
|
||||
order = defaultSortOrder,
|
||||
filter = MangaListFilter(query = query),
|
||||
)
|
||||
}
|
||||
|
||||
private fun isAuthorized(domain: String): Boolean {
|
||||
val cookies = context.cookieJar.getCookies(domain).mapToSet { x -> x.name }
|
||||
return authCookies.all { it in cookies }
|
||||
@@ -369,20 +380,8 @@ internal class ExHentaiParser(
|
||||
}
|
||||
|
||||
private fun String.cleanupTitle(): String {
|
||||
val result = StringBuilder(length)
|
||||
var skip = false
|
||||
for (c in this) {
|
||||
when {
|
||||
c == '[' -> skip = true
|
||||
c == ']' -> skip = false
|
||||
c.isWhitespace() && result.isEmpty() -> continue
|
||||
!skip -> result.append(c)
|
||||
}
|
||||
}
|
||||
while (result.lastOrNull()?.isWhitespace() == true) {
|
||||
result.deleteCharAt(result.lastIndex)
|
||||
}
|
||||
return result.toString()
|
||||
return replace(titleCleanupPattern, "")
|
||||
.replace(spacesCleanupPattern, "")
|
||||
}
|
||||
|
||||
private fun Element.parseTags(): Set<MangaTag> {
|
||||
|
||||
@@ -2,10 +2,10 @@ package org.koitharu.kotatsu.parsers.util
|
||||
|
||||
import okhttp3.HttpUrl
|
||||
import org.jsoup.nodes.Element
|
||||
import org.koitharu.kotatsu.parsers.core.LegacyMangaParser
|
||||
import org.koitharu.kotatsu.parsers.ErrorMessages
|
||||
import org.koitharu.kotatsu.parsers.InternalParsersApi
|
||||
import org.koitharu.kotatsu.parsers.MangaParser
|
||||
import org.koitharu.kotatsu.parsers.core.LegacyMangaParser
|
||||
import org.koitharu.kotatsu.parsers.exception.ParseException
|
||||
import org.koitharu.kotatsu.parsers.model.*
|
||||
|
||||
@@ -82,9 +82,6 @@ private fun <T> Set<T>?.oneOrThrowIfMany(msg: String): T? = when {
|
||||
else -> throw IllegalArgumentException(msg)
|
||||
}
|
||||
|
||||
public val LegacyMangaParser.domain: String
|
||||
get() = config[configKeyDomain]
|
||||
|
||||
@InternalParsersApi
|
||||
public fun LegacyMangaParser.getDomain(subdomain: String): String {
|
||||
val domain = domain
|
||||
@@ -92,7 +89,7 @@ public fun LegacyMangaParser.getDomain(subdomain: String): String {
|
||||
}
|
||||
|
||||
@InternalParsersApi
|
||||
public fun LegacyMangaParser.urlBuilder(subdomain: String? = null): HttpUrl.Builder {
|
||||
public fun MangaParser.urlBuilder(subdomain: String? = null): HttpUrl.Builder {
|
||||
return HttpUrl.Builder()
|
||||
.scheme(SCHEME_HTTPS)
|
||||
.host(if (subdomain == null) domain else "$subdomain.$domain")
|
||||
|
||||
@@ -27,7 +27,7 @@ public class RelatedMangaFinder(
|
||||
private suspend fun findRelatedImpl(scope: CoroutineScope, parser: MangaParser, seed: Manga): List<Manga> {
|
||||
val words = HashSet<String>()
|
||||
words += seed.title.splitByWhitespace()
|
||||
seed.altTitle?.let {
|
||||
seed.altTitles.forEach {
|
||||
words += it.splitByWhitespace()
|
||||
}
|
||||
if (words.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user