MangaThemesia: Allow searching with filter (#13384)

This commit is contained in:
AntsyLich 2022-09-08 17:51:23 +06:00 committed by GitHub
parent 050789f77d
commit d5a44221ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 39 deletions

View File

@ -81,43 +81,42 @@ abstract class MangaThemesia(
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val url = baseUrl.toHttpUrl().newBuilder()
if (query.isNotEmpty()) {
url.addPathSegments("page/$page").addQueryParameter("s", query)
} else {
url.addPathSegment(mangaUrlDirectory.substring(1)).addQueryParameter("page", page.toString())
filters.forEach { filter ->
when (filter) {
is AuthorFilter -> {
url.addQueryParameter("author", filter.state)
}
is YearFilter -> {
url.addQueryParameter("yearx", filter.state)
}
is StatusFilter -> {
url.addQueryParameter("status", filter.selectedValue())
}
is TypeFilter -> {
url.addQueryParameter("type", filter.selectedValue())
}
is OrderByFilter -> {
url.addQueryParameter("order", filter.selectedValue())
}
is GenreListFilter -> {
filter.state
.filter { it.state != Filter.TriState.STATE_IGNORE }
.forEach {
val value = if (it.state == Filter.TriState.STATE_EXCLUDE) "-${it.value}" else it.value
url.addQueryParameter("genre[]", value)
}
}
// if site has project page, default value "hasProjectPage" = false
is ProjectFilter -> {
if (filter.selectedValue() == "project-filter-on") {
url.setPathSegment(0, projectPageString.substring(1))
}
}
else -> { /* Do Nothing */ }
.addPathSegment(mangaUrlDirectory.substring(1))
.addQueryParameter("title", query)
.addQueryParameter("page", page.toString())
filters.forEach { filter ->
when (filter) {
is AuthorFilter -> {
url.addQueryParameter("author", filter.state)
}
is YearFilter -> {
url.addQueryParameter("yearx", filter.state)
}
is StatusFilter -> {
url.addQueryParameter("status", filter.selectedValue())
}
is TypeFilter -> {
url.addQueryParameter("type", filter.selectedValue())
}
is OrderByFilter -> {
url.addQueryParameter("order", filter.selectedValue())
}
is GenreListFilter -> {
filter.state
.filter { it.state != Filter.TriState.STATE_IGNORE }
.forEach {
val value = if (it.state == Filter.TriState.STATE_EXCLUDE) "-${it.value}" else it.value
url.addQueryParameter("genre[]", value)
}
}
// if site has project page, default value "hasProjectPage" = false
is ProjectFilter -> {
if (filter.selectedValue() == "project-filter-on") {
url.setPathSegment(0, projectPageString.substring(1))
}
}
else -> { /* Do Nothing */ }
}
}
return GET(url.toString())
@ -290,7 +289,7 @@ abstract class MangaThemesia(
}
/**
* Send the view count request to the Madara endpoint.
* Send the view count request to the sites endpoint.
*
* @param document The response document with the wp-manga data
*/
@ -378,7 +377,6 @@ abstract class MangaThemesia(
override fun getFilterList(): FilterList {
val filters = mutableListOf<Filter<*>>(
Filter.Header("NOTE: Ignored if using text search!"),
Filter.Separator(),
AuthorFilter(),
YearFilter(),

View File

@ -10,7 +10,7 @@ class MangaThemesiaGenerator : ThemeSourceGenerator {
override val themeClass = "MangaThemesia"
override val baseVersionCode: Int = 20
override val baseVersionCode: Int = 21
override val sources = listOf(
MultiLang("Asura Scans", "https://www.asurascans.com", listOf("en", "tr"), className = "AsuraScansFactory", pkgName = "asurascans", overrideVersionCode = 16),