Improve mangadex title selection
This commit is contained in:
parent
95e14a9ef9
commit
f0329cfafa
1 changed files with 5 additions and 1 deletions
|
|
@ -265,7 +265,7 @@ class MdUtil {
|
||||||
fun createMangaEntry(json: MangaDto, lang: String): MangaInfo {
|
fun createMangaEntry(json: MangaDto, lang: String): MangaInfo {
|
||||||
return MangaInfo(
|
return MangaInfo(
|
||||||
key = buildMangaUrl(json.data.id),
|
key = buildMangaUrl(json.data.id),
|
||||||
title = cleanString(json.data.attributes.title.asMdMap().let { it[lang] ?: it["en"].orEmpty() }),
|
title = cleanString(getTitle(json.data.attributes.title.asMdMap(), lang, json.data.attributes.originalLanguage)),
|
||||||
cover = json.data.relationships
|
cover = json.data.relationships
|
||||||
.firstOrNull { relationshipDto -> relationshipDto.type == MdConstants.Types.coverArt }
|
.firstOrNull { relationshipDto -> relationshipDto.type == MdConstants.Types.coverArt }
|
||||||
?.attributes
|
?.attributes
|
||||||
|
|
@ -276,6 +276,10 @@ class MdUtil {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getTitle(titleMap: Map<String, String?>, currentLang: String, originalLanguage: String): String {
|
||||||
|
return titleMap[currentLang] ?: titleMap["en"] ?: titleMap[originalLanguage].orEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
fun cdnCoverUrl(dexId: String, fileName: String): String {
|
fun cdnCoverUrl(dexId: String, fileName: String): String {
|
||||||
return "$cdnUrl/covers/$dexId/$fileName"
|
return "$cdnUrl/covers/$dexId/$fileName"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue