Don't automatically set MAL start date (closes #4349)
This commit is contained in:
parent
6662e2002f
commit
13d25e0849
7 changed files with 12 additions and 55 deletions
|
@ -22,9 +22,6 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
|||
const val PLANNING = 5
|
||||
const val REPEATING = 6
|
||||
|
||||
const val DEFAULT_STATUS = READING
|
||||
const val DEFAULT_SCORE = 0
|
||||
|
||||
const val POINT_100 = "POINT_100"
|
||||
const val POINT_10 = "POINT_10"
|
||||
const val POINT_10_DECIMAL = "POINT_10_DECIMAL"
|
||||
|
@ -154,8 +151,8 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
|||
update(track)
|
||||
} else {
|
||||
// Set default fields if it's not found in the list
|
||||
track.score = DEFAULT_SCORE.toFloat()
|
||||
track.status = DEFAULT_STATUS
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
add(track)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||
refresh(track)
|
||||
} else {
|
||||
// Set default fields if it's not found in the list
|
||||
track.score = DEFAULT_SCORE.toFloat()
|
||||
track.status = DEFAULT_STATUS
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
add(track)
|
||||
update(track)
|
||||
}
|
||||
|
@ -128,8 +128,5 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||
const val ON_HOLD = 4
|
||||
const val DROPPED = 5
|
||||
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.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.float
|
||||
import kotlinx.serialization.json.int
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
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? {
|
||||
return withIOContext {
|
||||
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 DROPPED = 4
|
||||
const val PLAN_TO_READ = 5
|
||||
|
||||
const val DEFAULT_STATUS = READING
|
||||
const val DEFAULT_SCORE = 0f
|
||||
}
|
||||
|
||||
@StringRes
|
||||
|
@ -85,8 +82,8 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|||
track.media_id = remoteTrack.media_id
|
||||
update(track)
|
||||
} else {
|
||||
track.score = DEFAULT_SCORE
|
||||
track.status = DEFAULT_STATUS
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
add(track)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,9 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -102,7 +104,7 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
|||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -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 {
|
||||
return withIOContext {
|
||||
val formBodyBuilder = FormBody.Builder()
|
||||
|
|
|
@ -21,9 +21,6 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|||
const val DROPPED = 4
|
||||
const val PLANNING = 5
|
||||
const val REPEATING = 6
|
||||
|
||||
const val DEFAULT_STATUS = READING
|
||||
const val DEFAULT_SCORE = 0
|
||||
}
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
@ -59,8 +56,8 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|||
update(track)
|
||||
} else {
|
||||
// Set default fields if it's not found in the list
|
||||
track.score = DEFAULT_SCORE.toFloat()
|
||||
track.status = DEFAULT_STATUS
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
add(track)
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue