Improve E-H/Exh toplist support

This commit is contained in:
Jobobby04 2022-11-16 14:17:43 -05:00
parent c8de918e46
commit 123afa7753

View File

@ -488,12 +488,20 @@ class EHentai(
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val uri = baseUrl.toUri().buildUpon()
val toplist = ToplistOption.values()[filters.firstNotNullOfOrNull { (it as? ToplistOptions)?.state } ?: 0]
if (toplist != ToplistOption.NONE) {
val uri = "https://e-hentai.org".toUri().buildUpon()
uri.appendPath("toplist.php")
uri.appendQueryParameter("tl", toplist.index.toString())
uri.appendQueryParameter("p", (page - 1).toString())
return exGet(url = uri.toString())
}
val uri = baseUrl.toUri().buildUpon()
val isReverseFilterEnabled = filters.any { it is ReverseFilter && it.state }
val jumpSeekValue = filters.firstNotNullOfOrNull { (it as? JumpSeekFilter)?.state?.nullIfBlank() }
if (toplist == ToplistOption.NONE) {
uri.appendQueryParameter("f_apply", "Apply+Filter")
uri.appendQueryParameter("f_search", (query + " " + combineQuery(filters)).trim())
filters.forEach {
@ -513,22 +521,11 @@ class EHentai(
uri.appendQueryParameter("jump", jumpSeekValue)
}
}
} else {
uri.appendPath("toplist.php")
uri.appendQueryParameter("tl", toplist.index.toString())
uri.appendQueryParameter("p", (page - 1).toString())
}
val regularPage = if (toplist == ToplistOption.NONE) {
page
} else {
null
}
return exGet(
url = uri.toString(),
next = if (!isReverseFilterEnabled) regularPage else null,
prev = if (isReverseFilterEnabled) regularPage else null,
next = if (!isReverseFilterEnabled) page else null,
prev = if (isReverseFilterEnabled) page else null,
)
}
@ -885,15 +882,9 @@ class EHentai(
// Filters
override fun getFilterList(): FilterList {
return FilterList(
*if (exh) {
emptyArray()
} else {
arrayOf(
Filter.Header("Note: Will ignore other parameters!"),
ToplistOptions(),
Filter.Separator(),
)
},
AutoCompleteTags(),
Watched(isEnabled = preferences.exhWatchedListDefaultState().get()),
GenreGroup(),