Fix Mangaowl search url building (#8570)

* Fix search url building

* Update version
This commit is contained in:
Arraiment 2021-08-16 18:10:07 +08:00 committed by GitHub
parent cce0c70265
commit 5edfbb5354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 14 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaOwl'
pkgNameSuffix = 'en.mangaowl'
extClass = '.MangaOwl'
extVersionCode = 21
extVersionCode = 22
libVersion = '1.2'
}

View File

@ -90,13 +90,18 @@ class MangaOwl : ParsedHttpSource() {
filters.forEach { filter ->
when (filter) {
is SearchFilter -> url.addQueryParameter("search_field", filter.toUriPart())
is SearchFieldFilter -> {
val fields = filter.state
.filter { it.state }
.joinToString("") { it.uriPart }
url.addQueryParameter("search_field", fields)
}
is SortFilter -> url.addQueryParameter("sort", filter.toUriPart())
is StatusFilter -> url.addQueryParameter("completed", filter.toUriPart())
is GenreFilter -> {
val genres = filter.state
.filter { it.state }
.joinToString(".") { it.uriPart }
.joinToString(",") { it.uriPart }
url.addQueryParameter("genres", genres)
}
is MinChapterFilter -> url.addQueryParameter("chapter_from", filter.state)
@ -181,7 +186,7 @@ class MangaOwl : ParsedHttpSource() {
// Filters
override fun getFilterList() = FilterList(
SearchFilter(),
SearchFieldFilter(getSearchFields()),
SortFilter(),
StatusFilter(),
GenreFilter(getGenreList()),
@ -196,16 +201,6 @@ class MangaOwl : ParsedHttpSource() {
fun toUriPart() = vals[state].second
}
private class SearchFilter : UriPartFilter(
"Search in",
arrayOf(
Pair("Manga title", "1"),
Pair("Authors", "2"),
Pair("Description", "3"),
Pair("All", "123")
)
)
private class SortFilter : UriPartFilter(
"Sort by",
arrayOf(
@ -339,6 +334,15 @@ class MangaOwl : ParsedHttpSource() {
Genre("Zombies", "108")
)
private class SearchField(name: String, state: Boolean, val uriPart: String) : Filter.CheckBox(name, state)
private class SearchFieldFilter(fields: List<SearchField>) : Filter.Group<SearchField>("Search in", fields)
private fun getSearchFields() = listOf(
SearchField("Manga title", true, "1"),
SearchField("Authors", true, "2"),
SearchField("Description", false, "3")
)
private class MinChapterFilter : Filter.Text("Minimum Chapters")
private class MaxChapterFilter : Filter.Text("Maximum Chapters")
}