fix: fixed a bug where the server returned a 404 error due to receiving data in HikkaApi

This commit is contained in:
Lorg0n 2024-10-27 02:25:24 +03:00
parent 6b8c2dcdc3
commit 45cd945f7c

View file

@ -4,8 +4,8 @@ import android.net.Uri
import androidx.core.net.toUri import androidx.core.net.toUri
import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.database.models.Track
import eu.kanade.tachiyomi.data.track.hikka.dto.HKAuthTokenInfo import eu.kanade.tachiyomi.data.track.hikka.dto.HKAuthTokenInfo
import eu.kanade.tachiyomi.data.track.hikka.dto.HKMangaPagination
import eu.kanade.tachiyomi.data.track.hikka.dto.HKManga import eu.kanade.tachiyomi.data.track.hikka.dto.HKManga
import eu.kanade.tachiyomi.data.track.hikka.dto.HKMangaPagination
import eu.kanade.tachiyomi.data.track.hikka.dto.HKOAuth import eu.kanade.tachiyomi.data.track.hikka.dto.HKOAuth
import eu.kanade.tachiyomi.data.track.hikka.dto.HKRead import eu.kanade.tachiyomi.data.track.hikka.dto.HKRead
import eu.kanade.tachiyomi.data.track.hikka.dto.HKUser import eu.kanade.tachiyomi.data.track.hikka.dto.HKUser
@ -100,17 +100,18 @@ class HikkaApi(
} }
} }
private suspend fun getRead(track: Track): HKRead { private suspend fun getRead(track: Track): HKRead? {
return withIOContext { return withIOContext {
val slug = track.tracking_url.split("/")[4] val slug = track.tracking_url.split("/")[4]
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon().build()
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
.build()
with(json) { with(json) {
authClient.newCall(GET(url.toString())) val response = authClient.newCall(GET(url.toString())).execute()
.awaitSuccess() if (response.code == 404) {
.parseAs<HKRead>() return@withIOContext null
}
response.use {
it.parseAs<HKRead>()
}
} }
} }
} }
@ -150,7 +151,7 @@ class HikkaApi(
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon() val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
.build() .build()
var rereads = getRead(track).rereads var rereads = getRead(track)?.rereads ?: 0
if (track.status == Hikka.REREADING && rereads == 0) { if (track.status == Hikka.REREADING && rereads == 0) {
rereads = 1 rereads = 1
} }