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