mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-27 11:28:23 +01:00
Some improvements to Bangumi tracker search (#1396)
In short: - fetch & show actual summary - fallback to "name" if "name_cn" is empty - request larger responseGroup to get & display the summary & rating - add type filter query param to make Bangumi filter, not us Previously, we only displayed the "name" in the summary area and used "name_cn" as the entry name. However, "name_cn" (Chinese name) can be an empty string at times, resulting in an awkward looking search result list where some, many, or even all the results have no title displayed and only show the "name" (Japanese name) in the summary area. This has been solved by using "name" as a fallback value should "name_cn" be empty. If a Chinese name is available, the original name is prepended to the summary with the addition "作品原名:" (meaning "original series title"). By using the "responseGroup=large" query parameter, we can request the required data we need to display the actual summary for an entry and the entry's average rating. The "name" is prepended to the summary contents, if any exist, so it is still accessible for series identification if a "name_cn" exists too and was used for the result title. Adding the "type=1" filter query parameter means Bangumi will only return entries of type 1 ("book") instead of all types and Mihon needing to filter, resulting in potentially missed entry matches.
This commit is contained in:
parent
eedece5adf
commit
78f9a84b14
@ -14,6 +14,9 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||||||
### Fixed
|
### Fixed
|
||||||
- Fixed "currentTab was used multiple times"
|
- Fixed "currentTab was used multiple times"
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- Bangumi search now shows the score and summary of a search result ([@MajorTanya](https://github.com/MajorTanya)) ([#1396](https://github.com/mihonapp/mihon/pull/1396))
|
||||||
|
|
||||||
## [v0.17.0] - 2024-10-26
|
## [v0.17.0] - 2024-10-26
|
||||||
### Added
|
### Added
|
||||||
- Option to disable reader zoom out ([@Splintorien](https://github.com/Splintorien)) ([#302](https://github.com/mihonapp/mihon/pull/302))
|
- Option to disable reader zoom out ([@Splintorien](https://github.com/Splintorien)) ([#302](https://github.com/mihonapp/mihon/pull/302))
|
||||||
|
@ -71,6 +71,8 @@ class BangumiApi(
|
|||||||
val url = "$API_URL/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}"
|
val url = "$API_URL/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}"
|
||||||
.toUri()
|
.toUri()
|
||||||
.buildUpon()
|
.buildUpon()
|
||||||
|
.appendQueryParameter("type", "1")
|
||||||
|
.appendQueryParameter("responseGroup", "large")
|
||||||
.appendQueryParameter("max_results", "20")
|
.appendQueryParameter("max_results", "20")
|
||||||
.build()
|
.build()
|
||||||
with(json) {
|
with(json) {
|
||||||
@ -81,7 +83,6 @@ class BangumiApi(
|
|||||||
if (result.code == 404) emptyList<TrackSearch>()
|
if (result.code == 404) emptyList<TrackSearch>()
|
||||||
|
|
||||||
result.list
|
result.list
|
||||||
?.filter { it.type == 1 }
|
|
||||||
?.map { it.toTrackSearch(trackId) }
|
?.map { it.toTrackSearch(trackId) }
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ data class BGMSearchItem(
|
|||||||
val nameCn: String,
|
val nameCn: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
val type: Int,
|
val type: Int,
|
||||||
|
val summary: String?,
|
||||||
val images: BGMSearchItemCovers?,
|
val images: BGMSearchItemCovers?,
|
||||||
@SerialName("eps_count")
|
@SerialName("eps_count")
|
||||||
val epsCount: Long?,
|
val epsCount: Long?,
|
||||||
@ -25,9 +26,13 @@ data class BGMSearchItem(
|
|||||||
) {
|
) {
|
||||||
fun toTrackSearch(trackId: Long): TrackSearch = TrackSearch.create(trackId).apply {
|
fun toTrackSearch(trackId: Long): TrackSearch = TrackSearch.create(trackId).apply {
|
||||||
remote_id = this@BGMSearchItem.id
|
remote_id = this@BGMSearchItem.id
|
||||||
title = nameCn
|
title = nameCn.ifBlank { name }
|
||||||
cover_url = images?.common ?: ""
|
cover_url = images?.common.orEmpty()
|
||||||
summary = this@BGMSearchItem.name
|
summary = if (nameCn.isNotBlank()) {
|
||||||
|
"作品原名:$name" + this@BGMSearchItem.summary?.let { "\n$it" }.orEmpty()
|
||||||
|
} else {
|
||||||
|
this@BGMSearchItem.summary.orEmpty()
|
||||||
|
}
|
||||||
score = rating?.score ?: -1.0
|
score = rating?.score ?: -1.0
|
||||||
tracking_url = url
|
tracking_url = url
|
||||||
total_chapters = epsCount ?: 0
|
total_chapters = epsCount ?: 0
|
||||||
|
Loading…
Reference in New Issue
Block a user