Display staff information on Anilist tracker search results (#1810)
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> (cherry picked from commit b702603965044cfe3ee852f8d0c970b6eb93b97a) # Conflicts: # CHANGELOG.md
This commit is contained in:
parent
1eb64d117e
commit
8dc6a95ce6
@ -304,6 +304,15 @@ private fun SearchResultItem(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
if (trackSearch.authors.isNotEmpty() || trackSearch.artists.isNotEmpty()) {
|
||||||
|
Text(
|
||||||
|
text = (trackSearch.authors + trackSearch.artists).distinct().joinToString(),
|
||||||
|
modifier = Modifier.secondaryItemAlpha(),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
)
|
||||||
|
}
|
||||||
if (type.isNotBlank()) {
|
if (type.isNotBlank()) {
|
||||||
SearchResultItemDetails(
|
SearchResultItemDetails(
|
||||||
title = stringResource(MR.strings.track_type),
|
title = stringResource(MR.strings.track_type),
|
||||||
|
@ -97,9 +97,13 @@ internal class TrackerSearchPreviewProvider : PreviewParameterProvider<@Composab
|
|||||||
it.summary = lorem((0..40).random()).joinToString()
|
it.summary = lorem((0..40).random()).joinToString()
|
||||||
it.publishing_status = if (Random.nextBoolean()) "Finished" else ""
|
it.publishing_status = if (Random.nextBoolean()) "Finished" else ""
|
||||||
it.publishing_type = if (Random.nextBoolean()) "Oneshot" else ""
|
it.publishing_type = if (Random.nextBoolean()) "Oneshot" else ""
|
||||||
|
it.artists = randomNames()
|
||||||
|
it.authors = randomNames()
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun randomNames(): List<String> = (0..(0..3).random()).map { lorem((3..5).random()).joinToString() }
|
||||||
|
|
||||||
private fun lorem(words: Int): Sequence<String> =
|
private fun lorem(words: Int): Sequence<String> =
|
||||||
LoremIpsum(words).values
|
LoremIpsum(words).values
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,19 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||||||
|Page (perPage: 50) {
|
|Page (perPage: 50) {
|
||||||
|media(search: ${'$'}query, type: MANGA, format_not_in: [NOVEL]) {
|
|media(search: ${'$'}query, type: MANGA, format_not_in: [NOVEL]) {
|
||||||
|id
|
|id
|
||||||
|
|staff {
|
||||||
|
|edges {
|
||||||
|
|role
|
||||||
|
|id
|
||||||
|
|node {
|
||||||
|
|name {
|
||||||
|
|full
|
||||||
|
|userPreferred
|
||||||
|
|native
|
||||||
|
|}
|
||||||
|
|}
|
||||||
|
|}
|
||||||
|
|}
|
||||||
|title {
|
|title {
|
||||||
|userPreferred
|
|userPreferred
|
||||||
|}
|
|}
|
||||||
@ -224,6 +237,19 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
|||||||
|month
|
|month
|
||||||
|day
|
|day
|
||||||
|}
|
|}
|
||||||
|
|staff {
|
||||||
|
|edges {
|
||||||
|
|role
|
||||||
|
|id
|
||||||
|
|node {
|
||||||
|
|name {
|
||||||
|
|full
|
||||||
|
|userPreferred
|
||||||
|
|native
|
||||||
|
|}
|
||||||
|
|}
|
||||||
|
|}
|
||||||
|
|}
|
||||||
|}
|
|}
|
||||||
|}
|
|}
|
||||||
|}
|
|}
|
||||||
|
@ -19,6 +19,7 @@ data class ALManga(
|
|||||||
val startDateFuzzy: Long,
|
val startDateFuzzy: Long,
|
||||||
val totalChapters: Long,
|
val totalChapters: Long,
|
||||||
val averageScore: Int,
|
val averageScore: Int,
|
||||||
|
val staff: ALStaff,
|
||||||
) {
|
) {
|
||||||
fun toTrack() = TrackSearch.create(TrackerManager.ANILIST).apply {
|
fun toTrack() = TrackSearch.create(TrackerManager.ANILIST).apply {
|
||||||
remote_id = remoteId
|
remote_id = remoteId
|
||||||
@ -38,6 +39,11 @@ data class ALManga(
|
|||||||
""
|
""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
staff.edges.forEach {
|
||||||
|
val name = it.node.name() ?: return@forEach
|
||||||
|
if ("Story" in it.role) authors += name
|
||||||
|
if ("Art" in it.role) artists += name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ data class ALSearchItem(
|
|||||||
val startDate: ALFuzzyDate,
|
val startDate: ALFuzzyDate,
|
||||||
val chapters: Long?,
|
val chapters: Long?,
|
||||||
val averageScore: Int?,
|
val averageScore: Int?,
|
||||||
|
val staff: ALStaff,
|
||||||
) {
|
) {
|
||||||
fun toALManga(): ALManga = ALManga(
|
fun toALManga(): ALManga = ALManga(
|
||||||
remoteId = id,
|
remoteId = id,
|
||||||
@ -24,6 +25,7 @@ data class ALSearchItem(
|
|||||||
startDateFuzzy = startDate.toEpochMilli(),
|
startDateFuzzy = startDate.toEpochMilli(),
|
||||||
totalChapters = chapters ?: 0,
|
totalChapters = chapters ?: 0,
|
||||||
averageScore = averageScore ?: -1,
|
averageScore = averageScore ?: -1,
|
||||||
|
staff = staff,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,3 +38,31 @@ data class ALItemTitle(
|
|||||||
data class ItemCover(
|
data class ItemCover(
|
||||||
val large: String,
|
val large: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ALStaff(
|
||||||
|
val edges: List<ALEdge>,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ALEdge(
|
||||||
|
val role: String,
|
||||||
|
val id: Int,
|
||||||
|
val node: ALStaffNode,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ALStaffNode(
|
||||||
|
val name: ALStaffName,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ALStaffName(
|
||||||
|
val userPreferred: String?,
|
||||||
|
val native: String?,
|
||||||
|
val full: String?,
|
||||||
|
) {
|
||||||
|
operator fun invoke(): String? {
|
||||||
|
return userPreferred ?: full ?: native
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -34,6 +34,10 @@ class TrackSearch : Track {
|
|||||||
|
|
||||||
override lateinit var tracking_url: String
|
override lateinit var tracking_url: String
|
||||||
|
|
||||||
|
var authors: List<String> = emptyList()
|
||||||
|
|
||||||
|
var artists: List<String> = emptyList()
|
||||||
|
|
||||||
var cover_url: String = ""
|
var cover_url: String = ""
|
||||||
|
|
||||||
var summary: String = ""
|
var summary: String = ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user