Skip to content

Commit

Permalink
add POPULARITY time sortOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
davvarrr committed Sep 10, 2024
1 parent ad726a3 commit 4fcc68d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ enum class SortOrder {
NEWEST_ASC,
ALPHABETICAL,
ALPHABETICAL_DESC,
POPULARITY_HOUR,
POPULARITY_TODAY,
POPULARITY_WEEK,
POPULARITY_MONTH,
POPULARITY_YEAR,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<MangaState> = EnumSet.allOf(MangaState::class.java)
Expand Down Expand Up @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 4fcc68d

Please sign in to comment.