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(
|
data class YouTubeRadio(
|
||||||
private val videoId: String? = null,
|
private val videoId: String? = null,
|
||||||
private val playlistId: String? = null,
|
private var playlistId: String? = null,
|
||||||
private val playlistSetVideoId: String? = null,
|
private var playlistSetVideoId: String? = null,
|
||||||
private val parameters: String? = null
|
private var parameters: String? = null
|
||||||
) {
|
) {
|
||||||
private var nextContinuation: String? = null
|
private var nextContinuation: String? = null
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ data class YouTubeRadio(
|
||||||
playlistSetVideoId = playlistSetVideoId,
|
playlistSetVideoId = playlistSetVideoId,
|
||||||
continuation = nextContinuation
|
continuation = nextContinuation
|
||||||
)?.getOrNull()?.let { nextResult ->
|
)?.getOrNull()?.let { nextResult ->
|
||||||
|
playlistId = nextResult.playlistId
|
||||||
|
parameters = nextResult.params
|
||||||
|
playlistSetVideoId = nextResult.playlistSetVideoId
|
||||||
|
|
||||||
mediaItems = nextResult.items?.map(YouTube.Item.Song::asMediaItem)
|
mediaItems = nextResult.items?.map(YouTube.Item.Song::asMediaItem)
|
||||||
nextResult.continuation?.takeUnless { nextContinuation == nextResult.continuation }
|
nextResult.continuation?.takeUnless { nextContinuation == nextResult.continuation }
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,6 +631,9 @@ object YouTube {
|
||||||
.tabs
|
.tabs
|
||||||
|
|
||||||
NextResult(
|
NextResult(
|
||||||
|
playlistId = playlistId,
|
||||||
|
playlistSetVideoId = playlistSetVideoId,
|
||||||
|
params = params,
|
||||||
continuation = (tabs
|
continuation = (tabs
|
||||||
.getOrNull(0)
|
.getOrNull(0)
|
||||||
?.tabRenderer
|
?.tabRenderer
|
||||||
|
@ -652,6 +655,23 @@ object YouTube {
|
||||||
?: body.continuationContents)
|
?: body.continuationContents)
|
||||||
?.playlistPanelRenderer
|
?.playlistPanelRenderer
|
||||||
?.contents
|
?.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 { it.playlistPanelVideoRenderer }
|
||||||
?.mapNotNull { renderer ->
|
?.mapNotNull { renderer ->
|
||||||
Item.Song(
|
Item.Song(
|
||||||
|
@ -706,6 +726,9 @@ object YouTube {
|
||||||
|
|
||||||
data class NextResult(
|
data class NextResult(
|
||||||
val continuation: String?,
|
val continuation: String?,
|
||||||
|
val playlistId: String?,
|
||||||
|
val params: String? = null,
|
||||||
|
val playlistSetVideoId: String? = null,
|
||||||
val items: List<Item.Song>?,
|
val items: List<Item.Song>?,
|
||||||
val lyrics: Lyrics?,
|
val lyrics: Lyrics?,
|
||||||
val related: Related?,
|
val related: Related?,
|
||||||
|
@ -997,4 +1020,3 @@ object YouTube {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ data class NextResponse(
|
||||||
) {
|
) {
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Content(
|
data class Content(
|
||||||
val playlistPanelVideoRenderer: PlaylistPanelVideoRenderer?
|
val playlistPanelVideoRenderer: PlaylistPanelVideoRenderer?,
|
||||||
|
val automixPreviewVideoRenderer: AutomixPreviewVideoRenderer?,
|
||||||
) {
|
) {
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PlaylistPanelVideoRenderer(
|
data class PlaylistPanelVideoRenderer(
|
||||||
|
@ -39,6 +40,20 @@ data class NextResponse(
|
||||||
val videoId: String,
|
val videoId: String,
|
||||||
val playlistSetVideoId: 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…
Add table
Reference in a new issue