diff --git a/src/all/komga/build.gradle b/src/all/komga/build.gradle index ea1e7ff3c..4f336ee09 100644 --- a/src/all/komga/build.gradle +++ b/src/all/komga/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: Komga' pkgNameSuffix = 'all.komga' extClass = '.Komga' - extVersionCode = 6 + extVersionCode = 7 libVersion = '1.2' } diff --git a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt index dc4d7b76d..2ba28b00e 100644 --- a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt +++ b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt @@ -51,9 +51,20 @@ open class Komga : ConfigurableSource, HttpSource() { url.addQueryParameter("library_id", libraryToInclude.joinToString(",")) } } + is StatusGroup -> { + val statusToInclude = mutableListOf() + 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) : Filter.Group("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) : Filter.Group("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() ) diff --git a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt index 1adb737f0..0138550a7 100644 --- a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt +++ b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt @@ -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(