From 13d25e0849ea9c3b267da6d7fb2624a942fcc41b Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 1 Feb 2021 22:39:41 -0500 Subject: [PATCH] Don't automatically set MAL start date (closes #4349) --- .../tachiyomi/data/track/anilist/Anilist.kt | 7 ++----- .../tachiyomi/data/track/bangumi/Bangumi.kt | 7 ++----- .../tachiyomi/data/track/bangumi/BangumiApi.kt | 15 --------------- .../kanade/tachiyomi/data/track/kitsu/Kitsu.kt | 7 ++----- .../data/track/myanimelist/MyAnimeList.kt | 6 ++++-- .../data/track/myanimelist/MyAnimeListApi.kt | 18 ------------------ .../data/track/shikimori/Shikimori.kt | 7 ++----- 7 files changed, 12 insertions(+), 55 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt index aecf538889..d9b0a56a67 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt @@ -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) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt index a65af7702a..72ce189ed6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt @@ -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 } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt index 28018cf6ee..b9bb187af8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt @@ -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}")) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt index 66edfce256..c8722c1368 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt @@ -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) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt index 9c42e6987b..06648f6a97 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt index 25e4621ff4..3130ca5441 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt @@ -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() - .let { parseMangaItem(it, track) } - } - } - suspend fun updateItem(track: Track): Track { return withIOContext { val formBodyBuilder = FormBody.Builder() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt index aec1b462be..d7b891a9ed 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt @@ -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) } }