|
@@ -38,9 +38,11 @@ class KomgaApi(private val client: OkHttpClient) {
|
|
}
|
|
}
|
|
|
|
|
|
val progress = client
|
|
val progress = client
|
|
- .newCall(GET("$url/read-progress/tachiyomi"))
|
|
|
|
- .await()
|
|
|
|
- .parseAs<ReadProgressDto>()
|
|
|
|
|
|
+ .newCall(GET("${url.replace("/api/v1/series/", "/api/v2/series/")}/read-progress/tachiyomi"))
|
|
|
|
+ .await().let {
|
|
|
|
+ if (url.contains("/api/v1/series/")) it.parseAs<ReadProgressV2Dto>()
|
|
|
|
+ else it.parseAs<ReadProgressDto>().toV2()
|
|
|
|
+ }
|
|
|
|
|
|
track.apply {
|
|
track.apply {
|
|
cover_url = "$url/thumbnail"
|
|
cover_url = "$url/thumbnail"
|
|
@@ -51,7 +53,7 @@ class KomgaApi(private val client: OkHttpClient) {
|
|
progress.booksReadCount -> Komga.COMPLETED
|
|
progress.booksReadCount -> Komga.COMPLETED
|
|
else -> Komga.READING
|
|
else -> Komga.READING
|
|
}
|
|
}
|
|
- last_chapter_read = progress.lastReadContinuousIndex.toFloat()
|
|
|
|
|
|
+ last_chapter_read = progress.lastReadContinuousNumberSort
|
|
}
|
|
}
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
Timber.w(e, "Could not get item: $url")
|
|
Timber.w(e, "Could not get item: $url")
|
|
@@ -60,11 +62,14 @@ class KomgaApi(private val client: OkHttpClient) {
|
|
}
|
|
}
|
|
|
|
|
|
suspend fun updateProgress(track: Track): Track {
|
|
suspend fun updateProgress(track: Track): Track {
|
|
- val progress = ReadProgressUpdateDto(track.last_chapter_read.toInt())
|
|
|
|
- val payload = json.encodeToString(progress)
|
|
|
|
|
|
+ val payload = if (track.tracking_url.contains("/api/v1/series/")) {
|
|
|
|
+ json.encodeToString(ReadProgressUpdateV2Dto(track.last_chapter_read))
|
|
|
|
+ } else {
|
|
|
|
+ json.encodeToString(ReadProgressUpdateDto(track.last_chapter_read.toInt()))
|
|
|
|
+ }
|
|
client.newCall(
|
|
client.newCall(
|
|
Request.Builder()
|
|
Request.Builder()
|
|
- .url("${track.tracking_url}/read-progress/tachiyomi")
|
|
|
|
|
|
+ .url("${track.tracking_url.replace("/api/v1/series/", "/api/v2/series/")}/read-progress/tachiyomi")
|
|
.put(payload.toRequestBody("application/json".toMediaType()))
|
|
.put(payload.toRequestBody("application/json".toMediaType()))
|
|
.build()
|
|
.build()
|
|
)
|
|
)
|