Skip to content

Commit

Permalink
fix: scope on other albums
Browse files Browse the repository at this point in the history
  • Loading branch information
z-huang authored and Malopieds committed Aug 30, 2024
1 parent 75f9006 commit 94aee05
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ fun AlbumScreen(
val haptic = LocalHapticFeedback.current
val coroutineScope = rememberCoroutineScope()
val playerConnection = LocalPlayerConnection.current ?: return

val scope = rememberCoroutineScope()

val isPlaying by playerConnection.isPlaying.collectAsState()
val mediaMetadata by playerConnection.mediaMetadata.collectAsState()

Expand Down Expand Up @@ -520,7 +523,7 @@ fun AlbumScreen(
item = item,
isActive = mediaMetadata?.album?.id == item.id,
isPlaying = isPlaying,
coroutineScope = coroutineScope,
coroutineScope = scope,
modifier =
Modifier
.combinedClickable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AlbumViewModel
.album(albumId)
.onSuccess {
playlistId.value = it.album.playlistId
otherVersions.value = it.album.otherVersions
otherVersions.value = it.otherVersions
database.transaction {
if (album == null) {
insert(it)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<string name="from_your_library">From your library</string>

<!-- Album screen -->
<string name="other_versions">Other Versions</string>
<string name="other_versions">Other versions</string>

<!-- Library -->
<string name="liked">Liked</string>
Expand Down
33 changes: 21 additions & 12 deletions innertube/src/main/java/com/malopieds/innertube/YouTube.kt
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,19 @@ object YouTube {
?.thumbnails
?.lastOrNull()
?.url!!,
otherVersions =
response.contents.twoColumnBrowseResultsRenderer.secondaryContents
?.sectionListRenderer
?.contents
?.getOrNull(
1,
)?.musicCarouselShelfRenderer
?.contents
?.mapNotNull { it.musicTwoRowItemRenderer }
?.mapNotNull(NewReleaseAlbumPage::fromMusicTwoRowItemRenderer)
.orEmpty(),
),
songs = if (withSongs) albumSongs(playlistId).getOrThrow() else emptyList(),
otherVersions =
response.contents.twoColumnBrowseResultsRenderer.secondaryContents
?.sectionListRenderer
?.contents
?.getOrNull(
1,
)?.musicCarouselShelfRenderer
?.contents
?.mapNotNull { it.musicTwoRowItemRenderer }
?.mapNotNull(NewReleaseAlbumPage::fromMusicTwoRowItemRenderer)
.orEmpty(),
)
}

Expand Down Expand Up @@ -922,7 +922,16 @@ object YouTube {
endpoint.params,
continuation,
).body<NextResponse>()
val title = response.contents.singleColumnMusicWatchNextResultsRenderer.tabbedRenderer.watchNextTabbedResultsRenderer.tabs[0].tabRenderer.content?.musicQueueRenderer?.header?.musicQueueHeaderRenderer?.subtitle?.runs?.firstOrNull()?.text
val title =
response.contents.singleColumnMusicWatchNextResultsRenderer.tabbedRenderer.watchNextTabbedResultsRenderer.tabs[0]
.tabRenderer.content
?.musicQueueRenderer
?.header
?.musicQueueHeaderRenderer
?.subtitle
?.runs
?.firstOrNull()
?.text
val playlistPanelRenderer =
response.continuationContents?.playlistPanelContinuation
?: response.contents.singleColumnMusicWatchNextResultsRenderer.tabbedRenderer.watchNextTabbedResultsRenderer.tabs[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ data class AlbumItem(
val year: Int? = null,
override val thumbnail: String,
override val explicit: Boolean = false,
val otherVersions: List<AlbumItem> = emptyList(),
) : YTItem() {
override val shareLink: String
get() = "https://music.youtube.com/playlist?list=$playlistId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.malopieds.innertube.utils.parseTime
data class AlbumPage(
val album: AlbumItem,
val songs: List<SongItem>,
val otherVersions: List<AlbumItem>,
) {
companion object {
fun fromMusicResponsiveListItemRenderer(renderer: MusicResponsiveListItemRenderer): SongItem? {
Expand Down

0 comments on commit 94aee05

Please sign in to comment.