filter by genres, tags and publishers (#4211)
This commit is contained in:
parent
d7981d8b16
commit
6e5772ecfd
|
@ -1,3 +1,11 @@
|
||||||
|
## 1.2.16
|
||||||
|
|
||||||
|
Minimum Komga version required: `0.59.0`
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* filter by genres, tags and publishers
|
||||||
|
|
||||||
## 1.2.15
|
## 1.2.15
|
||||||
|
|
||||||
Minimum Komga version required: `0.56.0`
|
Minimum Komga version required: `0.56.0`
|
||||||
|
@ -5,6 +13,7 @@ Minimum Komga version required: `0.56.0`
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* remove the 1000 chapters limit
|
* remove the 1000 chapters limit
|
||||||
|
* display series description and tags (genres + tags)
|
||||||
|
|
||||||
## 1.2.14
|
## 1.2.14
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Komga'
|
extName = 'Komga'
|
||||||
pkgNameSuffix = 'all.komga'
|
pkgNameSuffix = 'all.komga'
|
||||||
extClass = '.KomgaFactory'
|
extClass = '.KomgaFactory'
|
||||||
extVersionCode = 15
|
extVersionCode = 16
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,39 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
||||||
url.addQueryParameter("status", statusToInclude.joinToString(","))
|
url.addQueryParameter("status", statusToInclude.joinToString(","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is GenreGroup -> {
|
||||||
|
val genreToInclude = mutableListOf<String>()
|
||||||
|
filter.state.forEach { content ->
|
||||||
|
if (content.state) {
|
||||||
|
genreToInclude.add(content.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (genreToInclude.isNotEmpty()) {
|
||||||
|
url.addQueryParameter("genre", genreToInclude.joinToString(","))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is TagGroup -> {
|
||||||
|
val tagToInclude = mutableListOf<String>()
|
||||||
|
filter.state.forEach { content ->
|
||||||
|
if (content.state) {
|
||||||
|
tagToInclude.add(content.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tagToInclude.isNotEmpty()) {
|
||||||
|
url.addQueryParameter("tag", tagToInclude.joinToString(","))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is PublisherGroup -> {
|
||||||
|
val publisherToInclude = mutableListOf<String>()
|
||||||
|
filter.state.forEach { content ->
|
||||||
|
if (content.state) {
|
||||||
|
publisherToInclude.add(content.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (publisherToInclude.isNotEmpty()) {
|
||||||
|
url.addQueryParameter("publisher", publisherToInclude.joinToString(","))
|
||||||
|
}
|
||||||
|
}
|
||||||
is Filter.Sort -> {
|
is Filter.Sort -> {
|
||||||
var sortCriteria = when (filter.state?.index) {
|
var sortCriteria = when (filter.state?.index) {
|
||||||
0 -> "metadata.titleSort"
|
0 -> "metadata.titleSort"
|
||||||
|
@ -212,6 +245,12 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
||||||
private class StatusFilter(name: String) : Filter.CheckBox(name, false)
|
private class StatusFilter(name: String) : Filter.CheckBox(name, false)
|
||||||
private class StatusGroup(filters: List<StatusFilter>) : Filter.Group<StatusFilter>("Status", filters)
|
private class StatusGroup(filters: List<StatusFilter>) : Filter.Group<StatusFilter>("Status", filters)
|
||||||
private class UnreadOnly : Filter.CheckBox("Unread only", false)
|
private class UnreadOnly : Filter.CheckBox("Unread only", false)
|
||||||
|
private class GenreFilter(genre: String) : Filter.CheckBox(genre, false)
|
||||||
|
private class GenreGroup(genres: List<GenreFilter>) : Filter.Group<GenreFilter>("Genres", genres)
|
||||||
|
private class TagFilter(tag: String) : Filter.CheckBox(tag, false)
|
||||||
|
private class TagGroup(tags: List<TagFilter>) : Filter.Group<TagFilter>("Tags", tags)
|
||||||
|
private class PublisherFilter(publisher: String) : Filter.CheckBox(publisher, false)
|
||||||
|
private class PublisherGroup(publishers: List<PublisherFilter>) : Filter.Group<PublisherFilter>("Publishers", publishers)
|
||||||
|
|
||||||
override fun getFilterList(): FilterList =
|
override fun getFilterList(): FilterList =
|
||||||
FilterList(
|
FilterList(
|
||||||
|
@ -219,11 +258,17 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
||||||
LibraryGroup(libraries.map { LibraryFilter(it.id, it.name) }.sortedBy { it.name.toLowerCase() }),
|
LibraryGroup(libraries.map { LibraryFilter(it.id, it.name) }.sortedBy { it.name.toLowerCase() }),
|
||||||
CollectionGroup(collections.map { CollectionFilter(it.id, it.name) }.sortedBy { it.name.toLowerCase() }),
|
CollectionGroup(collections.map { CollectionFilter(it.id, it.name) }.sortedBy { it.name.toLowerCase() }),
|
||||||
StatusGroup(listOf("Ongoing", "Ended", "Abandoned", "Hiatus").map { StatusFilter(it) }),
|
StatusGroup(listOf("Ongoing", "Ended", "Abandoned", "Hiatus").map { StatusFilter(it) }),
|
||||||
|
GenreGroup(genres.map { GenreFilter(it) }),
|
||||||
|
TagGroup(tags.map { TagFilter(it) }),
|
||||||
|
PublisherGroup(publishers.map { PublisherFilter(it) }),
|
||||||
SeriesSort()
|
SeriesSort()
|
||||||
)
|
)
|
||||||
|
|
||||||
private var libraries = emptyList<LibraryDto>()
|
private var libraries = emptyList<LibraryDto>()
|
||||||
private var collections = emptyList<CollectionDto>()
|
private var collections = emptyList<CollectionDto>()
|
||||||
|
private var genres = emptySet<String>()
|
||||||
|
private var tags = emptySet<String>()
|
||||||
|
private var publishers = emptySet<String>()
|
||||||
|
|
||||||
override val name = "Komga${if (suffix.isNotBlank()) " ($suffix)" else ""}"
|
override val name = "Komga${if (suffix.isNotBlank()) " ($suffix)" else ""}"
|
||||||
override val lang = "en"
|
override val lang = "en"
|
||||||
|
@ -345,6 +390,45 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
|
Single.fromCallable {
|
||||||
|
client.newCall(GET("$baseUrl/api/v1/genres", headers)).execute()
|
||||||
|
}
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ response ->
|
||||||
|
genres = try {
|
||||||
|
gson.fromJson(response.body()?.charStream()!!)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
emptySet()
|
||||||
|
}
|
||||||
|
}, {})
|
||||||
|
|
||||||
|
Single.fromCallable {
|
||||||
|
client.newCall(GET("$baseUrl/api/v1/tags", headers)).execute()
|
||||||
|
}
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ response ->
|
||||||
|
tags = try {
|
||||||
|
gson.fromJson(response.body()?.charStream()!!)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
emptySet()
|
||||||
|
}
|
||||||
|
}, {})
|
||||||
|
|
||||||
|
Single.fromCallable {
|
||||||
|
client.newCall(GET("$baseUrl/api/v1/publishers", headers)).execute()
|
||||||
|
}
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ response ->
|
||||||
|
publishers = try {
|
||||||
|
gson.fromJson(response.body()?.charStream()!!)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
emptySet()
|
||||||
|
}
|
||||||
|
}, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -32,9 +32,9 @@ data class SeriesMetadataDto(
|
||||||
val ageRatingLock: Boolean,
|
val ageRatingLock: Boolean,
|
||||||
val language: String,
|
val language: String,
|
||||||
val languageLock: Boolean,
|
val languageLock: Boolean,
|
||||||
val genres: Set<String>?, //TODO: remove optional in next iteration
|
val genres: Set<String>?, // TODO: remove optional in next iteration
|
||||||
val genresLock: Boolean,
|
val genresLock: Boolean,
|
||||||
val tags: Set<String>?, //TODO: remove optional in next iteration
|
val tags: Set<String>?, // TODO: remove optional in next iteration
|
||||||
val tagsLock: Boolean
|
val tagsLock: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue