From a49adbd09c606408827da252e6a5be9c4a19fe89 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 30 Dec 2020 15:08:10 -0500 Subject: [PATCH] Add ID search workaround for MAL tracking --- .../kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt | 6 ++++++ .../tachiyomi/data/track/myanimelist/MyAnimeListApi.kt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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 e476cb7f7..8145133b1 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 @@ -76,6 +76,12 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { } override fun search(query: String): Observable> { + if (query.startsWith("my:")) { + query.substringAfter("my:").toIntOrNull()?.let { id -> + return runAsObservable({ listOf(api.getMangaDetails(id)) }) + } + } + return runAsObservable({ api.search(query) }) } 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 cecf27571..fa1845bc6 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 @@ -79,7 +79,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI } } - private suspend fun getMangaDetails(id: Int): TrackSearch { + suspend fun getMangaDetails(id: Int): TrackSearch { return withContext(Dispatchers.IO) { val url = "$baseApiUrl/manga".toUri().buildUpon() .appendPath(id.toString())