From f5f90f7a0e237992ab39a7650ca495cbd2b06ea3 Mon Sep 17 00:00:00 2001 From: uy/sun Date: Mon, 15 Jan 2024 02:42:17 +0800 Subject: [PATCH] ColaManhua (OhManhua): add Category and Char filters (#248) * ColaManhua (OhManhua): add Category and Char filters * Use UriPartFilter * Change source name * Refactor StatusFilter --- src/zh/onemanhua/build.gradle | 4 +- .../extension/zh/onemanhua/Onemanhua.kt | 112 ++++++++++++++++-- 2 files changed, 107 insertions(+), 9 deletions(-) diff --git a/src/zh/onemanhua/build.gradle b/src/zh/onemanhua/build.gradle index 4cfe9cfd5..3526781a6 100644 --- a/src/zh/onemanhua/build.gradle +++ b/src/zh/onemanhua/build.gradle @@ -3,10 +3,10 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlinx-serialization' ext { - extName = 'ColaManhua (OhManhua)' + extName = 'COLAMANGA' pkgNameSuffix = 'zh.onemanhua' extClass = '.Onemanhua' - extVersionCode = 12 + extVersionCode = 13 } dependencies { diff --git a/src/zh/onemanhua/src/eu/kanade/tachiyomi/extension/zh/onemanhua/Onemanhua.kt b/src/zh/onemanhua/src/eu/kanade/tachiyomi/extension/zh/onemanhua/Onemanhua.kt index be13bda3c..9edb725f0 100644 --- a/src/zh/onemanhua/src/eu/kanade/tachiyomi/extension/zh/onemanhua/Onemanhua.kt +++ b/src/zh/onemanhua/src/eu/kanade/tachiyomi/extension/zh/onemanhua/Onemanhua.kt @@ -49,7 +49,7 @@ class Onemanhua : ConfigurableSource, ParsedHttpSource() { override val id = 8252565807829914103 // name used to be "One漫画" override val lang = "zh" override val supportsLatest = true - override val name = "COLA漫画 (OH漫画)" + override val name = "COLAMANGA" override val baseUrl = "https://www.colamanga.com" // Preference setting @@ -122,11 +122,99 @@ class Onemanhua : ConfigurableSource, ParsedHttpSource() { override fun latestUpdatesFromElement(element: Element) = commonMangaFromElement(element) // Filter - private class StatusFilter : Filter.TriState("已完结") - private class SortFilter : Filter.Select("排序", arrayOf("更新日", "收录日", "日点击", "月点击"), 2) - + open class UriPartFilter(displayName: String, private val vals: Array>) : + Filter.Select(displayName, vals.map { it.first }.toTypedArray()) { + fun toUriPart() = vals[state].second + } + private class StatusFilter : UriPartFilter( + "状态", + arrayOf( + Pair("全部", ""), + Pair("连载中", "1"), + Pair("已完结", "2"), + ), + ) + private class SortFilter : UriPartFilter( + "排序", + arrayOf( + Pair("更新日", "update"), + Pair("日点击", "dailyCount"), + Pair("周点击", "weeklyCount"), + Pair("月点击", "monthlyCount"), + ), + ) + private class CategoryFilter : UriPartFilter( + "类型", + arrayOf( + Pair("全部", ""), + Pair("热血", "10023"), + Pair("玄幻", "10024"), + Pair("恋爱", "10126"), + Pair("冒险", "10210"), + Pair("古风", "10143"), + Pair("都市", "10124"), + Pair("穿越", "10129"), + Pair("奇幻", "10242"), + Pair("其他", "10560"), + Pair("少男", "10641"), + Pair("搞笑", "10122"), + Pair("战斗", "10309"), + Pair("冒险热血", "11224"), + Pair("重生", "10461"), + Pair("爆笑", "10201"), + Pair("逆袭", "10943"), + Pair("后宫", "10138"), + Pair("少年", "10321"), + Pair("少女", "10301"), + Pair("熱血", "12044"), + Pair("系统", "10722"), + Pair("动作", "10125"), + Pair("校园", "10131"), + Pair("冒險", "12123"), + Pair("修真", "10133"), + Pair("修仙", "10453"), + Pair("剧情", "10480"), + Pair("霸总", "10127"), + Pair("大女主", "10706"), + Pair("生活", "10142"), + ), + ) + private class CharFilter : UriPartFilter( + "字母", + arrayOf( + Pair("全部", ""), + Pair("A", "10182"), + Pair("B", "10081"), + Pair("C", "10134"), + Pair("D", "10001"), + Pair("E", "10238"), + Pair("F", "10161"), + Pair("G", "10225"), + Pair("H", "10137"), + Pair("I", "10284"), + Pair("J", "10141"), + Pair("K", "10283"), + Pair("L", "10132"), + Pair("M", "10136"), + Pair("N", "10130"), + Pair("O", "10282"), + Pair("P", "10262"), + Pair("Q", "10164"), + Pair("R", "10240"), + Pair("S", "10121"), + Pair("T", "10123"), + Pair("U", "11184"), + Pair("V", "11483"), + Pair("W", "10135"), + Pair("X", "10061"), + Pair("Y", "10082"), + Pair("Z", "10128"), + ), + ) override fun getFilterList() = FilterList( SortFilter(), + CategoryFilter(), + CharFilter(), StatusFilter(), ) @@ -141,12 +229,22 @@ class Onemanhua : ConfigurableSource, ParsedHttpSource() { filters.forEach { filter -> when (filter) { is StatusFilter -> { - if (!filter.isIgnored()) { - url.addQueryParameter("status", arrayOf("0", "2", "1")[filter.state]) + if (filter.state != 0) { + url.addQueryParameter("status", filter.toUriPart()) } } is SortFilter -> { - url.addQueryParameter("orderBy", arrayOf("update", "create", "dailyCount", "weeklyCount", "monthlyCount")[filter.state]) + url.addQueryParameter("orderBy", filter.toUriPart()) + } + is CategoryFilter -> { + if (filter.state != 0) { + url.addQueryParameter("mainCategoryId", filter.toUriPart()) + } + } + is CharFilter -> { + if (filter.state != 0) { + url.addQueryParameter("charCategoryId", filter.toUriPart()) + } } else -> {} }