From e2df8ef2e09615d87341a3ca5e784f4dc6bab51a Mon Sep 17 00:00:00 2001 From: Eugene Cheung Date: Thu, 9 Aug 2018 19:23:39 -0400 Subject: [PATCH] Fix searching with only genres in MangaDex (closes #444) --- src/all/mangadex/build.gradle | 4 +- .../extension/all/mangadex/Mangadex.kt | 65 ++++++++++--------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index 837cda6b7..25ac05de9 100644 --- a/src/all/mangadex/build.gradle +++ b/src/all/mangadex/build.gradle @@ -5,8 +5,8 @@ ext { appName = 'Tachiyomi: MangaDex' pkgNameSuffix = 'all.mangadex' extClass = '.MangadexFactory' - extVersionCode = 34 - extVersionSuffix = 34 + extVersionCode = 35 + extVersionSuffix = 35 libVersion = '1.2' } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/Mangadex.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/Mangadex.kt index 44d3cf191..923a0b67b 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/Mangadex.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/Mangadex.kt @@ -249,8 +249,9 @@ open class Mangadex(override val lang: String, private val internalLang: String, } val genres = mutableListOf() + val genreList = getGenreList() mangaJson.get("genres").asJsonArray.forEach { id -> - GENRE_LIST.find { it -> it.id == id.string }?.let { genre -> + genreList.find { it -> it.id == id.string }?.let { genre -> genres.add(genre.name) } } @@ -424,39 +425,10 @@ open class Mangadex(override val lang: String, private val internalLang: String, R18(), Demographic(), OriginalLanguage(), - GenreList(GENRE_LIST) + GenreList(getGenreList()) ) - companion object { - private val WHITESPACE_REGEX = "\\s".toRegex() - - // This number matches to the cookie - private const val NO_R18 = 0 - private const val ALL = 1 - private const val ONLY_R18 = 2 - - private const val SHOW_R18_PREF_Title = "Default R18 Setting" - private const val SHOW_R18_PREF = "showR18Default" - - private const val API_MANGA = "/api/manga/" - private const val API_CHAPTER = "/api/chapter/" - - private val SOURCE_LANG_LIST = listOf( - Pair("All", "0"), - Pair("Japanese", "2"), - Pair("English", "1"), - Pair("Polish", "3"), - Pair("German", "8"), - Pair("French", "10"), - Pair("Vietnamese", "12"), - Pair("Chinese", "21"), - Pair("Indonesian", "27"), - Pair("Korean", "28"), - Pair("Spanish (LATAM)", "29"), - Pair("Thai", "32"), - Pair("Filipino", "34") - ) - private val GENRE_LIST = listOf( + private fun getGenreList() =listOf( Genre("1", "4-koma"), Genre("2", "Action"), Genre("3", "Adventure"), @@ -498,6 +470,35 @@ open class Mangadex(override val lang: String, private val internalLang: String, Genre("39", "[no chapters]"), Genre("40", "Game"), Genre("41", "Isekai")) + + companion object { + private val WHITESPACE_REGEX = "\\s".toRegex() + + // This number matches to the cookie + private const val NO_R18 = 0 + private const val ALL = 1 + private const val ONLY_R18 = 2 + + private const val SHOW_R18_PREF_Title = "Default R18 Setting" + private const val SHOW_R18_PREF = "showR18Default" + + private const val API_MANGA = "/api/manga/" + private const val API_CHAPTER = "/api/chapter/" + + private val SOURCE_LANG_LIST = listOf( + Pair("All", "0"), + Pair("Japanese", "2"), + Pair("English", "1"), + Pair("Polish", "3"), + Pair("German", "8"), + Pair("French", "10"), + Pair("Vietnamese", "12"), + Pair("Chinese", "21"), + Pair("Indonesian", "27"), + Pair("Korean", "28"), + Pair("Spanish (LATAM)", "29"), + Pair("Thai", "32"), + Pair("Filipino", "34")) } }