Browse Source

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
nicki 3 years ago
parent
commit
708e71a35a

+ 4 - 4
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("_", "-"),

+ 2 - 2
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 = [email protected]_id
-        title = title_romaji
+        title = title_user_pref
         total_chapters = [email protected]_chapters
         cover_url = image_url_lge
         summary = description ?: ""