Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show all account playlists, not only the first 24 #1598

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions innertube/src/main/java/com/zionhuang/innertube/YouTube.kt
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,35 @@ object YouTube {
}

suspend fun likedPlaylists(): Result<List<PlaylistItem>> = runCatching {
val response = innerTube.browse(
var response = innerTube.browse(
client = WEB_REMIX,
browseId = "FEmusic_liked_playlists",
setLogin = true
).body<BrowseResponse>()
response.contents?.singleColumnBrowseResultsRenderer?.tabs?.firstOrNull()?.tabRenderer?.content?.sectionListRenderer?.contents?.firstOrNull()?.gridRenderer?.items!!
val gridRenderer = response.contents?.singleColumnBrowseResultsRenderer?.tabs?.firstOrNull()?.tabRenderer?.content?.sectionListRenderer?.contents?.firstOrNull()?.gridRenderer
val playlists = gridRenderer?.items!!
.drop(1) // the first item is "create new playlist"
.mapNotNull(GridRenderer.Item::musicTwoRowItemRenderer)
.mapNotNull {
ArtistItemsPage.fromMusicTwoRowItemRenderer(it) as? PlaylistItem
}
}.toMutableList()
var continuation = gridRenderer?.continuations?.getContinuation()
while (continuation != null) {
response = innerTube.browse(
client = WEB_REMIX,
continuation = continuation,
setLogin = true
).body<BrowseResponse>()
val gridContinuation = response.continuationContents?.gridContinuation
playlists += gridContinuation?.items!!
.drop(1) // the first item is "create new playlist"
.mapNotNull(GridRenderer.Item::musicTwoRowItemRenderer)
.mapNotNull {
ArtistItemsPage.fromMusicTwoRowItemRenderer(it) as? PlaylistItem
}
continuation = gridContinuation?.continuations?.getContinuation()
}
playlists
}

suspend fun player(videoId: String, playlistId: String? = null): Result<PlayerResponse> = runCatching {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.serialization.Serializable
data class GridRenderer(
val header: Header?,
val items: List<Item>,
val continuations: List<Continuation>?
) {
@Serializable
data class Header(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.zionhuang.innertube.models.response

import com.zionhuang.innertube.models.Button
import com.zionhuang.innertube.models.Continuation
import com.zionhuang.innertube.models.GridRenderer.Item
import com.zionhuang.innertube.models.Menu
import com.zionhuang.innertube.models.MusicShelfRenderer
import com.zionhuang.innertube.models.ResponseContext
Expand Down Expand Up @@ -49,6 +50,7 @@ data class BrowseResponse(
data class ContinuationContents(
val sectionListContinuation: SectionListContinuation?,
val musicPlaylistShelfContinuation: MusicPlaylistShelfContinuation?,
val gridContinuation: GidContinuation
) {
@Serializable
data class SectionListContinuation(
Expand All @@ -61,6 +63,12 @@ data class BrowseResponse(
val contents: List<MusicShelfRenderer.Content>,
val continuations: List<Continuation>?,
)

@Serializable
data class GidContinuation(
val items: List<Item>,
val continuations: List<Continuation>?,
)
}

@Serializable
Expand Down