Improve mangadex title selection
This commit is contained in:
parent
95e14a9ef9
commit
f0329cfafa
@ -265,7 +265,7 @@ class MdUtil {
|
||||
fun createMangaEntry(json: MangaDto, lang: String): MangaInfo {
|
||||
return MangaInfo(
|
||||
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
|
||||
.firstOrNull { relationshipDto -> relationshipDto.type == MdConstants.Types.coverArt }
|
||||
?.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 {
|
||||
return "$cdnUrl/covers/$dexId/$fileName"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user