2021-02-10 14:05:12 +00:00
|
|
|
package eu.kanade.tachiyomi.extension.id.pojokmanga
|
|
|
|
|
|
|
|
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
2021-06-08 21:51:36 +00:00
|
|
|
import eu.kanade.tachiyomi.network.GET
|
|
|
|
import eu.kanade.tachiyomi.source.model.Filter
|
|
|
|
import eu.kanade.tachiyomi.source.model.FilterList
|
|
|
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
|
|
|
import okhttp3.Request
|
2021-02-10 14:05:12 +00:00
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
import java.util.Locale
|
|
|
|
|
2021-06-08 21:51:36 +00:00
|
|
|
class PojokManga : Madara("Pojok Manga", "https://pojokmanga.com", "id", SimpleDateFormat("MMM dd, yyyy", Locale.US)) {
|
|
|
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
|
|
|
var url = "$baseUrl/${searchPage(page)}".toHttpUrlOrNull()!!.newBuilder()
|
|
|
|
url.addQueryParameter("s", query)
|
|
|
|
url.addQueryParameter("post_type", "wp-manga")
|
|
|
|
filters.forEach { filter ->
|
|
|
|
when (filter) {
|
|
|
|
is AuthorFilter -> {
|
|
|
|
if (filter.state.isNotBlank()) {
|
|
|
|
url.addQueryParameter("author", filter.state)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
is ArtistFilter -> {
|
|
|
|
if (filter.state.isNotBlank()) {
|
|
|
|
url.addQueryParameter("artist", filter.state)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
is YearFilter -> {
|
|
|
|
if (filter.state.isNotBlank()) {
|
|
|
|
url.addQueryParameter("release", filter.state)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
is StatusFilter -> {
|
|
|
|
filter.state.forEach {
|
|
|
|
if (it.state) {
|
|
|
|
url.addQueryParameter("status[]", it.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
is OrderByFilter -> {
|
|
|
|
if (filter.state != 0) {
|
|
|
|
url.addQueryParameter("m_orderby", filter.toUriPart())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
is AdultContentFilter -> {
|
|
|
|
url.addQueryParameter("adult", filter.toUriPart())
|
|
|
|
}
|
|
|
|
is GenreConditionFilter -> {
|
|
|
|
url.addQueryParameter("op", filter.toUriPart())
|
|
|
|
}
|
|
|
|
is GenreList -> {
|
|
|
|
filter.state
|
|
|
|
.filter { it.state }
|
|
|
|
.let { list ->
|
|
|
|
if (list.isNotEmpty()) { list.forEach { genre -> url.addQueryParameter("genre[]", genre.id) } }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
is ProjectFilter -> {
|
|
|
|
if (filter.toUriPart() == "project-filter-on") {
|
|
|
|
url = "$baseUrl/project/page/$page".toHttpUrlOrNull()!!.newBuilder()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return GET(url.toString(), headers)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun searchMangaSelector() = "div.c-tabs-item__content, div.page-item-detail"
|
|
|
|
|
|
|
|
protected class ProjectFilter : UriPartFilter(
|
|
|
|
"Filter Project",
|
|
|
|
arrayOf(
|
|
|
|
Pair("Show all manga", ""),
|
|
|
|
Pair("Show only project manga", "project-filter-on")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
override fun getFilterList() = FilterList(
|
2022-02-28 21:37:21 +00:00
|
|
|
AuthorFilter(authorFilterTitle),
|
|
|
|
ArtistFilter(artistFilterTitle),
|
|
|
|
YearFilter(yearFilterTitle),
|
|
|
|
StatusFilter(statusFilterTitle, getStatusList()),
|
|
|
|
OrderByFilter(orderByFilterTitle, orderByFilterOptions.zip(orderByFilterOptionsValues)),
|
|
|
|
AdultContentFilter(adultContentFilterTitle, adultContentFilterOptions),
|
2021-06-08 21:51:36 +00:00
|
|
|
Filter.Separator(),
|
2022-02-28 21:37:21 +00:00
|
|
|
Filter.Header(genreFilterHeader),
|
|
|
|
GenreConditionFilter(genreConditionFilterTitle, genreConditionFilterOptions),
|
|
|
|
GenreList(genreFilterTitle, getGenreList()),
|
2021-06-08 21:51:36 +00:00
|
|
|
Filter.Separator(),
|
|
|
|
Filter.Header("NOTE: cant be used with other filter!"),
|
|
|
|
Filter.Header("$name Project List page"),
|
|
|
|
ProjectFilter(),
|
|
|
|
)
|
2021-09-14 15:05:48 +00:00
|
|
|
|
|
|
|
override val useNewChapterEndpoint = true
|
2021-06-08 21:51:36 +00:00
|
|
|
}
|