compatibility for the upcoming version of Komga which have changes in the API (IDs are String instead of Long) (#3792)
This commit is contained in:
parent
1699c7a78c
commit
7a9de141d2
|
@ -1,4 +1,12 @@
|
|||
## [1.2.12]
|
||||
## 1.2.13
|
||||
|
||||
Requires Komga `0.41.0`
|
||||
|
||||
### Features
|
||||
|
||||
* compatibility for the upcoming version of Komga which have changes in the API (IDs are String instead of Long)
|
||||
|
||||
## 1.2.12
|
||||
|
||||
Requires Komga `0.41.0`
|
||||
|
||||
|
@ -6,7 +14,7 @@ Requires Komga `0.41.0`
|
|||
|
||||
* filter by collection
|
||||
|
||||
## [1.2.11]
|
||||
## 1.2.11
|
||||
|
||||
Requires Komga `0.35.2`
|
||||
|
||||
|
@ -14,7 +22,7 @@ Requires Komga `0.35.2`
|
|||
|
||||
* Set password preferences inputTypes
|
||||
|
||||
## [1.2.10]
|
||||
## 1.2.10
|
||||
|
||||
Requires Komga `0.35.2`
|
||||
|
||||
|
@ -23,7 +31,7 @@ Requires Komga `0.35.2`
|
|||
* unread only filter (closes gotson/komga#180)
|
||||
* prefix book titles with number (closes gotson/komga#169)
|
||||
|
||||
## [1.2.9]
|
||||
## 1.2.9
|
||||
|
||||
Requires Komga `0.22.0`
|
||||
|
||||
|
@ -31,7 +39,7 @@ Requires Komga `0.22.0`
|
|||
|
||||
* use SourceFactory to have multiple Komga servers (3 for the moment)
|
||||
|
||||
## [1.2.8]
|
||||
## 1.2.8
|
||||
|
||||
Requires Komga `0.22.0`
|
||||
|
||||
|
@ -40,44 +48,44 @@ Requires Komga `0.22.0`
|
|||
* use book metadata title for chapter display name
|
||||
* use book metadata sort number for chapter number
|
||||
|
||||
## [1.2.7]
|
||||
## 1.2.7
|
||||
|
||||
### Features
|
||||
|
||||
* use series metadata title for display name
|
||||
* filter on series status
|
||||
|
||||
## [1.2.6]
|
||||
## 1.2.6
|
||||
|
||||
### Features
|
||||
|
||||
* Add support for AndroidX preferences
|
||||
|
||||
## [1.2.5]
|
||||
## 1.2.5
|
||||
|
||||
### Features
|
||||
|
||||
* add sort options in filter
|
||||
|
||||
## [1.2.4]
|
||||
## 1.2.4
|
||||
|
||||
### Features
|
||||
|
||||
* better handling of authentication
|
||||
|
||||
## [1.2.3]
|
||||
## 1.2.3
|
||||
|
||||
### Features
|
||||
|
||||
* filters by library
|
||||
|
||||
## [1.2.2]
|
||||
## 1.2.2
|
||||
|
||||
### Features
|
||||
|
||||
* request converted image from server if format is not supported
|
||||
|
||||
## [1.2.1]
|
||||
## 1.2.1
|
||||
|
||||
### Features
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
|||
extName = 'Komga'
|
||||
pkgNameSuffix = 'all.komga'
|
||||
extClass = '.KomgaFactory'
|
||||
extVersionCode = 12
|
||||
extVersionCode = 13
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,15 @@ import com.github.salomonbrys.kotson.fromJson
|
|||
import com.google.gson.Gson
|
||||
import eu.kanade.tachiyomi.extension.BuildConfig
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.BookDto
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.BookDtoOld
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.CollectionDto
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.CollectionDtoOld
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.LibraryDto
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.LibraryDtoOld
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.PageDto
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.PageWrapperDto
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.SeriesDto
|
||||
import eu.kanade.tachiyomi.extension.all.komga.dto.SeriesDtoOld
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
|
@ -24,10 +28,6 @@ import eu.kanade.tachiyomi.source.model.Page
|
|||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import java.text.DecimalFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl
|
||||
|
@ -39,6 +39,10 @@ import rx.android.schedulers.AndroidSchedulers
|
|||
import rx.schedulers.Schedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.DecimalFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
||||
override fun popularMangaRequest(page: Int): Request =
|
||||
|
@ -64,7 +68,7 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
}
|
||||
}
|
||||
is LibraryGroup -> {
|
||||
val libraryToInclude = mutableListOf<Long>()
|
||||
val libraryToInclude = mutableListOf<String>()
|
||||
filter.state.forEach { content ->
|
||||
if (content.state) {
|
||||
libraryToInclude.add(content.id)
|
||||
|
@ -75,7 +79,7 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
}
|
||||
}
|
||||
is CollectionGroup -> {
|
||||
val collectionToInclude = mutableListOf<Long>()
|
||||
val collectionToInclude = mutableListOf<String>()
|
||||
filter.state.forEach { content ->
|
||||
if (content.state) {
|
||||
collectionToInclude.add(content.id)
|
||||
|
@ -121,7 +125,12 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
GET(baseUrl + manga.url, headers)
|
||||
|
||||
override fun mangaDetailsParse(response: Response): SManga {
|
||||
val series = gson.fromJson<SeriesDto>(response.body()?.charStream()!!)
|
||||
val series = try {
|
||||
gson.fromJson<SeriesDto>(response.body()?.charStream()!!)
|
||||
} catch (e: Exception) {
|
||||
gson.fromJson<SeriesDtoOld>(response.body()?.charStream()!!)
|
||||
.toSeriesDto()
|
||||
}
|
||||
return series.toSManga()
|
||||
}
|
||||
|
||||
|
@ -129,9 +138,14 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
GET("$baseUrl${manga.url}/books?size=1000&media_status=READY", headers)
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val page = gson.fromJson<PageWrapperDto<BookDto>>(response.body()?.charStream()!!)
|
||||
val page = try {
|
||||
gson.fromJson<PageWrapperDto<BookDto>>(response.body()?.charStream()!!).content
|
||||
} catch (e: Exception) {
|
||||
gson.fromJson<PageWrapperDto<BookDtoOld>>(response.body()?.charStream()!!).content
|
||||
.map { it.toBookDto() }
|
||||
}
|
||||
|
||||
return page.content.map { book ->
|
||||
return page.map { book ->
|
||||
SChapter.create().apply {
|
||||
chapter_number = book.metadata.numberSort
|
||||
name = "${decimalFormat.format(book.metadata.numberSort)} - ${book.metadata.title} (${book.size})"
|
||||
|
@ -161,11 +175,22 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
}
|
||||
|
||||
private fun processSeriesPage(response: Response): MangasPage {
|
||||
val page = gson.fromJson<PageWrapperDto<SeriesDto>>(response.body()?.charStream()!!)
|
||||
val mangas = page.content.map {
|
||||
var lastPage: Boolean
|
||||
val page = try {
|
||||
with(gson.fromJson<PageWrapperDto<SeriesDto>>(response.body()?.charStream()!!)) {
|
||||
lastPage = last
|
||||
content
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
with(gson.fromJson<PageWrapperDto<SeriesDtoOld>>(response.body()?.charStream()!!)) {
|
||||
lastPage = last
|
||||
content.map { it.toSeriesDto() }
|
||||
}
|
||||
}
|
||||
val mangas = page.map {
|
||||
it.toSManga()
|
||||
}
|
||||
return MangasPage(mangas, !page.last)
|
||||
return MangasPage(mangas, !lastPage)
|
||||
}
|
||||
|
||||
private fun SeriesDto.toSManga(): SManga =
|
||||
|
@ -197,9 +222,9 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
|
||||
override fun imageUrlParse(response: Response): String = ""
|
||||
|
||||
private class LibraryFilter(val id: Long, name: String) : Filter.CheckBox(name, false)
|
||||
private class LibraryFilter(val id: String, name: String) : Filter.CheckBox(name, false)
|
||||
private class LibraryGroup(libraries: List<LibraryFilter>) : Filter.Group<LibraryFilter>("Libraries", libraries)
|
||||
private class CollectionFilter(val id: Long, name: String) : Filter.CheckBox(name, false)
|
||||
private class CollectionFilter(val id: String, name: String) : Filter.CheckBox(name, false)
|
||||
private class CollectionGroup(collections: List<CollectionFilter>) : Filter.Group<CollectionFilter>("Collections", collections)
|
||||
private class SeriesSort : Filter.Sort("Sort", arrayOf("Alphabetically", "Date added", "Date updated"), Selection(0, true))
|
||||
private class StatusFilter(name: String) : Filter.CheckBox(name, false)
|
||||
|
@ -320,11 +345,16 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
.subscribe({ response ->
|
||||
libraries = try {
|
||||
gson.fromJson(it.body()?.charStream()!!)
|
||||
gson.fromJson(response.body()?.charStream()!!)
|
||||
} catch (e: Exception) {
|
||||
emptyList()
|
||||
try {
|
||||
gson.fromJson<List<LibraryDtoOld>>(response.body()?.charStream()!!)
|
||||
.map { it.toLibraryDto() }
|
||||
} catch (e: Exception) {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}, {})
|
||||
|
||||
|
@ -333,11 +363,16 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
.subscribe({ response ->
|
||||
collections = try {
|
||||
gson.fromJson<PageWrapperDto<CollectionDto>>(it.body()?.charStream()!!).content
|
||||
gson.fromJson<PageWrapperDto<CollectionDto>>(response.body()?.charStream()!!).content
|
||||
} catch (e: Exception) {
|
||||
emptyList()
|
||||
try {
|
||||
gson.fromJson<PageWrapperDto<CollectionDtoOld>>(response.body()?.charStream()!!).content
|
||||
.map { it.toCollectionDto() }
|
||||
} catch (e: Exception) {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}, {})
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package eu.kanade.tachiyomi.extension.all.komga.dto
|
||||
|
||||
data class LibraryDto(
|
||||
val id: Long,
|
||||
val id: String,
|
||||
val name: String
|
||||
)
|
||||
|
||||
data class SeriesDto(
|
||||
val id: Long,
|
||||
val libraryId: Long,
|
||||
val id: String,
|
||||
val libraryId: String,
|
||||
val name: String,
|
||||
val created: String?,
|
||||
val lastModified: String?,
|
||||
|
@ -25,8 +25,8 @@ data class SeriesMetadataDto(
|
|||
)
|
||||
|
||||
data class BookDto(
|
||||
val id: Long,
|
||||
val seriesId: Long,
|
||||
val id: String,
|
||||
val seriesId: String,
|
||||
val name: String,
|
||||
val number: Float,
|
||||
val created: String?,
|
||||
|
@ -77,7 +77,7 @@ data class AuthorDto(
|
|||
)
|
||||
|
||||
data class CollectionDto(
|
||||
val id: Long,
|
||||
val id: String,
|
||||
val name: String,
|
||||
val ordered: Boolean,
|
||||
val seriesIds: List<Long>,
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package eu.kanade.tachiyomi.extension.all.komga.dto
|
||||
|
||||
data class LibraryDtoOld(
|
||||
val id: Long,
|
||||
val name: String
|
||||
) {
|
||||
fun toLibraryDto() = LibraryDto(id.toString(), name)
|
||||
}
|
||||
|
||||
data class SeriesDtoOld(
|
||||
val id: Long,
|
||||
val libraryId: Long,
|
||||
val name: String,
|
||||
val created: String?,
|
||||
val lastModified: String?,
|
||||
val fileLastModified: String,
|
||||
val booksCount: Int,
|
||||
val metadata: SeriesMetadataDto
|
||||
) {
|
||||
fun toSeriesDto() = SeriesDto(id.toString(), libraryId.toString(), name, created, lastModified, fileLastModified, booksCount, metadata)
|
||||
}
|
||||
|
||||
data class BookDtoOld(
|
||||
val id: Long,
|
||||
val seriesId: Long,
|
||||
val name: String,
|
||||
val number: Float,
|
||||
val created: String?,
|
||||
val lastModified: String?,
|
||||
val fileLastModified: String,
|
||||
val sizeBytes: Long,
|
||||
val size: String,
|
||||
val media: MediaDto,
|
||||
val metadata: BookMetadataDto
|
||||
) {
|
||||
fun toBookDto() = BookDto(id.toString(), seriesId.toString(), name, number, created, lastModified, fileLastModified, sizeBytes, size, media, metadata)
|
||||
}
|
||||
|
||||
data class CollectionDtoOld(
|
||||
val id: Long,
|
||||
val name: String,
|
||||
val ordered: Boolean,
|
||||
val seriesIds: List<Long>,
|
||||
val createdDate: String,
|
||||
val lastModifiedDate: String,
|
||||
val filtered: Boolean
|
||||
) {
|
||||
fun toCollectionDto() = CollectionDto(id.toString(), name, ordered, seriesIds, createdDate, lastModifiedDate, filtered)
|
||||
}
|
Loading…
Reference in New Issue