Mangahere - fix genre search (#3380)

This commit is contained in:
Mike 2020-06-02 04:47:59 -04:00 committed by GitHub
parent 179912d2ed
commit 311cef70fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 35 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Mangahere' appName = 'Tachiyomi: Mangahere'
pkgNameSuffix = 'en.mangahere' pkgNameSuffix = 'en.mangahere'
extClass = '.Mangahere' extClass = '.Mangahere'
extVersionCode = 14 extVersionCode = 15
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -83,44 +83,40 @@ class Mangahere : ParsedHttpSource() {
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val url = HttpUrl.parse("$baseUrl/search")!!.newBuilder() val url = HttpUrl.parse("$baseUrl/search")!!.newBuilder()
filters.forEach { filters.forEach { filter ->
when (it) { when (filter) {
is TypeList -> url.addEncodedQueryParameter("type", types[filter.values[filter.state]].toString())
is TypeList -> { is CompletionList -> url.addEncodedQueryParameter("st", filter.state.toString())
url.addEncodedQueryParameter("type", types[it.values[it.state]].toString())
}
is CompletionList -> url.addEncodedQueryParameter("st", it.state.toString())
is GenreList -> { is GenreList -> {
val includeGenres = mutableSetOf<Int>()
val genreFilter = filters.find { filter -> filter is GenreList } as GenreList? val excludeGenres = mutableSetOf<Int>()
val includeGenres = ArrayList<Int>() filter.state.forEach { genre ->
val excludeGenres = ArrayList<Int>() if (genre.isIncluded()) includeGenres.add(genre.id)
genreFilter?.state?.forEach { genre -> if (genre.isExcluded()) excludeGenres.add(genre.id)
if (genre.isIncluded()) }
includeGenres.add(genre.id) url.apply {
else if (genre.isExcluded()) addEncodedQueryParameter("genres", includeGenres.joinToString(","))
excludeGenres.add(genre.id) addEncodedQueryParameter("nogenres", excludeGenres.joinToString(","))
} }
url.addEncodedQueryParameter("genres", includeGenres.joinToString(","))
.addEncodedQueryParameter("nogenres", excludeGenres.joinToString(","))
} }
} }
} }
url.addEncodedQueryParameter("page", page.toString()) url.apply {
.addEncodedQueryParameter("title", query) addEncodedQueryParameter("page", page.toString())
.addEncodedQueryParameter("sort", null) addEncodedQueryParameter("title", query)
.addEncodedQueryParameter("stype", 1.toString()) addEncodedQueryParameter("sort", null)
.addEncodedQueryParameter("name", null) addEncodedQueryParameter("stype", 1.toString())
.addEncodedQueryParameter("author_method", "cw") addEncodedQueryParameter("name", null)
.addEncodedQueryParameter("author", null) addEncodedQueryParameter("author_method", "cw")
.addEncodedQueryParameter("artist_method", "cw") addEncodedQueryParameter("author", null)
.addEncodedQueryParameter("artist", null) addEncodedQueryParameter("artist_method", "cw")
.addEncodedQueryParameter("rating_method", "eq") addEncodedQueryParameter("artist", null)
.addEncodedQueryParameter("rating", null) addEncodedQueryParameter("rating_method", "eq")
.addEncodedQueryParameter("released_method", "eq") addEncodedQueryParameter("rating", null)
.addEncodedQueryParameter("released", null) addEncodedQueryParameter("released_method", "eq")
addEncodedQueryParameter("released", null)
}
return GET(url.toString(), headers) return GET(url.toString(), headers)
} }
@ -318,7 +314,7 @@ class Mangahere : ParsedHttpSource() {
override fun getFilterList() = FilterList( override fun getFilterList() = FilterList(
TypeList(types.keys.toList().sorted().toTypedArray()), TypeList(types.keys.toList().sorted().toTypedArray()),
CompletionList(completions), CompletionList(completions),
GenreList(genres) GenreList(genres())
) )
private val types = hashMapOf( private val types = hashMapOf(
@ -330,7 +326,7 @@ class Mangahere : ParsedHttpSource() {
private val completions = arrayOf("Either", "No", "Yes") private val completions = arrayOf("Either", "No", "Yes")
private val genres = arrayListOf( private fun genres() = arrayListOf(
Genre("Action", 1), Genre("Action", 1),
Genre("Adventure", 2), Genre("Adventure", 2),
Genre("Comedy", 3), Genre("Comedy", 3),