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