From 708e71a35a275836f1f04ccc5f6de0725c4456f6 Mon Sep 17 00:00:00 2001 From: nicki <72807749+curche@users.noreply.github.com> Date: Sat, 21 Aug 2021 03:50:04 +0530 Subject: [PATCH] Use user preferred title language in Anilist (#5758) * Use user preferred title language in Anilist Since Anilist is only used by authenticated users, the title language can be set using the `userPreferred` field (defaults to romaji) Changed wherever `title>romaji` was being used. Shouldn't have missed any. `userPreferred` is also available for Staff and Character but not relevant to Tachiyomi for now. Users might need to go Logout and log back in on Anilist to see the change. Actual setting can be found at https://anilist.co/settings/media closes https://github.com/tachiyomiorg/tachiyomi/issues/5757 * correct title in anilist model indicates the fact that userPreferred title is used * convert forgotten `type` to `format` as well leads to NPE when using `findLibManga`. missed one query in https://github.com/tachiyomiorg/tachiyomi/pull/5741 --- .../eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt | 8 ++++---- .../kanade/tachiyomi/data/track/anilist/AnilistModels.kt | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt index e832413b5c..0147dbb542 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt @@ -110,7 +110,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { |media(search: ${'$'}query, type: MANGA, format_not_in: [NOVEL]) { |id |title { - |romaji + |userPreferred |} |coverImage { |large @@ -175,12 +175,12 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { |media { |id |title { - |romaji + |userPreferred |} |coverImage { |large |} - |type + |format |status |chapters |description @@ -264,7 +264,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { private fun jsonToALManga(struct: JsonObject): ALManga { return ALManga( struct["id"]!!.jsonPrimitive.int, - struct["title"]!!.jsonObject["romaji"]!!.jsonPrimitive.content, + struct["title"]!!.jsonObject["userPreferred"]!!.jsonPrimitive.content, struct["coverImage"]!!.jsonObject["large"]!!.jsonPrimitive.content, struct["description"]!!.jsonPrimitive.contentOrNull, struct["format"]!!.jsonPrimitive.content.replace("_", "-"), diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt index 920dbc2293..5911361fd5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt @@ -10,7 +10,7 @@ import java.util.Locale data class ALManga( val media_id: Int, - val title_romaji: String, + val title_user_pref: String, val image_url_lge: String, val description: String?, val format: String, @@ -21,7 +21,7 @@ data class ALManga( fun toTrack() = TrackSearch.create(TrackManager.ANILIST).apply { media_id = this@ALManga.media_id - title = title_romaji + title = title_user_pref total_chapters = this@ALManga.total_chapters cover_url = image_url_lge summary = description ?: ""