MangAdventure: sort by views (#10067)

This commit is contained in:
ObserverOfTime 2021-12-10 15:37:19 +02:00 committed by GitHub
parent bc39d9ae8f
commit 0e0a8f2bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 20 deletions

View File

@ -29,7 +29,9 @@ abstract class MangAdventure(
protected open val statuses = arrayOf("Any", "Completed", "Ongoing")
/** The site's sort order labels that correspond to [SortOrder.values]. */
protected open val orders = arrayOf("Title", "Latest upload", "Chapter count")
protected open val orders = arrayOf(
"Title", "Views", "Latest upload", "Chapter count"
)
/** A user agent representing Tachiyomi. */
private val userAgent = "Mozilla/5.0 " +
@ -61,7 +63,7 @@ abstract class MangAdventure(
override fun popularMangaRequest(page: Int) =
apiUri.buildUpon().appendEncodedPath("series").run {
appendQueryParameter("page", page.toString())
appendQueryParameter("sort", "-chapter_count")
appendQueryParameter("sort", "-views")
GET(toString(), headers)
}
@ -72,15 +74,8 @@ abstract class MangAdventure(
} else {
appendQueryParameter("page", page.toString())
appendQueryParameter("title", query)
filters.forEach {
when (it) {
is Author -> appendQueryParameter("author", it.toString())
is Artist -> appendQueryParameter("artist", it.toString())
is Status -> appendQueryParameter("status", it.toString())
is SortOrder -> appendQueryParameter("sort", it.toString())
is CategoryList -> appendQueryParameter("categories", it.toString())
else -> Unit
}
filters.filterIsInstance<UriFilter>().forEach {
appendQueryParameter(it.param, it.toString())
}
}
GET(toString(), headers)
@ -96,6 +91,7 @@ abstract class MangAdventure(
override fun pageListRequest(chapter: SChapter) =
apiUri.buildUpon().appendEncodedPath("pages").run {
val (slug, vol, num) = chapter.components
appendQueryParameter("track", "true")
appendQueryParameter("series", slug)
appendQueryParameter("volume", vol)
appendQueryParameter("number", num)
@ -176,11 +172,15 @@ abstract class MangAdventure(
url = series.url
title = series.title
thumbnail_url = series.cover
description = series.description
description = series.description?.plus(
series.aliases?.joinToString("\n", "\n\nAlternative titles:\n")
)
author = series.authors?.joinToString()
artist = series.artists?.joinToString()
genre = series.categories?.joinToString()
status = when (series.completed) {
status = if (series.licensed == true) {
SManga.LICENSED
} else when (series.completed) {
true -> SManga.COMPLETED
false -> SManga.ONGOING
null -> SManga.UNKNOWN

View File

@ -56,6 +56,8 @@ internal data class Series(
val cover: String?,
val description: String? = null,
val completed: Boolean? = null,
val licensed: Boolean? = null,
val aliases: List<String>? = null,
val authors: List<String>? = null,
val artists: List<String>? = null,
val categories: List<String>? = null

View File

@ -2,13 +2,23 @@ package eu.kanade.tachiyomi.multisrc.mangadventure
import eu.kanade.tachiyomi.source.model.Filter
internal interface UriFilter {
val param: String
override fun toString(): String
}
/** Filter representing the name of an author. */
internal class Author : Filter.Text("Author") {
internal class Author : Filter.Text("Author"), UriFilter {
override val param = "author"
override fun toString() = state
}
/** Filter representing the name of an artist. */
internal class Artist : Filter.Text("Artist") {
internal class Artist : Filter.Text("Artist"), UriFilter {
override val param = "artist"
override fun toString() = state
}
@ -19,7 +29,9 @@ internal class Artist : Filter.Text("Artist") {
*/
internal class SortOrder(
private val labels: Array<String>
) : Filter.Sort("Sort", values, null) {
) : Filter.Sort("Sort", values, null), UriFilter {
override val param = "sort"
override fun toString() = when (state?.ascending) {
null -> ""
true -> labels[state!!.index]
@ -28,7 +40,9 @@ internal class SortOrder(
companion object {
/** The available sort order values. */
private val values = arrayOf("title", "latest_upload", "chapter_count")
private val values = arrayOf(
"title", "views", "latest_upload", "chapter_count"
)
}
}
@ -39,7 +53,9 @@ internal class SortOrder(
*/
internal class Status(
statuses: Array<String>
) : Filter.Select<String>("Status", statuses) {
) : Filter.Select<String>("Status", statuses), UriFilter {
override val param = "status"
override fun toString() = values[state]
}
@ -57,7 +73,9 @@ internal class Category(name: String) : Filter.TriState(name)
*/
internal class CategoryList(
categories: List<String>
) : Filter.Group<Category>("Categories", categories.map(::Category)) {
) : Filter.Group<Category>("Categories", categories.map(::Category)), UriFilter {
override val param = "categories"
override fun toString() = state.filterNot { it.isIgnored() }
.joinToString(",") { if (it.isIncluded()) it.name else "-" + it.name }
}

View File

@ -9,7 +9,7 @@ class MangAdventureGenerator : ThemeSourceGenerator {
override val themeClass = "MangAdventure"
override val baseVersionCode = 6
override val baseVersionCode = 7
override val sources = listOf(
SingleLang("Arc-Relight", "https://arc-relight.com", "en", className = "ArcRelight"),