From 4fcc68d1494164576e6d76daa255d92a7aeb6b59 Mon Sep 17 00:00:00 2001 From: devi Date: Tue, 10 Sep 2024 14:25:24 +0200 Subject: [PATCH] add POPULARITY time sortOrder --- .../kotatsu/parsers/model/SortOrder.kt | 5 ++ .../kotatsu/parsers/site/all/BatoToParser.kt | 10 ++++ .../parsers/site/all/MangaDexParser.kt | 1 + .../parsers/site/es/TuMangaOnlineParser.kt | 1 + .../site/galleryadults/all/NHentaiParser.kt | 50 +++++-------------- .../kotatsu/parsers/site/ru/MangaWtfParser.kt | 9 +--- 6 files changed, 32 insertions(+), 44 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/SortOrder.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/SortOrder.kt index 9d743ae20..83c1b5898 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/SortOrder.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/SortOrder.kt @@ -11,4 +11,9 @@ enum class SortOrder { NEWEST_ASC, ALPHABETICAL, ALPHABETICAL_DESC, + POPULARITY_HOUR, + POPULARITY_TODAY, + POPULARITY_WEEK, + POPULARITY_MONTH, + POPULARITY_YEAR, } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/BatoToParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/BatoToParser.kt index 1d4e5520a..79036fdef 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/BatoToParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/BatoToParser.kt @@ -53,6 +53,11 @@ internal class BatoToParser(context: MangaLoaderContext) : PagedMangaParser( SortOrder.UPDATED, SortOrder.POPULARITY, SortOrder.ALPHABETICAL, + SortOrder.POPULARITY_YEAR, + SortOrder.POPULARITY_MONTH, + SortOrder.POPULARITY_WEEK, + SortOrder.POPULARITY_TODAY, + SortOrder.POPULARITY_HOUR, ) override val availableStates: Set = EnumSet.allOf(MangaState::class.java) @@ -108,6 +113,11 @@ internal class BatoToParser(context: MangaLoaderContext) : PagedMangaParser( SortOrder.POPULARITY -> append("views_a.za") SortOrder.NEWEST -> append("create.za") SortOrder.ALPHABETICAL -> append("title.az") + SortOrder.POPULARITY_YEAR -> append("views_y.za") + SortOrder.POPULARITY_MONTH -> append("views_m.za") + SortOrder.POPULARITY_WEEK -> append("views_w.za") + SortOrder.POPULARITY_TODAY -> append("views_d.za") + SortOrder.POPULARITY_HOUR -> append("views_h.za") else -> append("update.za") } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaDexParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaDexParser.kt index 3f7980f24..d57c5d1f7 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaDexParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaDexParser.kt @@ -94,6 +94,7 @@ internal class MangaDexParser(context: MangaLoaderContext) : MangaParser(context SortOrder.NEWEST_ASC -> "[createdAt]=asc" SortOrder.POPULARITY -> "[followedCount]=desc" SortOrder.POPULARITY_ASC -> "[followedCount]=asc" + else -> "[latestUploadedChapter]=desc" }, ) filter.states.forEach { diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/es/TuMangaOnlineParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/es/TuMangaOnlineParser.kt index 7b3220fc4..877ebc7b7 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/es/TuMangaOnlineParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/es/TuMangaOnlineParser.kt @@ -66,6 +66,7 @@ class TuMangaOnlineParser(context: MangaLoaderContext) : PagedMangaParser( SortOrder.ALPHABETICAL_DESC -> "alphabetically&order_dir=desc" SortOrder.RATING -> "score&order_dir=desc" SortOrder.RATING_ASC -> "score&order_dir=asc" + else -> "release_date&order_dir=desc" }, ) append("&filter_by=title") diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/galleryadults/all/NHentaiParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/galleryadults/all/NHentaiParser.kt index 8ea0f31d2..2535fdb9d 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/galleryadults/all/NHentaiParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/galleryadults/all/NHentaiParser.kt @@ -57,48 +57,24 @@ internal class NHentaiParser(context: MangaLoaderContext) : } is MangaListFilter.Advanced -> { - if (filter.tags.size > 1 || (filter.tags.isNotEmpty() && filter.locale != null)) { - append("/search/?q=") - append(buildQuery(filter.tags, filter.locale).urlEncoded()) - if (filter.sortOrder == SortOrder.POPULARITY) { - append("&sort=popular") - } - append("&") - } else if (filter.tags.isNotEmpty()) { - filter.tags.oneOrThrowIfMany()?.let { - append("/tag/") - append(it.key) - } - append("/") - if (filter.sortOrder == SortOrder.POPULARITY) { - append("popular") - } - if (page > 1) { - append("?") - } - } else if (filter.locale != null) { - append("/language/") - append(filter.locale.toLanguagePath()) - append("/") - if (filter.sortOrder == SortOrder.POPULARITY) { - append("popular") - } - if (page > 1) { - append("?") - } - } else { - if (filter.sortOrder == SortOrder.POPULARITY) { - append("/?sort=popular&") - } else { - append("/?") - } + append("/search/?q=pages:>0 ") + // for Search with query + // append(filter.query.urlEncoded()) + // append(' ') + append(buildQuery(filter.tags, filter.locale).urlEncoded()) + when (filter.sortOrder) { + SortOrder.POPULARITY -> append("&sort=popular") + SortOrder.POPULARITY_TODAY -> append("&sort=popular-today") + SortOrder.POPULARITY_WEEK -> append("&sort=popular-week") + SortOrder.UPDATED -> {} + else -> {} } } - null -> append("/?") + null -> append("/search/?q=pages:>0 ") } if (page > 1) { - append("page=") + append("&page=") append(page.toString()) } } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/MangaWtfParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/MangaWtfParser.kt index dfbafffbf..093fb08dd 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/MangaWtfParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/MangaWtfParser.kt @@ -67,13 +67,8 @@ class MangaWtfParser( SortOrder.POPULARITY -> "viewsCount,desc" SortOrder.RATING -> "likesCount,desc" SortOrder.NEWEST -> "createdAt,desc" - SortOrder.ALPHABETICAL, - SortOrder.ALPHABETICAL_DESC, - SortOrder.UPDATED_ASC, - SortOrder.POPULARITY_ASC, - SortOrder.RATING_ASC, - SortOrder.NEWEST_ASC, - -> throw IllegalArgumentException("Unsupported ${filter.sortOrder}") + else -> throw IllegalArgumentException("Unsupported ${filter.sortOrder}") + }, ) if (filter.tags.isNotEmpty()) {