Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/SortOrderPopularitytime' into fe…
Browse files Browse the repository at this point in the history
…ature/advanced_filter
  • Loading branch information
Koitharu committed Sep 17, 2024
2 parents 821e51f + 7c8b427 commit 9042074
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ enum class SortOrder {
ADDED,
ADDED_ASC,
RELEVANCE,
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 @@ -108,6 +108,7 @@ internal class MangaDexParser(context: MangaLoaderContext) : MangaParser(context
SortOrder.ADDED -> "[createdAt]=desc"
SortOrder.ADDED_ASC -> "[createdAt]=asc"
SortOrder.RELEVANCE -> "&order[relevance]=desc"
else -> "[latestUploadedChapter]=desc"
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class NHentaiParser(context: MangaLoaderContext) :
".tag-container:contains(Languages:) span.tags a:not(.tag-17249) span.name" // tag-17249 = translated
override val idImg = "image-container"

override val availableSortOrders: Set<SortOrder> = EnumSet.of(SortOrder.UPDATED, SortOrder.POPULARITY)
override val availableSortOrders: Set<SortOrder> = EnumSet.of(SortOrder.UPDATED, SortOrder.POPULARITY, SortOrder.POPULARITY_TODAY, SortOrder.POPULARITY_WEEK)

override val isMultipleTagsSupported = true

Expand Down 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

0 comments on commit 9042074

Please sign in to comment.