Fixes Bato.to Filtering (#5403)

* Fixed A-Z and Totally sort and added Z-A sort

* Added Genres, Status, Origin and removed stars, styles and demographic

* Update build.gradle

* Improved Status Filter

* Added hidden genres

These Genres(award_winning, youkai, uncategirized) give out results in the search query but are listed nowhere on bato.to

* Added More Sort Options
This commit is contained in:
Johannes Joens 2021-01-14 09:41:21 +13:00 committed by GitHub
parent 295b19ad08
commit 66c8af8b4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 162 additions and 120 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Bato.to' extName = 'Bato.to'
pkgNameSuffix = 'all.batoto' pkgNameSuffix = 'all.batoto'
extClass = '.BatoToFactory' extClass = '.BatoToFactory'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -71,47 +71,24 @@ open class BatoTo(
url.addQueryParameter("langs", siteLang) url.addQueryParameter("langs", siteLang)
filters.forEach { filter -> filters.forEach { filter ->
when (filter) { when (filter) {
is AuthorFilter -> { is OriginFilter -> {
author = filter.state val originToInclude = mutableListOf<String>()
}
is StyleFilter -> {
val styleToInclude = mutableListOf<String>()
filter.state.forEach { content ->
if (content.state) {
styleToInclude.add(content.name)
}
}
if (styleToInclude.isNotEmpty()) {
url.addQueryParameter(
"styles",
styleToInclude
.joinToString(",")
)
}
}
is DemographicFilter -> {
val demographicToInclude = mutableListOf<String>()
filter.state.forEach { content -> filter.state.forEach { content ->
if (content.state) { if (content.state) {
demographicToInclude.add(content.name) demographicToInclude.add(content.name)
} }
} }
if (demographicToInclude.isNotEmpty()) { if (originToInclude.isNotEmpty()) {
url.addQueryParameter( url.addQueryParameter(
"demogs", "origs",
demographicToInclude originToInclude
.joinToString(",") .joinToString(",")
) )
} }
} }
is StatusFilter -> { is StatusFilter -> {
val status = when (filter.state) { if (filter.state != 0) {
Filter.TriState.STATE_INCLUDE -> "1" url.addQueryParameter("release", filter.toUriPart())
Filter.TriState.STATE_EXCLUDE -> "0"
else -> ""
}
if (status.isNotEmpty()) {
url.addQueryParameter("status", status)
} }
} }
is GenreFilter -> { is GenreFilter -> {
@ -129,11 +106,6 @@ open class BatoTo(
) )
} }
} }
is StarFilter -> {
if (filter.state != 0) {
url.addQueryParameter("stars", filter.toUriPart())
}
}
is ChapterFilter -> { is ChapterFilter -> {
if (filter.state != 0) { if (filter.state != 0) {
url.addQueryParameter("chapters", filter.toUriPart()) url.addQueryParameter("chapters", filter.toUriPart())
@ -325,23 +297,9 @@ open class BatoTo(
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used") override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
private class AuthorFilter : Filter.Text("Author / Artist") private class OriginFilter(genres: List<Tag>) : Filter.Group<Tag>("Origin", genres)
private class StyleFilter(genres: List<Tag>) : Filter.Group<Tag>("Styles", genres)
private class DemographicFilter(genres: List<Tag>) : Filter.Group<Tag>("Demographic", genres)
private class GenreFilter(genres: List<Tag>) : Filter.Group<Tag>("Genres", genres) private class GenreFilter(genres: List<Tag>) : Filter.Group<Tag>("Genres", genres)
private class StatusFilter : Filter.TriState("Completed")
private class StarFilter : UriPartFilter(
"Stars",
arrayOf(
Pair("<select>", ""),
Pair("5 Stars", "5"),
Pair("4 Stars", "4"),
Pair("3 Stars", "3"),
Pair("2 Stars", "2"),
Pair("1 Stars", "1")
)
)
private class ChapterFilter : UriPartFilter( private class ChapterFilter : UriPartFilter(
"Chapters", "Chapters",
@ -363,89 +321,173 @@ open class BatoTo(
"Sorts By", "Sorts By",
arrayOf( arrayOf(
Pair("<select>", ""), Pair("<select>", ""),
Pair("Totally", "views_t"), Pair("A-Z", "title.az"),
Pair("365 days", "views_y"), Pair("Z-A", "title"),
Pair("30 days", "views_m"), Pair("Last Updated", "update"),
Pair("7 days", "views_w"), Pair("Oldest Updated", "updated.az")
Pair("24 hours", "views_d"), Pair("Newest Added", "create"),
Pair("60 minutes", "views_h"), Pair("Oldest Added", "create.az"),
Pair("A-Z", "title"), Pair("Most Views Totally", "views_a"),
Pair("Update time", "update"), Pair("Most Views 365 days", "views_y"),
Pair("Add time", "create") Pair("Most Views 30 days", "views_m"),
Pair("Most Views 7 days", "views_w"),
Pair("Most Views 24 hours", "views_d"),
Pair("Most Views 60 minutes", "views_h"),
Pair("Least Views Totally", "views_a.az"),
Pair("Least Views 365 days", "views_y.az"),
Pair("Least Views 30 days", "views_m.az"),
Pair("Least Views 7 days", "views_w.az"),
Pair("Least Views 24 hours", "views_d.az"),
Pair("Least Views 60 minutes", "views_h.az")
)
)
private class StatusFilter : UriPartFilter(
"Status",
arrayOf(
Pair("<select>", ""),
Pair("Pending", "pending"),
Pair("Ongoing", "ongoing"),
Pair("Completed", "completed"),
Pair("Hiatus", "hiatus"),
Pair("Cancelled", "cancelled")
) )
) )
override fun getFilterList() = FilterList( override fun getFilterList() = FilterList(
Filter.Header("NOTE: Ignored if using text search!"), Filter.Header("NOTE: Ignored if using text search!"),
AuthorFilter(),
Filter.Separator(), Filter.Separator(),
StatusFilter(),
StarFilter(),
ChapterFilter(), ChapterFilter(),
SortBy(), SortBy(),
StyleFilter(getStyleList()), StatusFilter(),
DemographicFilter(getDemographicList()), OriginFilter(getOriginList()),
GenreFilter(getGenreList()) GenreFilter(getGenreList())
) )
private fun getStyleList() = listOf( private fun getOriginList() = listOf(
Tag("manga"), Tag("my"),
Tag("manhwa"), Tag("ceb"),
Tag("manhua"), Tag("zh"),
Tag("webtoon") Tag("zh_hk"),
) Tag("en"),
Tag("en_us"),
private fun getDemographicList() = listOf( Tag("fil"),
Tag("josei"), Tag("id"),
Tag("seinen"), Tag("it"),
Tag("shoujo"), Tag("ja"),
Tag("shoujo ai"), Tag("ko"),
Tag("shounen"), Tag("ms"),
Tag("shounen ai"), Tag("pt_br"),
Tag("yaoi"), Tag("th"),
Tag("yuri") Tag("vi")
) )
private fun getGenreList() = listOf( private fun getGenreList() = listOf(
Tag("action"), Tag("Artbook"),
Tag("adventure"), Tag("Cartoon"),
Tag("award winning"), Tag("Comic"),
Tag("comedy"), Tag("Doujinshi"),
Tag("cooking"), Tag("Imageset"),
Tag("demons"), Tag("Manga"),
Tag("doujinshi"), Tag("Manhua"),
Tag("drama"), Tag("Manhwa"),
Tag("ecchi"), Tag("Webtoon"),
Tag("fantasy"), Tag("Western"),
Tag("gender bender"), Tag("Josei"),
Tag("harem"), Tag("Seinen"),
Tag("historical"), Tag("Shoujo"),
Tag("horror"), Tag("Shoujo_Ai"),
Tag("isekai"), Tag("Shounen"),
Tag("magic"), Tag("Shounen_Ai"),
Tag("martial arts"), Tag("Yaoi"),
Tag("mature"), Tag("Yuri"),
Tag("mecha"), Tag("Ecchi"),
Tag("medical"), Tag("Mature"),
Tag("military"), Tag("Adult"),
Tag("music"), Tag("Gore"),
Tag("mystery"), Tag("Violence"),
Tag("one shot"), Tag("Smut"),
Tag("psychological"), Tag("Hentai"),
Tag("reverse harem"), Tag("4_Koma"),
Tag("romance"), Tag("Action"),
Tag("school life"), Tag("Adaptation"),
Tag("sci fi"), Tag("Adventure"),
Tag("shotacon"), Tag("Aliens"),
Tag("slice of life"), Tag("Animals"),
Tag("smut"), Tag("Anthology"),
Tag("sports"), Tag("Comedy"),
Tag("super power"), Tag("Cooking"),
Tag("supernatural"), Tag("Crime"),
Tag("tragedy"), Tag("Crossdressing"),
Tag("uncategorized"), Tag("Delinquents"),
Tag("vampire"), Tag("Dementia"),
Tag("youkai") Tag("Demons"),
Tag("Drama"),
Tag("Fantasy"),
Tag("Fan_Colored"),
Tag("Full_Color"),
Tag("Game"),
Tag("Gender_Bender"),
Tag("Genderswap"),
Tag("Ghosts"),
Tag("Gyaru"),
Tag("Harem"),
Tag("Halequin"),
Tag("Historical"),
Tag("Horror"),
Tag("Incest"),
Tag("Isekai"),
Tag("Kids"),
Tag("Loli"),
Tag("Lolicon"),
Tag("Magic"),
Tag("Magical_Girls"),
Tag("Martial_Arts"),
Tag("Mecha"),
Tag("Medical"),
Tag("Military"),
Tag("Monster_Girls"),
Tag("Monsters"),
Tag("Music"),
Tag("Mystery"),
Tag("Netorare"),
Tag("Ninja"),
Tag("Office_Workers"),
Tag("Oneshot"),
Tag("Parody"),
Tag("Philosophical"),
Tag("Police"),
Tag("Post_Apocalyptic"),
Tag("Psychological"),
Tag("Reincarnation"),
Tag("Reverse_Harem"),
Tag("Romance"),
Tag("Samurai"),
Tag("School_Life"),
Tag("Sci_Fi"),
Tag("Shota"),
Tag("Shotacon"),
Tag("Slice_Of_Life"),
Tag("SM_BDSM"),
Tag("Space"),
Tag("Sports"),
Tag("Super_Power"),
Tag("Superhero"),
Tag("Supernatural"),
Tag("Survival"),
Tag("Thriller"),
Tag("Time_Travel"),
Tag("Tragedy"),
Tag("Vampires"),
Tag("Video_Games"),
Tag("Virtual_Reality"),
Tag("Wuxia"),
Tag("Xianxia"),
Tag("Xuanhuan"),
Tag("Zombies"),
Tag("c"),
Tag("youkai"),
Tag("uncategirized")
) )
private open class UriPartFilter(displayName: String, val vals: Array<Pair<String, String>>) : private open class UriPartFilter(displayName: String, val vals: Array<Pair<String, String>>) :