Split PlaylistOrAlbumScreen
This commit is contained in:
@@ -723,7 +723,114 @@ object YouTube {
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun playlistOrAlbum(browseId: String): Outcome<PlaylistOrAlbum> {
|
||||
suspend fun playlistOrAlbum(browseId: String): Result<PlaylistOrAlbum> {
|
||||
return browse2(browseId).map { body ->
|
||||
PlaylistOrAlbum(
|
||||
title = body
|
||||
.header
|
||||
?.musicDetailHeaderRenderer
|
||||
?.title
|
||||
?.text,
|
||||
thumbnail = body
|
||||
.header
|
||||
?.musicDetailHeaderRenderer
|
||||
?.thumbnail
|
||||
?.musicThumbnailRenderer
|
||||
?.thumbnail
|
||||
?.thumbnails
|
||||
?.firstOrNull(),
|
||||
authors = body
|
||||
.header
|
||||
?.musicDetailHeaderRenderer
|
||||
?.subtitle
|
||||
?.splitBySeparator()
|
||||
?.getOrNull(1)
|
||||
?.map { Info.from(it) },
|
||||
year = body
|
||||
.header
|
||||
?.musicDetailHeaderRenderer
|
||||
?.subtitle
|
||||
?.splitBySeparator()
|
||||
?.getOrNull(2)
|
||||
?.firstOrNull()
|
||||
?.text,
|
||||
items = body
|
||||
.contents
|
||||
.singleColumnBrowseResultsRenderer
|
||||
?.tabs
|
||||
?.firstOrNull()
|
||||
?.tabRenderer
|
||||
?.content
|
||||
?.sectionListRenderer
|
||||
?.contents
|
||||
?.firstOrNull()
|
||||
?.musicShelfRenderer
|
||||
?.contents
|
||||
?.map(MusicShelfRenderer.Content::musicResponsiveListItemRenderer)
|
||||
?.mapNotNull { renderer ->
|
||||
PlaylistOrAlbum.Item(
|
||||
info = renderer
|
||||
.flexColumns
|
||||
.getOrNull(0)
|
||||
?.musicResponsiveListItemFlexColumnRenderer
|
||||
?.text
|
||||
?.runs
|
||||
?.getOrNull(0)
|
||||
?.let { Info.from(it) } ?: return@mapNotNull null,
|
||||
authors = renderer
|
||||
.flexColumns
|
||||
.getOrNull(1)
|
||||
?.musicResponsiveListItemFlexColumnRenderer
|
||||
?.text
|
||||
?.runs
|
||||
?.map { Info.from<NavigationEndpoint.Endpoint.Browse>(it) }
|
||||
?.takeIf { it.isNotEmpty() },
|
||||
durationText = renderer
|
||||
.fixedColumns
|
||||
?.getOrNull(0)
|
||||
?.musicResponsiveListItemFlexColumnRenderer
|
||||
?.text
|
||||
?.runs
|
||||
?.getOrNull(0)
|
||||
?.text,
|
||||
album = renderer
|
||||
.flexColumns
|
||||
.getOrNull(2)
|
||||
?.musicResponsiveListItemFlexColumnRenderer
|
||||
?.text
|
||||
?.runs
|
||||
?.firstOrNull()
|
||||
?.let { Info.from(it) },
|
||||
thumbnail = renderer
|
||||
.thumbnail
|
||||
?.musicThumbnailRenderer
|
||||
?.thumbnail
|
||||
?.thumbnails
|
||||
?.firstOrNull()
|
||||
)
|
||||
}
|
||||
?.filter { it.info.endpoint != null },
|
||||
url = body
|
||||
.microformat
|
||||
?.microformatDataRenderer
|
||||
?.urlCanonical,
|
||||
continuation = body
|
||||
.contents
|
||||
.singleColumnBrowseResultsRenderer
|
||||
?.tabs
|
||||
?.firstOrNull()
|
||||
?.tabRenderer
|
||||
?.content
|
||||
?.sectionListRenderer
|
||||
?.continuations
|
||||
?.firstOrNull()
|
||||
?.nextRadioContinuationData
|
||||
?.continuation
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun playlistOrAlbum2(browseId: String): Outcome<PlaylistOrAlbum> {
|
||||
return browse(browseId).map { body ->
|
||||
PlaylistOrAlbum(
|
||||
title = body
|
||||
|
||||
Reference in New Issue
Block a user