Fix #186
This commit is contained in:
parent
36a8f9623e
commit
a26eebd806
3 changed files with 46 additions and 5 deletions
|
@ -7,9 +7,9 @@ import kotlinx.coroutines.withContext
|
|||
|
||||
data class YouTubeRadio(
|
||||
private val videoId: String? = null,
|
||||
private val playlistId: String? = null,
|
||||
private val playlistSetVideoId: String? = null,
|
||||
private val parameters: String? = null
|
||||
private var playlistId: String? = null,
|
||||
private var playlistSetVideoId: String? = null,
|
||||
private var parameters: String? = null
|
||||
) {
|
||||
private var nextContinuation: String? = null
|
||||
|
||||
|
@ -24,6 +24,10 @@ data class YouTubeRadio(
|
|||
playlistSetVideoId = playlistSetVideoId,
|
||||
continuation = nextContinuation
|
||||
)?.getOrNull()?.let { nextResult ->
|
||||
playlistId = nextResult.playlistId
|
||||
parameters = nextResult.params
|
||||
playlistSetVideoId = nextResult.playlistSetVideoId
|
||||
|
||||
mediaItems = nextResult.items?.map(YouTube.Item.Song::asMediaItem)
|
||||
nextResult.continuation?.takeUnless { nextContinuation == nextResult.continuation }
|
||||
}
|
||||
|
|
|
@ -631,6 +631,9 @@ object YouTube {
|
|||
.tabs
|
||||
|
||||
NextResult(
|
||||
playlistId = playlistId,
|
||||
playlistSetVideoId = playlistSetVideoId,
|
||||
params = params,
|
||||
continuation = (tabs
|
||||
.getOrNull(0)
|
||||
?.tabRenderer
|
||||
|
@ -652,6 +655,23 @@ object YouTube {
|
|||
?: body.continuationContents)
|
||||
?.playlistPanelRenderer
|
||||
?.contents
|
||||
?.also {
|
||||
// TODO: we should parse the MusicResponsiveListItemRenderer menu so we can
|
||||
// avoid an extra network request
|
||||
it.lastOrNull()
|
||||
?.automixPreviewVideoRenderer
|
||||
?.content
|
||||
?.automixPlaylistVideoRenderer
|
||||
?.navigationEndpoint
|
||||
?.watchPlaylistEndpoint
|
||||
?.let { endpoint ->
|
||||
return next(
|
||||
videoId = videoId,
|
||||
playlistId = endpoint.playlistId,
|
||||
params = endpoint.params
|
||||
)
|
||||
}
|
||||
}
|
||||
?.mapNotNull { it.playlistPanelVideoRenderer }
|
||||
?.mapNotNull { renderer ->
|
||||
Item.Song(
|
||||
|
@ -706,6 +726,9 @@ object YouTube {
|
|||
|
||||
data class NextResult(
|
||||
val continuation: String?,
|
||||
val playlistId: String?,
|
||||
val params: String? = null,
|
||||
val playlistSetVideoId: String? = null,
|
||||
val items: List<Item.Song>?,
|
||||
val lyrics: Lyrics?,
|
||||
val related: Related?,
|
||||
|
@ -997,4 +1020,3 @@ object YouTube {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ data class NextResponse(
|
|||
) {
|
||||
@Serializable
|
||||
data class Content(
|
||||
val playlistPanelVideoRenderer: PlaylistPanelVideoRenderer?
|
||||
val playlistPanelVideoRenderer: PlaylistPanelVideoRenderer?,
|
||||
val automixPreviewVideoRenderer: AutomixPreviewVideoRenderer?,
|
||||
) {
|
||||
@Serializable
|
||||
data class PlaylistPanelVideoRenderer(
|
||||
|
@ -39,6 +40,20 @@ data class NextResponse(
|
|||
val videoId: String,
|
||||
val playlistSetVideoId: String?,
|
||||
)
|
||||
@Serializable
|
||||
data class AutomixPreviewVideoRenderer(
|
||||
val content: Content?
|
||||
) {
|
||||
@Serializable
|
||||
data class Content(
|
||||
val automixPlaylistVideoRenderer: AutomixPlaylistVideoRenderer?
|
||||
) {
|
||||
@Serializable
|
||||
data class AutomixPlaylistVideoRenderer(
|
||||
val navigationEndpoint: NavigationEndpoint
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue