mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-25 02:18:24 +01:00
Don't automatically set MAL start date (closes #4349)
This commit is contained in:
parent
6662e2002f
commit
13d25e0849
@ -22,9 +22,6 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
const val PLANNING = 5
|
const val PLANNING = 5
|
||||||
const val REPEATING = 6
|
const val REPEATING = 6
|
||||||
|
|
||||||
const val DEFAULT_STATUS = READING
|
|
||||||
const val DEFAULT_SCORE = 0
|
|
||||||
|
|
||||||
const val POINT_100 = "POINT_100"
|
const val POINT_100 = "POINT_100"
|
||||||
const val POINT_10 = "POINT_10"
|
const val POINT_10 = "POINT_10"
|
||||||
const val POINT_10_DECIMAL = "POINT_10_DECIMAL"
|
const val POINT_10_DECIMAL = "POINT_10_DECIMAL"
|
||||||
@ -154,8 +151,8 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
update(track)
|
update(track)
|
||||||
} else {
|
} else {
|
||||||
// Set default fields if it's not found in the list
|
// Set default fields if it's not found in the list
|
||||||
track.score = DEFAULT_SCORE.toFloat()
|
track.status = READING
|
||||||
track.status = DEFAULT_STATUS
|
track.score = 0F
|
||||||
add(track)
|
add(track)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
refresh(track)
|
refresh(track)
|
||||||
} else {
|
} else {
|
||||||
// Set default fields if it's not found in the list
|
// Set default fields if it's not found in the list
|
||||||
track.score = DEFAULT_SCORE.toFloat()
|
track.status = READING
|
||||||
track.status = DEFAULT_STATUS
|
track.score = 0F
|
||||||
add(track)
|
add(track)
|
||||||
update(track)
|
update(track)
|
||||||
}
|
}
|
||||||
@ -128,8 +128,5 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
const val ON_HOLD = 4
|
const val ON_HOLD = 4
|
||||||
const val DROPPED = 5
|
const val DROPPED = 5
|
||||||
const val PLANNING = 1
|
const val PLANNING = 1
|
||||||
|
|
||||||
const val DEFAULT_STATUS = READING
|
|
||||||
const val DEFAULT_SCORE = 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.util.lang.withIOContext
|
|||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.float
|
|
||||||
import kotlinx.serialization.json.int
|
import kotlinx.serialization.json.int
|
||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
@ -101,20 +100,6 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun jsonToTrack(mangas: JsonObject): Track {
|
|
||||||
return Track.create(TrackManager.BANGUMI).apply {
|
|
||||||
title = mangas["name"]!!.jsonPrimitive.content
|
|
||||||
media_id = mangas["id"]!!.jsonPrimitive.int
|
|
||||||
score = try {
|
|
||||||
mangas["rating"]!!.jsonObject["score"]!!.jsonPrimitive.float
|
|
||||||
} catch (_: Exception) {
|
|
||||||
0f
|
|
||||||
}
|
|
||||||
status = Bangumi.DEFAULT_STATUS
|
|
||||||
tracking_url = mangas["url"]!!.jsonPrimitive.content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun findLibManga(track: Track): Track? {
|
suspend fun findLibManga(track: Track): Track? {
|
||||||
return withIOContext {
|
return withIOContext {
|
||||||
authClient.newCall(GET("$apiUrl/subject/${track.media_id}"))
|
authClient.newCall(GET("$apiUrl/subject/${track.media_id}"))
|
||||||
|
@ -21,9 +21,6 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
const val ON_HOLD = 3
|
const val ON_HOLD = 3
|
||||||
const val DROPPED = 4
|
const val DROPPED = 4
|
||||||
const val PLAN_TO_READ = 5
|
const val PLAN_TO_READ = 5
|
||||||
|
|
||||||
const val DEFAULT_STATUS = READING
|
|
||||||
const val DEFAULT_SCORE = 0f
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
@ -85,8 +82,8 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
track.media_id = remoteTrack.media_id
|
track.media_id = remoteTrack.media_id
|
||||||
update(track)
|
update(track)
|
||||||
} else {
|
} else {
|
||||||
track.score = DEFAULT_SCORE
|
track.status = READING
|
||||||
track.status = DEFAULT_STATUS
|
track.score = 0F
|
||||||
add(track)
|
add(track)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,9 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun add(track: Track): Track {
|
override suspend fun add(track: Track): Track {
|
||||||
return api.addItemToList(track)
|
track.status = READING
|
||||||
|
track.score = 0F
|
||||||
|
return api.updateItem(track)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun update(track: Track): Track {
|
override suspend fun update(track: Track): Track {
|
||||||
@ -102,7 +104,7 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun refresh(track: Track): Track {
|
override suspend fun refresh(track: Track): Track {
|
||||||
return api.findListItem(track) ?: api.addItemToList(track)
|
return api.findListItem(track) ?: add(track)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun login(username: String, password: String) = login(password)
|
override suspend fun login(username: String, password: String) = login(password)
|
||||||
|
@ -111,24 +111,6 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun addItemToList(track: Track): Track {
|
|
||||||
return withIOContext {
|
|
||||||
val formBody: RequestBody = FormBody.Builder()
|
|
||||||
.add("status", "reading")
|
|
||||||
.add("score", "0")
|
|
||||||
.add("start_date", convertToIsoDate(System.currentTimeMillis())!!)
|
|
||||||
.build()
|
|
||||||
val request = Request.Builder()
|
|
||||||
.url(mangaUrl(track.media_id).toString())
|
|
||||||
.put(formBody)
|
|
||||||
.build()
|
|
||||||
authClient.newCall(request)
|
|
||||||
.await()
|
|
||||||
.parseAs<JsonObject>()
|
|
||||||
.let { parseMangaItem(it, track) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun updateItem(track: Track): Track {
|
suspend fun updateItem(track: Track): Track {
|
||||||
return withIOContext {
|
return withIOContext {
|
||||||
val formBodyBuilder = FormBody.Builder()
|
val formBodyBuilder = FormBody.Builder()
|
||||||
|
@ -21,9 +21,6 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
const val DROPPED = 4
|
const val DROPPED = 4
|
||||||
const val PLANNING = 5
|
const val PLANNING = 5
|
||||||
const val REPEATING = 6
|
const val REPEATING = 6
|
||||||
|
|
||||||
const val DEFAULT_STATUS = READING
|
|
||||||
const val DEFAULT_SCORE = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val json: Json by injectLazy()
|
private val json: Json by injectLazy()
|
||||||
@ -59,8 +56,8 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
update(track)
|
update(track)
|
||||||
} else {
|
} else {
|
||||||
// Set default fields if it's not found in the list
|
// Set default fields if it's not found in the list
|
||||||
track.score = DEFAULT_SCORE.toFloat()
|
track.status = READING
|
||||||
track.status = DEFAULT_STATUS
|
track.score = 0F
|
||||||
add(track)
|
add(track)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user