Retrieve YouTube artists subscribers count

This commit is contained in:
vfsfitvnm 2022-09-24 13:12:54 +02:00
parent e71e34c0d7
commit 4362456995
2 changed files with 40 additions and 11 deletions

View file

@ -164,12 +164,16 @@ fun VideoItem(
overflow = TextOverflow.Ellipsis,
)
BasicText(
text = video.views.firstOrNull()?.name ?: "",
style = typography.xxs.medium.secondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
video.views.firstOrNull()?.name?.let { viewsText ->
BasicText(
text = viewsText,
style = typography.xxs.medium.secondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier
.padding(top = 8.dp)
)
}
}
}
}
@ -200,7 +204,10 @@ fun VideoItemShimmer(
Column {
TextPlaceholder()
TextPlaceholder()
TextPlaceholder()
TextPlaceholder(
modifier = Modifier
.padding(top = 8.dp)
)
}
}
}
@ -287,7 +294,6 @@ fun PlaylistItemShimmer(
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
TextPlaceholder()
TextPlaceholder()
TextPlaceholder()
}
}
}
@ -369,7 +375,10 @@ fun AlbumItemShimmer(
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
TextPlaceholder()
TextPlaceholder()
TextPlaceholder()
TextPlaceholder(
modifier = Modifier
.padding(top = 8.dp)
)
}
}
}
@ -405,6 +414,17 @@ fun ArtistItem(
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
artist.subscribersCountText?.let { subscribersCountText ->
BasicText(
text = subscribersCountText,
style = typography.xxs.semiBold.secondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier
.padding(top = 4.dp)
)
}
}
}
}
@ -430,7 +450,11 @@ fun ArtistItemShimmer(
)
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
TextPlaceholder()
TextPlaceholder()
TextPlaceholder(
modifier = Modifier
.padding(top = 4.dp)
)
}
}
}

View file

@ -320,6 +320,7 @@ object YouTube {
data class Artist(
val info: Info<NavigationEndpoint.Endpoint.Browse>,
val subscribersCountText: String?,
override val thumbnail: ThumbnailRenderer.MusicThumbnailRenderer.Thumbnail.Thumbnail?
) : Item() {
override val key: String?
@ -329,7 +330,7 @@ object YouTube {
val Filter = Filter("EgWKAQIgAWoKEAkQChAFEAMQBA%3D%3D")
override fun from(content: MusicShelfRenderer.Content): Artist {
val (mainRuns) = content.runs
val (mainRuns, otherRuns) = content.runs
return Artist(
info = Info(
@ -341,6 +342,10 @@ object YouTube {
.navigationEndpoint
?.browseEndpoint
),
subscribersCountText = otherRuns
.lastOrNull()
?.last()
?.text,
thumbnail = content
.thumbnail
)