From 8bab7cfec44b49947c70b8c9932467f54a7742c2 Mon Sep 17 00:00:00 2001 From: vance <32921531+rawfh@users.noreply.github.com> Date: Mon, 7 Dec 2020 21:21:31 +0800 Subject: [PATCH] copymanga: Add ordering filter (#5041) * rename ThemeFilter to MangaFilter * Add ordering filter * Increase version number * rename ThemeFilter to MangaFilter * remove default ordering parameter in htmlUrlString --- src/zh/copymanga/build.gradle | 2 +- .../extension/zh/copymanga/CopyManga.kt | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/zh/copymanga/build.gradle b/src/zh/copymanga/build.gradle index 300ad627d..114dc400c 100644 --- a/src/zh/copymanga/build.gradle +++ b/src/zh/copymanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'CopyManga' pkgNameSuffix = 'zh.copymanga' extClass = '.CopyManga' - extVersionCode = 2 + extVersionCode = 3 libVersion = '1.2' } diff --git a/src/zh/copymanga/src/eu/kanade/tachiyomi/extension/zh/copymanga/CopyManga.kt b/src/zh/copymanga/src/eu/kanade/tachiyomi/extension/zh/copymanga/CopyManga.kt index 854c68b37..84f00624b 100644 --- a/src/zh/copymanga/src/eu/kanade/tachiyomi/extension/zh/copymanga/CopyManga.kt +++ b/src/zh/copymanga/src/eu/kanade/tachiyomi/extension/zh/copymanga/CopyManga.kt @@ -39,11 +39,11 @@ class CopyManga : HttpSource() { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { // when perform html search, sort by popular var apiUrlString = "$baseUrl/api/kb/web/search/count?format=json&limit=$searchPageSize&offset=${(page - 1) * searchPageSize}&platform=2&q=$query" - var htmlUrlString = "$baseUrl/comics?ordering=-popular&offset=${(page - 1) * popularLatestPageSize}&limit=$popularLatestPageSize" + var htmlUrlString = "$baseUrl/comics?offset=${(page - 1) * popularLatestPageSize}&limit=$popularLatestPageSize" var requestUrlString: String val params = filters.map { - if (it is ThemeFilter) { + if (it is MangaFilter) { it.toUriPart() } else "" }.filter { it != "" }.joinToString("&") @@ -167,7 +167,7 @@ class CopyManga : HttpSource() { // Copymanga has different logic in polular and search page, mix two logic in search progress for now override fun getFilterList() = FilterList( - ThemeFilter( + MangaFilter( "题材", "theme", arrayOf( @@ -228,10 +228,20 @@ class CopyManga : HttpSource() { Pair("重生", "chongsheng"), Pair("仙侠", "xianxia") ) - ) - ) + ), + MangaFilter( + "排序", + "ordering", + arrayOf( + Pair("最热门", "-popular"), + Pair("最冷门", "popular"), + Pair("最新", "-datetime_updated"), + Pair("最早", "datetime_updated"), + ) + ), + ) - private class ThemeFilter( + private class MangaFilter( displayName: String, searchName: String, val vals: Array>,