Skip to content

Commit

Permalink
fix(innertube): wrong playlist song artist
Browse files Browse the repository at this point in the history
  • Loading branch information
Malopieds committed Aug 27, 2024
1 parent bed5a63 commit 1d67973
Showing 1 changed file with 17 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,6 @@ data class PlaylistPage(
) {
companion object {
fun fromMusicResponsiveListItemRenderer(renderer: MusicResponsiveListItemRenderer): SongItem? {
val artists: List<Artist>? =
renderer.flexColumns
.getOrNull(1)
?.musicResponsiveListItemFlexColumnRenderer
?.text
?.runs
?.oddElements()
?.map {
Artist(
name = it.text,
id = it.navigationEndpoint?.browseEndpoint?.browseId,
)
}

val collaborators: List<Artist>? =
renderer.flexColumns
.getOrNull(2)
?.musicResponsiveListItemFlexColumnRenderer
?.text
?.runs
?.oddElements()
?.map {
Artist(
name = it.text,
id = it.navigationEndpoint?.browseEndpoint?.browseId,
)
}
return SongItem(
id = renderer.playlistItemData?.videoId ?: return null,
title =
Expand All @@ -54,22 +27,25 @@ data class PlaylistPage(
?.firstOrNull()
?.text ?: return null,
artists =
if (collaborators != null) {
artists!!.plus(collaborators)
} else {
artists
} ?: return null,
album =
renderer.flexColumns.getOrNull(2)?.musicResponsiveListItemFlexColumnRenderer?.text?.runs?.firstOrNull()?.let {
val browseId = it.navigationEndpoint?.browseEndpoint?.browseId
if (browseId != null) {
Album(
renderer.flexColumns
.getOrNull(1)
?.musicResponsiveListItemFlexColumnRenderer
?.text
?.runs
?.oddElements()
?.map {
Artist(
name = it.text,
id = browseId,
id = it.navigationEndpoint?.browseEndpoint?.browseId,
)
} else {
null
}
}.orEmpty()
.ifEmpty { return null },
album =
renderer.flexColumns.getOrNull(2)?.musicResponsiveListItemFlexColumnRenderer?.text?.runs?.firstOrNull()?.let {
Album(
name = it.text,
id = it.navigationEndpoint?.browseEndpoint?.browseId ?: return@let null,
)
},
duration =
renderer.fixedColumns
Expand Down

0 comments on commit 1d67973

Please sign in to comment.