MangAdventure: Add more statuses in search filters + general cleanup (#533)
This commit is contained in:
parent
d976177365
commit
5710e5634e
|
@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.AppInfo
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
|
@ -13,7 +14,6 @@ import kotlinx.serialization.json.decodeFromJsonElement
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import eu.kanade.tachiyomi.source.model.Page as SPage
|
|
||||||
|
|
||||||
/** MangAdventure base source. */
|
/** MangAdventure base source. */
|
||||||
abstract class MangAdventure(
|
abstract class MangAdventure(
|
||||||
|
@ -25,7 +25,7 @@ abstract class MangAdventure(
|
||||||
protected open val categories = DEFAULT_CATEGORIES
|
protected open val categories = DEFAULT_CATEGORIES
|
||||||
|
|
||||||
/** The site's manga status names. */
|
/** The site's manga status names. */
|
||||||
protected open val statuses = arrayOf("Any", "Completed", "Ongoing")
|
protected open val statuses = arrayOf("Any", "Completed", "Ongoing", "Hiatus", "Cancelled")
|
||||||
|
|
||||||
/** The site's sort order labels that correspond to [SortOrder.values]. */
|
/** The site's sort order labels that correspond to [SortOrder.values]. */
|
||||||
protected open val orders = arrayOf(
|
protected open val orders = arrayOf(
|
||||||
|
@ -36,9 +36,8 @@ abstract class MangAdventure(
|
||||||
)
|
)
|
||||||
|
|
||||||
/** A user agent representing Tachiyomi. */
|
/** A user agent representing Tachiyomi. */
|
||||||
private val userAgent = "Mozilla/5.0 " +
|
private val userAgent =
|
||||||
"(Android ${VERSION.RELEASE}; Mobile) " +
|
"Mozilla/5.0 (Android ${VERSION.RELEASE}; Mobile) Tachiyomi/${AppInfo.getVersionName()}"
|
||||||
"Tachiyomi/${AppInfo.getVersionName()}"
|
|
||||||
|
|
||||||
/** The URL of the site's API. */
|
/** The URL of the site's API. */
|
||||||
private val apiUrl by lazy { "$baseUrl/api/v2" }
|
private val apiUrl by lazy { "$baseUrl/api/v2" }
|
||||||
|
@ -62,7 +61,7 @@ abstract class MangAdventure(
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList) =
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList) =
|
||||||
apiUrl.toHttpUrl().newBuilder().addEncodedPathSegment("series").run {
|
apiUrl.toHttpUrl().newBuilder().addEncodedPathSegment("series").run {
|
||||||
if (query.startsWith(SLUG_QUERY)) {
|
if (query.startsWith(SLUG_QUERY)) {
|
||||||
addQueryParameter("slug", query.substring(SLUG_QUERY.length))
|
addQueryParameter("slug", query.substringAfter(SLUG_QUERY))
|
||||||
} else {
|
} else {
|
||||||
addQueryParameter("page", page.toString())
|
addQueryParameter("page", page.toString())
|
||||||
addQueryParameter("title", query)
|
addQueryParameter("title", query)
|
||||||
|
@ -70,6 +69,7 @@ abstract class MangAdventure(
|
||||||
addQueryParameter(it.param, it.toString())
|
addQueryParameter(it.param, it.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GET(build(), headers)
|
GET(build(), headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ abstract class MangAdventure(
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
url = chapter.id.toString()
|
url = chapter.id.toString()
|
||||||
name = buildString {
|
name = buildString {
|
||||||
append(chapter.full_title)
|
append(chapter.fullTitle)
|
||||||
if (chapter.final) append(" [END]")
|
if (chapter.final) append(" [END]")
|
||||||
}
|
}
|
||||||
chapter_number = chapter.number
|
chapter_number = chapter.number
|
||||||
|
@ -111,8 +111,8 @@ abstract class MangAdventure(
|
||||||
response.decode<Series>().let(::mangaFromJSON)
|
response.decode<Series>().let(::mangaFromJSON)
|
||||||
|
|
||||||
override fun pageListParse(response: Response) =
|
override fun pageListParse(response: Response) =
|
||||||
response.decode<Results<Page>>().map { page ->
|
response.decode<Results<MAPage>>().map { page ->
|
||||||
SPage(page.number, page.url, page.image)
|
Page(page.number, imageUrl = page.image)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(response: Response) =
|
override fun imageUrlParse(response: Response) =
|
||||||
|
@ -126,8 +126,8 @@ abstract class MangAdventure(
|
||||||
FilterList(
|
FilterList(
|
||||||
Author(),
|
Author(),
|
||||||
Artist(),
|
Artist(),
|
||||||
SortOrder(orders),
|
|
||||||
Status(statuses),
|
Status(statuses),
|
||||||
|
SortOrder(orders),
|
||||||
CategoryList(categories),
|
CategoryList(categories),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,37 @@
|
||||||
package eu.kanade.tachiyomi.multisrc.mangadventure
|
package eu.kanade.tachiyomi.multisrc.mangadventure
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
/** Generic results wrapper schema. */
|
/** Generic results wrapper schema. */
|
||||||
@kotlinx.serialization.Serializable
|
@Serializable
|
||||||
internal class Results<T>(
|
internal class Results<T>(
|
||||||
private val results: List<T>,
|
private val results: List<T>,
|
||||||
) : Iterable<T> by results
|
) : Iterable<T> by results
|
||||||
|
|
||||||
/** Generic paginator schema. */
|
/** Generic paginator schema. */
|
||||||
@kotlinx.serialization.Serializable
|
@Serializable
|
||||||
internal class Paginator<T>(
|
internal class Paginator<T>(
|
||||||
val last: Boolean,
|
val last: Boolean,
|
||||||
private val results: List<T>,
|
private val results: List<T>,
|
||||||
) : Iterable<T> by results
|
) : Iterable<T> by results
|
||||||
|
|
||||||
/** Page model schema. */
|
/** Page model schema. */
|
||||||
@kotlinx.serialization.Serializable
|
@Serializable
|
||||||
internal data class Page(
|
internal data class MAPage(
|
||||||
private val id: Int,
|
private val id: Int,
|
||||||
val image: String,
|
val image: String,
|
||||||
val number: Int,
|
val number: Int,
|
||||||
val url: String,
|
val url: String,
|
||||||
) {
|
) {
|
||||||
override fun equals(other: Any?) =
|
override fun equals(other: Any?) =
|
||||||
this === other || other is Page && id == other.id
|
this === other || other is MAPage && id == other.id
|
||||||
|
|
||||||
override fun hashCode() = id
|
override fun hashCode() = id
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Chapter model schema. */
|
/** Chapter model schema. */
|
||||||
@kotlinx.serialization.Serializable
|
@Serializable
|
||||||
internal data class Chapter(
|
internal data class Chapter(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val title: String,
|
val title: String,
|
||||||
|
@ -38,7 +41,7 @@ internal data class Chapter(
|
||||||
val final: Boolean,
|
val final: Boolean,
|
||||||
val series: String,
|
val series: String,
|
||||||
val groups: List<String>,
|
val groups: List<String>,
|
||||||
val full_title: String,
|
@SerialName("full_title") val fullTitle: String,
|
||||||
) {
|
) {
|
||||||
override fun equals(other: Any?) =
|
override fun equals(other: Any?) =
|
||||||
this === other || other is Chapter && id == other.id
|
this === other || other is Chapter && id == other.id
|
||||||
|
@ -47,7 +50,7 @@ internal data class Chapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Series model schema. */
|
/** Series model schema. */
|
||||||
@kotlinx.serialization.Serializable
|
@Serializable
|
||||||
internal data class Series(
|
internal data class Series(
|
||||||
val slug: String,
|
val slug: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
|
|
|
@ -9,7 +9,7 @@ class MangAdventureGenerator : ThemeSourceGenerator {
|
||||||
|
|
||||||
override val themeClass = "MangAdventure"
|
override val themeClass = "MangAdventure"
|
||||||
|
|
||||||
override val baseVersionCode = 12
|
override val baseVersionCode = 13
|
||||||
|
|
||||||
override val sources = listOf(
|
override val sources = listOf(
|
||||||
SingleLang("Arc-Relight", "https://arc-relight.com", "en", className = "ArcRelight"),
|
SingleLang("Arc-Relight", "https://arc-relight.com", "en", className = "ArcRelight"),
|
||||||
|
|
Loading…
Reference in New Issue