diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt index 8b2fdea964..b59420247d 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt @@ -67,7 +67,7 @@ fun AlbumScreen(browseId: String) { .collect { (currentAlbum, tabIndex) -> album = currentAlbum - if (albumPage == null && (currentAlbum?.timestamp == null || tabIndex == 1)) { + if (albumPage == null && (currentAlbum?.timestamp == null || currentAlbum.title == null || tabIndex == 1)) { withContext(Dispatchers.IO) { Innertube.albumPage(BrowseBody(browseId = browseId)) ?.onSuccess { currentAlbumPage -> diff --git a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/BrowseResponse.kt b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/BrowseResponse.kt index ef7e2f8e5d..06519d234e 100644 --- a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/BrowseResponse.kt +++ b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/BrowseResponse.kt @@ -13,6 +13,7 @@ data class BrowseResponse( @Serializable data class Contents( val singleColumnBrowseResultsRenderer: Tabs?, + val twoColumnBrowseResultsRenderer: TwoColResults?, val sectionListRenderer: SectionListRenderer?, ) diff --git a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/MusicShelfRenderer.kt b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/MusicShelfRenderer.kt index 15e8659943..dab934ccef 100644 --- a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/MusicShelfRenderer.kt +++ b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/MusicShelfRenderer.kt @@ -7,7 +7,9 @@ data class MusicShelfRenderer( val bottomEndpoint: NavigationEndpoint?, val contents: List?, val continuations: List?, - val title: Runs? + val title: Runs?, + val thumbnail: ThumbnailRenderer?, + val subtitle: Runs? ) { @Serializable data class Content( @@ -23,7 +25,7 @@ data class MusicShelfRenderer( ?: emptyList()) to (musicResponsiveListItemRenderer ?.flexColumns - ?.lastOrNull() + ?.getOrNull(1) ?.musicResponsiveListItemFlexColumnRenderer ?.text ?.splitBySeparator() diff --git a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/SectionListRenderer.kt b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/SectionListRenderer.kt index 0d52b65cad..2f934a3c41 100644 --- a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/SectionListRenderer.kt +++ b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/SectionListRenderer.kt @@ -16,6 +16,8 @@ data class SectionListRenderer( val musicCarouselShelfRenderer: MusicCarouselShelfRenderer?, @JsonNames("musicPlaylistShelfRenderer") val musicShelfRenderer: MusicShelfRenderer?, + val musicResponsiveHeaderRenderer: MusicShelfRenderer?, + val musicPlaylistShelfRenderer: MusicShelfRenderer?, val gridRenderer: GridRenderer?, val musicDescriptionShelfRenderer: MusicDescriptionShelfRenderer?, ) { diff --git a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/TwoColResults.kt b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/TwoColResults.kt new file mode 100644 index 0000000000..a801d8081b --- /dev/null +++ b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/models/TwoColResults.kt @@ -0,0 +1,14 @@ +package it.vfsfitvnm.innertube.models + +import kotlinx.serialization.Serializable + +@Serializable +data class TwoColResults ( + val secondaryContents: SecondaryContents?, + val tabs: List? +) { + @Serializable + data class SecondaryContents ( + val sectionListRenderer: SectionListRenderer? + ) +} \ No newline at end of file diff --git a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/requests/ItemsPage.kt b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/requests/ItemsPage.kt index f4c17bd90d..38ac21307e 100644 --- a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/requests/ItemsPage.kt +++ b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/requests/ItemsPage.kt @@ -37,7 +37,7 @@ suspend fun Innertube.itemsPage( itemsPageFromMusicShelRendererOrGridRenderer( musicShelfRenderer = sectionListRendererContent - ?.musicShelfRenderer, + ?.musicPlaylistShelfRenderer, gridRenderer = sectionListRendererContent ?.gridRenderer, fromMusicResponsiveListItemRenderer = fromMusicResponsiveListItemRenderer, diff --git a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/requests/PlaylistPage.kt b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/requests/PlaylistPage.kt index a9824d3132..1f04433b29 100644 --- a/innertube/src/main/kotlin/it/vfsfitvnm/innertube/requests/PlaylistPage.kt +++ b/innertube/src/main/kotlin/it/vfsfitvnm/innertube/requests/PlaylistPage.kt @@ -5,8 +5,10 @@ import io.ktor.client.request.post import io.ktor.client.request.setBody import it.vfsfitvnm.innertube.Innertube import it.vfsfitvnm.innertube.models.BrowseResponse +import it.vfsfitvnm.innertube.models.Continuation import it.vfsfitvnm.innertube.models.ContinuationResponse import it.vfsfitvnm.innertube.models.MusicCarouselShelfRenderer +import it.vfsfitvnm.innertube.models.MusicResponsiveListItemRenderer import it.vfsfitvnm.innertube.models.MusicShelfRenderer import it.vfsfitvnm.innertube.models.bodies.BrowseBody import it.vfsfitvnm.innertube.models.bodies.ContinuationBody @@ -16,26 +18,31 @@ import it.vfsfitvnm.innertube.utils.runCatchingNonCancellable suspend fun Innertube.playlistPage(body: BrowseBody) = runCatchingNonCancellable { val response = client.post(browse) { setBody(body) - mask("contents.singleColumnBrowseResultsRenderer.tabs.tabRenderer.content.sectionListRenderer.contents(musicPlaylistShelfRenderer(continuations,contents.$musicResponsiveListItemRendererMask),musicCarouselShelfRenderer.contents.$musicTwoRowItemRendererMask),header.musicDetailHeaderRenderer(title,subtitle,thumbnail),microformat") + mask("contents.twoColumnBrowseResultsRenderer(tabs.tabRenderer.content.sectionListRenderer.contents.musicResponsiveHeaderRenderer(title,subtitle,thumbnail),secondaryContents.sectionListRenderer.contents(musicPlaylistShelfRenderer(continuations,contents.$musicResponsiveListItemRendererMask),musicCarouselShelfRenderer.contents.$musicTwoRowItemRendererMask)),microformat") }.body() val musicDetailHeaderRenderer = response - .header - ?.musicDetailHeaderRenderer - - val sectionListRendererContents = response .contents - ?.singleColumnBrowseResultsRenderer + ?.twoColumnBrowseResultsRenderer ?.tabs ?.firstOrNull() ?.tabRenderer ?.content ?.sectionListRenderer ?.contents + ?.firstOrNull() + ?.musicResponsiveHeaderRenderer + + val sectionListRendererContents = response + .contents + ?.twoColumnBrowseResultsRenderer + ?.secondaryContents + ?.sectionListRenderer + ?.contents val musicShelfRenderer = sectionListRendererContents ?.firstOrNull() - ?.musicShelfRenderer + ?.musicPlaylistShelfRenderer val musicCarouselShelfRenderer = sectionListRendererContents ?.getOrNull(1)