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
This commit is contained in:
nicki 2021-08-21 03:50:04 +05:30 committed by GitHub
parent 4eaccc966e
commit 708e71a35a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -110,7 +110,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|media(search: ${'$'}query, type: MANGA, format_not_in: [NOVEL]) { |media(search: ${'$'}query, type: MANGA, format_not_in: [NOVEL]) {
|id |id
|title { |title {
|romaji |userPreferred
|} |}
|coverImage { |coverImage {
|large |large
@ -175,12 +175,12 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|media { |media {
|id |id
|title { |title {
|romaji |userPreferred
|} |}
|coverImage { |coverImage {
|large |large
|} |}
|type |format
|status |status
|chapters |chapters
|description |description
@ -264,7 +264,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
private fun jsonToALManga(struct: JsonObject): ALManga { private fun jsonToALManga(struct: JsonObject): ALManga {
return ALManga( return ALManga(
struct["id"]!!.jsonPrimitive.int, struct["id"]!!.jsonPrimitive.int,
struct["title"]!!.jsonObject["romaji"]!!.jsonPrimitive.content, struct["title"]!!.jsonObject["userPreferred"]!!.jsonPrimitive.content,
struct["coverImage"]!!.jsonObject["large"]!!.jsonPrimitive.content, struct["coverImage"]!!.jsonObject["large"]!!.jsonPrimitive.content,
struct["description"]!!.jsonPrimitive.contentOrNull, struct["description"]!!.jsonPrimitive.contentOrNull,
struct["format"]!!.jsonPrimitive.content.replace("_", "-"), struct["format"]!!.jsonPrimitive.content.replace("_", "-"),

View File

@ -10,7 +10,7 @@ import java.util.Locale
data class ALManga( data class ALManga(
val media_id: Int, val media_id: Int,
val title_romaji: String, val title_user_pref: String,
val image_url_lge: String, val image_url_lge: String,
val description: String?, val description: String?,
val format: String, val format: String,
@ -21,7 +21,7 @@ data class ALManga(
fun toTrack() = TrackSearch.create(TrackManager.ANILIST).apply { fun toTrack() = TrackSearch.create(TrackManager.ANILIST).apply {
media_id = this@ALManga.media_id media_id = this@ALManga.media_id
title = title_romaji title = title_user_pref
total_chapters = this@ALManga.total_chapters total_chapters = this@ALManga.total_chapters
cover_url = image_url_lge cover_url = image_url_lge
summary = description ?: "" summary = description ?: ""