Fix genre filter not working. (#2487)

Fix genre filter not working at SuperHentais
This commit is contained in:
Alessandro Jean 2020-03-23 22:21:24 -03:00 committed by GitHub
parent 4b44edd0d7
commit c780173658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 103 additions and 103 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Super Hentais' appName = 'Tachiyomi: Super Hentais'
pkgNameSuffix = 'pt.superhentais' pkgNameSuffix = 'pt.superhentais'
extClass = '.SuperHentais' extClass = '.SuperHentais'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -264,7 +264,7 @@ class SuperHentais : ParsedHttpSource() {
private class SortFilter : Filter.Sort("Ordem", private class SortFilter : Filter.Sort("Ordem",
SORT_LIST.map { it.third }.toTypedArray(), Selection(2, false)) SORT_LIST.map { it.third }.toTypedArray(), Selection(2, false))
private class GenreFilter : Filter.Group<Tag>("Gêneros", GENRE_LIST) private class GenreFilter(genres: List<Tag>) : Filter.Group<Tag>("Gêneros", genres)
private class ExclusiveModeFilter : Filter.CheckBox("Modo Exclusivo", true) private class ExclusiveModeFilter : Filter.CheckBox("Modo Exclusivo", true)
override fun getFilterList() = FilterList( override fun getFilterList() = FilterList(
@ -274,81 +274,13 @@ class SuperHentais : ParsedHttpSource() {
StatusFilter(), StatusFilter(),
CensureFilter(), CensureFilter(),
SortFilter(), SortFilter(),
GenreFilter(), GenreFilter(getGenreList()),
ExclusiveModeFilter() ExclusiveModeFilter()
) )
private fun String.changeSize(): String = substringBefore("&w=280") + "&w512"
private fun Response.asJsonObject(): JsonObject = JSON_PARSER.parse(body()!!.string()).obj
private fun Map<String, String>.toUrlQueryParams() : String =
map { (k, v) -> "$k=$v" }.joinToString("&")
private fun FormBody.value(name: String): String {
return (0 until size())
.first { name(it) == name }
.let{ value(it) }
}
companion object {
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
private val JSON_PARSER by lazy { JsonParser() }
private val DEFAULT_FILTER = mapOf(
"filter_display_view" to "lista",
"filter_letter" to "0",
"filter_order" to "more_access",
"filter_type_content" to "5",
"filter_genre_model" to "yes",
"filter_status" to "0",
"filter_size_start" to "0",
"filter_size_final" to "0",
"filter_date" to "0",
"filter_date_ordem" to "0",
"filter_censure" to "0",
"filter_idade" to "",
"filter_dub" to "0",
"filter_viewed" to "0"
)
private val LETTER_LIST = listOf("Todas", "Caracteres Especiais")
.plus(('A' .. 'Z').map { it.toString() })
.toTypedArray()
private val CONTENT_LIST = listOf(
Triple("5", "hentai-manga", "Hentai Manga"),
Triple("6", "hq-ero", "HQ Ero"),
Triple("7", "parody-hentai-manga", "Parody Manga"),
Triple("8", "parody-hq-ero", "Parody HQ"),
Triple("9", "doujinshi", "Doujinshi"),
Triple("10", "manhwa-ero", "Manhwa")
)
private val STATUS_LIST = listOf(
Pair("0", "Sem filtro"),
Pair("complete", "Completo"),
Pair("progress", "Em progresso"),
Pair("incomplete", "Incompleto")
)
private val CENSURE_LIST = listOf(
Pair("0", "Sem filtro"),
Pair("yes", "Sem censura"),
Pair("no", "Com censura")
)
private val SORT_LIST = listOf(
Triple("a-z", "z-a", "Nome"),
Triple("date-asc", "date-desc", "Data"),
Triple("less_access", "more_access", "Popularidade"),
Triple("less_like", "more_like", "Nº de likes"),
Triple("post-less", "post-more", "Nº de capítulos")
)
// [...document.querySelectorAll(".filter_genre.list-item")] // [...document.querySelectorAll(".filter_genre.list-item")]
// .map(el => `Tag("${el.getAttribute('data-value')}", "${el.innerText}")`).join(',\n') // .map(el => `Tag("${el.getAttribute('data-value')}", "${el.innerText}")`).join(',\n')
private val GENRE_LIST = listOf( private fun getGenreList() = listOf(
Tag("33", "Ação"), Tag("33", "Ação"),
Tag("100", "Ahegao"), Tag("100", "Ahegao"),
Tag("64", "Anal"), Tag("64", "Anal"),
@ -445,5 +377,73 @@ class SuperHentais : ParsedHttpSource() {
Tag("6", "Yaoi"), Tag("6", "Yaoi"),
Tag("10", "Yuri") Tag("10", "Yuri")
) )
private fun String.changeSize(): String = substringBefore("&w=280") + "&w512"
private fun Response.asJsonObject(): JsonObject = JSON_PARSER.parse(body()!!.string()).obj
private fun Map<String, String>.toUrlQueryParams() : String =
map { (k, v) -> "$k=$v" }.joinToString("&")
private fun FormBody.value(name: String): String {
return (0 until size())
.first { name(it) == name }
.let{ value(it) }
}
companion object {
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
private val JSON_PARSER by lazy { JsonParser() }
private val DEFAULT_FILTER = mapOf(
"filter_display_view" to "lista",
"filter_letter" to "0",
"filter_order" to "more_access",
"filter_type_content" to "5",
"filter_genre_model" to "yes",
"filter_status" to "0",
"filter_size_start" to "0",
"filter_size_final" to "0",
"filter_date" to "0",
"filter_date_ordem" to "0",
"filter_censure" to "0",
"filter_idade" to "",
"filter_dub" to "0",
"filter_viewed" to "0"
)
private val LETTER_LIST = listOf("Todas", "Caracteres Especiais")
.plus(('A' .. 'Z').map { it.toString() })
.toTypedArray()
private val CONTENT_LIST = listOf(
Triple("5", "hentai-manga", "Hentai Manga"),
Triple("6", "hq-ero", "HQ Ero"),
Triple("7", "parody-hentai-manga", "Parody Manga"),
Triple("8", "parody-hq-ero", "Parody HQ"),
Triple("9", "doujinshi", "Doujinshi"),
Triple("10", "manhwa-ero", "Manhwa")
)
private val STATUS_LIST = listOf(
Pair("0", "Sem filtro"),
Pair("complete", "Completo"),
Pair("progress", "Em progresso"),
Pair("incomplete", "Incompleto")
)
private val CENSURE_LIST = listOf(
Pair("0", "Sem filtro"),
Pair("yes", "Sem censura"),
Pair("no", "Com censura")
)
private val SORT_LIST = listOf(
Triple("a-z", "z-a", "Nome"),
Triple("date-asc", "date-desc", "Data"),
Triple("less_access", "more_access", "Popularidade"),
Triple("less_like", "more_like", "Nº de likes"),
Triple("post-less", "post-more", "Nº de capítulos")
)
} }
} }