Recommendation bug fixes (#17)
* Return an empty recommendations list instead of throwing an error * Fix api response find for searched manga * Fix spelling Co-authored-by: she11sh0cked <she11sh0cked@users.noreply.github.com>
This commit is contained in:
parent
ef2241e0cb
commit
fd09f64fe6
@ -61,16 +61,12 @@ open class RecommendsPager(
|
|||||||
throw Exception("Null Response")
|
throw Exception("Null Response")
|
||||||
}
|
}
|
||||||
val response = JsonParser.parseString(responseBody).obj
|
val response = JsonParser.parseString(responseBody).obj
|
||||||
val results = response["results"].array
|
val result = response["results"].array
|
||||||
.sortedBy {
|
.find {
|
||||||
val title = it["title"].string
|
val title = it["title"].string
|
||||||
title.contains(manga.title, true)
|
title.contains(manga.title, true)
|
||||||
}
|
}
|
||||||
val result = results.last()
|
?: return@map null
|
||||||
val title = result["title"].string
|
|
||||||
if (!title.contains(manga.title, true)) {
|
|
||||||
return@map null
|
|
||||||
}
|
|
||||||
result["mal_id"].string
|
result["mal_id"].string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,21 +166,23 @@ open class RecommendsPager(
|
|||||||
val data = response["data"]!!.obj
|
val data = response["data"]!!.obj
|
||||||
val page = data["Page"].obj
|
val page = data["Page"].obj
|
||||||
val media = page["media"].array
|
val media = page["media"].array
|
||||||
val results = media.sortedBy {
|
val result = media.find {
|
||||||
val synonyms = it["synonyms"].array
|
val title = it["title"].obj
|
||||||
countOccurrence(synonyms, manga.title)
|
if (title["romaji"].nullString?.contains(manga.title, true) == true) {
|
||||||
}
|
return@find true
|
||||||
val result = results.last()
|
}
|
||||||
val title = result["title"].obj
|
if (title["english"].nullString?.contains(manga.title, true) == true) {
|
||||||
val synonyms = result["synonyms"].array
|
return@find true
|
||||||
if (
|
}
|
||||||
title["romaji"].nullString?.contains("", true) != true &&
|
if (title["native"].nullString?.contains(manga.title, true) == true) {
|
||||||
title["english"].nullString?.contains("", true) != true &&
|
return@find true
|
||||||
title["native"].nullString?.contains("", true) != true &&
|
}
|
||||||
countOccurrence(synonyms, manga.title) <= 0
|
if (countOccurrence(it["synonyms"].array, manga.title) <= 0) {
|
||||||
) {
|
return@find true
|
||||||
return@map listOf<SMangaImpl>()
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
?: return@map listOf<SMangaImpl>()
|
||||||
val recommendations = result["recommendations"].obj
|
val recommendations = result["recommendations"].obj
|
||||||
val edges = recommendations["edges"].array
|
val edges = recommendations["edges"].array
|
||||||
edges.map {
|
edges.map {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user