From 5cf9d09a028ba16b8cdab1536080cea0e53ddea4 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 22 Mar 2021 02:04:09 -0400 Subject: [PATCH] Fix MAL Delete entry api --- .../data/track/myanimelist/MyAnimeListApi.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 9567557f60..e72c4f2aa5 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 @@ -37,6 +37,7 @@ import org.jsoup.Jsoup import org.jsoup.nodes.Document import org.jsoup.nodes.Element import org.jsoup.parser.Parser +import retrofit2.http.DELETE import timber.log.Timber import java.text.SimpleDateFormat import java.util.* @@ -249,18 +250,21 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI } suspend fun remove(track: Track): Boolean { - try { - authClient.newCall(POST(url = removeUrl(track.media_id))).await() - return true - } catch (e: Exception) { - Timber.w(e) + return withIOContext { + try { + val request = Request.Builder() + .url(mangaUrl(track.media_id).toString()) + .delete() + .build() + authClient.newCall(request).await() + true + } catch (e: Exception) { + Timber.w(e) + false + } } - return false } - private fun removeUrl(mediaId: Int) = "$baseApiUrl/manga".toUri().buildUpon().appendPath(mediaId.toString()) - .appendPath("delete").toString() - companion object { // Registered under jay's MAL account private const val clientId = "8d3821c90edb495432a5ecb61de59200"