[Komga] series metadata (#2197)

* handle Series status
add filter for Series status

* use Series title instead of name
sort by titleSort instead of name
This commit is contained in:
Gauthier 2020-02-06 19:54:30 +08:00 committed by GitHub
parent 9ec115594e
commit 0e59671851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 5 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Komga'
pkgNameSuffix = 'all.komga'
extClass = '.Komga'
extVersionCode = 6
extVersionCode = 7
libVersion = '1.2'
}

View File

@ -51,9 +51,20 @@ open class Komga : ConfigurableSource, HttpSource() {
url.addQueryParameter("library_id", libraryToInclude.joinToString(","))
}
}
is StatusGroup -> {
val statusToInclude = mutableListOf<String>()
filter.state.forEach { content ->
if (content.state) {
statusToInclude.add(content.name.toUpperCase(Locale.ROOT))
}
}
if (statusToInclude.isNotEmpty()) {
url.addQueryParameter("status", statusToInclude.joinToString(","))
}
}
is Filter.Sort -> {
var sortCriteria = when (filter.state?.index) {
0 -> "name"
0 -> "metadata.titleSort"
1 -> "createdDate"
2 -> "lastModifiedDate"
else -> ""
@ -125,10 +136,14 @@ open class Komga : ConfigurableSource, HttpSource() {
private fun SeriesDto.toSManga(): SManga =
SManga.create().apply {
title = name
title = metadata.title
url = "/api/v1/series/${id}"
thumbnail_url = "$baseUrl/api/v1/series/${id}/thumbnail"
status = SManga.UNKNOWN
status = when (metadata.status) {
"ONGOING" -> SManga.ONGOING
"ENDED" -> SManga.COMPLETED
else -> SManga.UNKNOWN
}
}
private fun parseDate(date: String?): Long =
@ -151,10 +166,13 @@ open class Komga : ConfigurableSource, HttpSource() {
private class LibraryFilter(val id: Long, name: String) : Filter.CheckBox(name, false)
private class LibraryGroup(libraries: List<LibraryFilter>) : Filter.Group<LibraryFilter>("Libraries", libraries)
private class SeriesSort : Filter.Sort("Sort", arrayOf("Alphabetically", "Date added", "Date updated"), Filter.Sort.Selection(0, true))
private class StatusFilter(name: String) : Filter.CheckBox(name, false)
private class StatusGroup(filters: List<StatusFilter>) : Filter.Group<StatusFilter>("Status", filters)
override fun getFilterList(): FilterList =
FilterList(
LibraryGroup(libraries.map { LibraryFilter(it.id, it.name) }.sortedBy { it.name }),
StatusGroup(listOf("Ongoing", "Ended", "Abandoned", "Hiatus").map { StatusFilter(it) }),
SeriesSort()
)

View File

@ -12,7 +12,16 @@ data class SeriesDto(
val created: String?,
val lastModified: String?,
val fileLastModified: String,
val booksCount: Int
val booksCount: Int,
val metadata: SeriesMetadataDto
)
data class SeriesMetadataDto(
val status: String,
val created: String?,
val lastModified: String?,
val title: String,
val titleSort: String
)
data class BookDto(