mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
parent
1f259f9298
commit
734cb0be6e
9 changed files with 23 additions and 3 deletions
|
@ -193,6 +193,7 @@ fun TrackerSearch(
|
||||||
type = it.publishing_type.toLowerCase(Locale.current).capitalize(Locale.current),
|
type = it.publishing_type.toLowerCase(Locale.current).capitalize(Locale.current),
|
||||||
startDate = it.start_date,
|
startDate = it.start_date,
|
||||||
status = it.publishing_status.toLowerCase(Locale.current).capitalize(Locale.current),
|
status = it.publishing_status.toLowerCase(Locale.current).capitalize(Locale.current),
|
||||||
|
score = it.score,
|
||||||
description = it.summary.trim(),
|
description = it.summary.trim(),
|
||||||
selected = it == selected,
|
selected = it == selected,
|
||||||
onClick = { onSelectedChange(it) },
|
onClick = { onSelectedChange(it) },
|
||||||
|
@ -218,6 +219,7 @@ private fun SearchResultItem(
|
||||||
type: String,
|
type: String,
|
||||||
startDate: String,
|
startDate: String,
|
||||||
status: String,
|
status: String,
|
||||||
|
score: Float,
|
||||||
description: String,
|
description: String,
|
||||||
selected: Boolean,
|
selected: Boolean,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
|
@ -279,6 +281,12 @@ private fun SearchResultItem(
|
||||||
text = status,
|
text = status,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (score != -1f) {
|
||||||
|
SearchResultItemDetails(
|
||||||
|
title = stringResource(MR.strings.score),
|
||||||
|
text = score.toString(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (description.isNotBlank()) {
|
if (description.isNotBlank()) {
|
||||||
|
|
|
@ -153,6 +153,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
||||||
|month
|
|month
|
||||||
|day
|
|day
|
||||||
|}
|
|}
|
||||||
|
|averageScore
|
||||||
|}
|
|}
|
||||||
|}
|
|}
|
||||||
|}
|
|}
|
||||||
|
@ -309,6 +310,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
||||||
struct["status"]!!.jsonPrimitive.contentOrNull ?: "",
|
struct["status"]!!.jsonPrimitive.contentOrNull ?: "",
|
||||||
parseDate(struct, "startDate"),
|
parseDate(struct, "startDate"),
|
||||||
struct["chapters"]!!.jsonPrimitive.intOrNull ?: 0,
|
struct["chapters"]!!.jsonPrimitive.intOrNull ?: 0,
|
||||||
|
struct["averageScore"]?.jsonPrimitive?.intOrNull ?: -1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ data class ALManga(
|
||||||
val publishing_status: String,
|
val publishing_status: String,
|
||||||
val start_date_fuzzy: Long,
|
val start_date_fuzzy: Long,
|
||||||
val total_chapters: Int,
|
val total_chapters: Int,
|
||||||
|
val average_score: Int,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun toTrack() = TrackSearch.create(TrackerManager.ANILIST).apply {
|
fun toTrack() = TrackSearch.create(TrackerManager.ANILIST).apply {
|
||||||
|
@ -27,6 +28,7 @@ data class ALManga(
|
||||||
total_chapters = this@ALManga.total_chapters
|
total_chapters = this@ALManga.total_chapters
|
||||||
cover_url = image_url_lge
|
cover_url = image_url_lge
|
||||||
summary = description?.htmlDecode() ?: ""
|
summary = description?.htmlDecode() ?: ""
|
||||||
|
score = average_score.toFloat()
|
||||||
tracking_url = AnilistApi.mangaUrl(media_id)
|
tracking_url = AnilistApi.mangaUrl(media_id)
|
||||||
publishing_status = this@ALManga.publishing_status
|
publishing_status = this@ALManga.publishing_status
|
||||||
publishing_type = format
|
publishing_type = format
|
||||||
|
|
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.network.parseAs
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.contentOrNull
|
import kotlinx.serialization.json.contentOrNull
|
||||||
|
import kotlinx.serialization.json.floatOrNull
|
||||||
import kotlinx.serialization.json.int
|
import kotlinx.serialization.json.int
|
||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
@ -108,11 +109,13 @@ class BangumiApi(
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
val rating = obj["rating"]?.jsonObject?.get("score")?.jsonPrimitive?.floatOrNull ?: -1f
|
||||||
return TrackSearch.create(trackId).apply {
|
return TrackSearch.create(trackId).apply {
|
||||||
media_id = obj["id"]!!.jsonPrimitive.long
|
media_id = obj["id"]!!.jsonPrimitive.long
|
||||||
title = obj["name_cn"]!!.jsonPrimitive.content
|
title = obj["name_cn"]!!.jsonPrimitive.content
|
||||||
cover_url = coverUrl
|
cover_url = coverUrl
|
||||||
summary = obj["name"]!!.jsonPrimitive.content
|
summary = obj["name"]!!.jsonPrimitive.content
|
||||||
|
score = rating
|
||||||
tracking_url = obj["url"]!!.jsonPrimitive.content
|
tracking_url = obj["url"]!!.jsonPrimitive.content
|
||||||
total_chapters = totalChapters
|
total_chapters = totalChapters
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
|
||||||
private const val algoliaAppId = "AWQO5J657S"
|
private const val algoliaAppId = "AWQO5J657S"
|
||||||
private const val algoliaFilter =
|
private const val algoliaFilter =
|
||||||
"&facetFilters=%5B%22kind%3Amanga%22%5D&attributesToRetrieve=" +
|
"&facetFilters=%5B%22kind%3Amanga%22%5D&attributesToRetrieve=" +
|
||||||
"%5B%22synopsis%22%2C%22canonicalTitle%22%2C%22chapterCount%22%2C%22" +
|
"%5B%22synopsis%22%2C%22averageRating%22%2C%22canonicalTitle%22%2C%22chapterCount%22%2C%22" +
|
||||||
"posterImage%22%2C%22startDate%22%2C%22subtype%22%2C%22endDate%22%2C%20%22id%22%5D"
|
"posterImage%22%2C%22startDate%22%2C%22subtype%22%2C%22endDate%22%2C%20%22id%22%5D"
|
||||||
|
|
||||||
fun mangaUrl(remoteId: Long): String {
|
fun mangaUrl(remoteId: Long): String {
|
||||||
|
|
|
@ -28,6 +28,7 @@ class KitsuSearchManga(obj: JsonObject) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
private val synopsis = obj["synopsis"]?.jsonPrimitive?.contentOrNull
|
private val synopsis = obj["synopsis"]?.jsonPrimitive?.contentOrNull
|
||||||
|
private val rating = obj["averageRating"]?.jsonPrimitive?.contentOrNull?.toFloatOrNull()
|
||||||
private var startDate = obj["startDate"]?.jsonPrimitive?.contentOrNull?.let {
|
private var startDate = obj["startDate"]?.jsonPrimitive?.contentOrNull?.let {
|
||||||
val outputDf = SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
val outputDf = SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
||||||
outputDf.format(Date(it.toLong() * 1000))
|
outputDf.format(Date(it.toLong() * 1000))
|
||||||
|
@ -42,6 +43,7 @@ class KitsuSearchManga(obj: JsonObject) {
|
||||||
cover_url = original ?: ""
|
cover_url = original ?: ""
|
||||||
summary = synopsis ?: ""
|
summary = synopsis ?: ""
|
||||||
tracking_url = KitsuApi.mangaUrl(media_id)
|
tracking_url = KitsuApi.mangaUrl(media_id)
|
||||||
|
score = rating ?: -1f
|
||||||
publishing_status = if (endDate == null) {
|
publishing_status = if (endDate == null) {
|
||||||
"Publishing"
|
"Publishing"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,7 +20,7 @@ class TrackSearch : Track {
|
||||||
|
|
||||||
override var total_chapters: Int = 0
|
override var total_chapters: Int = 0
|
||||||
|
|
||||||
override var score: Float = 0f
|
override var score: Float = -1f
|
||||||
|
|
||||||
override var status: Int = 0
|
override var status: Int = 0
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.boolean
|
import kotlinx.serialization.json.boolean
|
||||||
import kotlinx.serialization.json.contentOrNull
|
import kotlinx.serialization.json.contentOrNull
|
||||||
import kotlinx.serialization.json.float
|
import kotlinx.serialization.json.float
|
||||||
|
import kotlinx.serialization.json.floatOrNull
|
||||||
import kotlinx.serialization.json.int
|
import kotlinx.serialization.json.int
|
||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
@ -103,7 +104,7 @@ class MyAnimeListApi(
|
||||||
.appendPath(id.toString())
|
.appendPath(id.toString())
|
||||||
.appendQueryParameter(
|
.appendQueryParameter(
|
||||||
"fields",
|
"fields",
|
||||||
"id,title,synopsis,num_chapters,main_picture,status,media_type,start_date",
|
"id,title,synopsis,num_chapters,mean,main_picture,status,media_type,start_date",
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
with(json) {
|
with(json) {
|
||||||
|
@ -117,6 +118,7 @@ class MyAnimeListApi(
|
||||||
title = obj["title"]!!.jsonPrimitive.content
|
title = obj["title"]!!.jsonPrimitive.content
|
||||||
summary = obj["synopsis"]?.jsonPrimitive?.content ?: ""
|
summary = obj["synopsis"]?.jsonPrimitive?.content ?: ""
|
||||||
total_chapters = obj["num_chapters"]!!.jsonPrimitive.int
|
total_chapters = obj["num_chapters"]!!.jsonPrimitive.int
|
||||||
|
score = obj["mean"]?.jsonPrimitive?.floatOrNull ?: -1f
|
||||||
cover_url =
|
cover_url =
|
||||||
obj["main_picture"]?.jsonObject?.get("large")?.jsonPrimitive?.content
|
obj["main_picture"]?.jsonObject?.get("large")?.jsonPrimitive?.content
|
||||||
?: ""
|
?: ""
|
||||||
|
|
|
@ -107,6 +107,7 @@ class ShikimoriApi(
|
||||||
total_chapters = obj["chapters"]!!.jsonPrimitive.int
|
total_chapters = obj["chapters"]!!.jsonPrimitive.int
|
||||||
cover_url = baseUrl + obj["image"]!!.jsonObject["preview"]!!.jsonPrimitive.content
|
cover_url = baseUrl + obj["image"]!!.jsonObject["preview"]!!.jsonPrimitive.content
|
||||||
summary = ""
|
summary = ""
|
||||||
|
score = obj["score"]!!.jsonPrimitive.float
|
||||||
tracking_url = baseUrl + obj["url"]!!.jsonPrimitive.content
|
tracking_url = baseUrl + obj["url"]!!.jsonPrimitive.content
|
||||||
publishing_status = obj["status"]!!.jsonPrimitive.content
|
publishing_status = obj["status"]!!.jsonPrimitive.content
|
||||||
publishing_type = obj["kind"]!!.jsonPrimitive.content
|
publishing_type = obj["kind"]!!.jsonPrimitive.content
|
||||||
|
|
Loading…
Reference in a new issue