cherry pick some MAL fixes (#1364)

* fix MAL search novel filter (#6279)

* Truncate MAL search queries to first 64 characters (closes #6314)

Is it worth telling the user? ¯\_(ツ)_/¯

Co-authored-by: arkon <eugcheung94@gmail.com>
This commit is contained in:
Henrik 2022-08-11 21:28:27 +02:00 committed by GitHub
parent 0e70a4c405
commit d1aa032008
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,7 +64,8 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
suspend fun search(query: String): List<TrackSearch> {
return withIOContext {
val url = "$baseApiUrl/manga".toUri().buildUpon()
.appendQueryParameter("q", query)
// MAL API throws a 400 when the query is over 64 characters...
.appendQueryParameter("q", query.take(64))
.appendQueryParameter("nsfw", "true")
.build()
authClient.newCall(GET(url.toString()))
@ -78,7 +79,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
async { getMangaDetails(id) }
}
.awaitAll()
.filter { trackSearch -> trackSearch.publishing_type != "novel" }
.filter { trackSearch -> !trackSearch.publishing_type.contains("novel") }
}
}
}