Compare commits

...

7 Commits

Author SHA1 Message Date
Lorg0n
0430b85ecc style: nothing change 2025-01-02 02:54:49 +03:00
Lorg0n
f49edd6160 ref: deleted unnecessary comment 2025-01-02 02:53:59 +03:00
Lorg0n
0ec0637d47 feat: change logic of binding track from Hikka source 2025-01-02 02:51:35 +03:00
Lorg0n
07eae5943d ref: deleted deleted unnecessary imports 2025-01-02 01:47:38 +03:00
Lorg0n
0cc46974fa ref: deleted unnecessary fields in the HKUser 2025-01-02 01:47:14 +03:00
Lorg0n
10bc14aaa7 feat: changed the buffer time to check the token for expiry 2025-01-02 01:42:25 +03:00
Lorg0n
6f35cb4ae3 fix: update the API link by replacing the deprecated one 2025-01-02 01:40:55 +03:00
5 changed files with 15 additions and 12 deletions

View File

@ -102,6 +102,7 @@ class Hikka(id: Long) : BaseTracker(id, "Hikka"), DeletableTracker {
}
override suspend fun bind(track: Track, hasReadChapters: Boolean): Track {
val readContent = api.getRead(track)
val remoteTrack = api.getManga(track)
track.copyPersonalFrom(remoteTrack)
@ -112,7 +113,15 @@ class Hikka(id: Long) : BaseTracker(id, "Hikka"), DeletableTracker {
track.status = if (!isRereading && hasReadChapters) READING else track.status
}
return update(track)
return if (readContent != null) {
track.score = readContent.score.toDouble()
track.last_chapter_read = readContent.chapters.toDouble()
track.score = readContent.score.toDouble()
update(track)
} else {
track.score = 0.0
update(track)
}
}
override suspend fun search(query: String): List<TrackSearch> {

View File

@ -97,7 +97,7 @@ class HikkaApi(
}
}
private suspend fun getRead(track: Track): HKRead? {
suspend fun getRead(track: Track): HKRead? {
return withIOContext {
val slug = track.tracking_url.split("/")[4]
val url = "$BASE_API_URL/read/manga/$slug".toUri().buildUpon().build()
@ -177,7 +177,7 @@ class HikkaApi(
private val authClient = client.newBuilder().addInterceptor(interceptor).build()
companion object {
const val BASE_API_URL = "https://hikka.io/api"
const val BASE_API_URL = "https://api.hikka.io"
const val BASE_URL = "https://hikka.io"
private const val SCOPE = "readlist,read:user-details"
private const val CLIENT_REFERENCE = "49eda83d-baa6-45f8-9936-b2a41d944da4"

View File

@ -29,7 +29,6 @@ data class HKManga(
title = this@HKManga.titleUa ?: this@HKManga.titleEn ?: this@HKManga.titleOriginal
total_chapters = this@HKManga.chapters?.toLong() ?: 0
cover_url = this@HKManga.image
summary = ""
score = this@HKManga.score
tracking_url = HikkaApi.BASE_URL + "/manga/${this@HKManga.slug}"
publishing_status = this@HKManga.status

View File

@ -10,6 +10,8 @@ data class HKOAuth(
val created: Long,
) {
fun isExpired(): Boolean {
return (expiration - 43200) < (System.currentTimeMillis() / 1000)
val currentTime = System.currentTimeMillis() / 1000
val buffer = 5 * 60 // safety margin
return currentTime >= (expiration - buffer)
}
}

View File

@ -5,12 +5,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class HKUser(
val reference: String,
val updated: Long,
val created: Long,
val description: String,
val username: String,
val cover: String,
val active: Boolean,
val avatar: String,
val role: String,
)