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, overflow = TextOverflow.Ellipsis,
) )
BasicText( video.views.firstOrNull()?.name?.let { viewsText ->
text = video.views.firstOrNull()?.name ?: "", BasicText(
style = typography.xxs.medium.secondary, text = viewsText,
maxLines = 1, style = typography.xxs.medium.secondary,
overflow = TextOverflow.Ellipsis, maxLines = 1,
) overflow = TextOverflow.Ellipsis,
modifier = Modifier
.padding(top = 8.dp)
)
}
} }
} }
} }
@ -200,7 +204,10 @@ fun VideoItemShimmer(
Column { Column {
TextPlaceholder() TextPlaceholder()
TextPlaceholder() TextPlaceholder()
TextPlaceholder() TextPlaceholder(
modifier = Modifier
.padding(top = 8.dp)
)
} }
} }
} }
@ -287,7 +294,6 @@ fun PlaylistItemShimmer(
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) { Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
TextPlaceholder() TextPlaceholder()
TextPlaceholder() TextPlaceholder()
TextPlaceholder()
} }
} }
} }
@ -369,7 +375,10 @@ fun AlbumItemShimmer(
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) { Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
TextPlaceholder() TextPlaceholder()
TextPlaceholder() TextPlaceholder()
TextPlaceholder() TextPlaceholder(
modifier = Modifier
.padding(top = 8.dp)
)
} }
} }
} }
@ -405,6 +414,17 @@ fun ArtistItem(
maxLines = 2, maxLines = 2,
overflow = TextOverflow.Ellipsis 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)) { 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( data class Artist(
val info: Info<NavigationEndpoint.Endpoint.Browse>, val info: Info<NavigationEndpoint.Endpoint.Browse>,
val subscribersCountText: String?,
override val thumbnail: ThumbnailRenderer.MusicThumbnailRenderer.Thumbnail.Thumbnail? override val thumbnail: ThumbnailRenderer.MusicThumbnailRenderer.Thumbnail.Thumbnail?
) : Item() { ) : Item() {
override val key: String? override val key: String?
@ -329,7 +330,7 @@ object YouTube {
val Filter = Filter("EgWKAQIgAWoKEAkQChAFEAMQBA%3D%3D") val Filter = Filter("EgWKAQIgAWoKEAkQChAFEAMQBA%3D%3D")
override fun from(content: MusicShelfRenderer.Content): Artist { override fun from(content: MusicShelfRenderer.Content): Artist {
val (mainRuns) = content.runs val (mainRuns, otherRuns) = content.runs
return Artist( return Artist(
info = Info( info = Info(
@ -341,6 +342,10 @@ object YouTube {
.navigationEndpoint .navigationEndpoint
?.browseEndpoint ?.browseEndpoint
), ),
subscribersCountText = otherRuns
.lastOrNull()
?.last()
?.text,
thumbnail = content thumbnail = content
.thumbnail .thumbnail
) )