This commit is contained in:
vfsfitvnm 2022-06-19 11:24:11 +02:00
parent f7a6481323
commit 6c15889360
4 changed files with 11 additions and 19 deletions

View file

@ -481,7 +481,7 @@ object YouTube {
info = Info(
name = renderer
.title
.text,
?.text ?: return@let null,
endpoint = renderer
.navigationEndpoint
.watchEndpoint
@ -504,7 +504,7 @@ object YouTube {
.getOrNull(0),
durationText = renderer
.lengthText
.text
?.text
)
}
}
@ -592,12 +592,12 @@ object YouTube {
?.playlistPanelRenderer
?.contents
?.mapNotNull { it.playlistPanelVideoRenderer }
?.map { renderer ->
?.mapNotNull { renderer ->
Item.Song(
info = Info(
name = renderer
.title
.text,
?.text ?: return@mapNotNull null,
endpoint = renderer
.navigationEndpoint
.watchEndpoint
@ -620,7 +620,7 @@ object YouTube {
.firstOrNull(),
durationText = renderer
.lengthText
.text
?.text
)
},
lyrics = NextResult.Lyrics(

View file

@ -30,10 +30,10 @@ data class NextResponse(
) {
@Serializable
data class PlaylistPanelVideoRenderer(
val title: Runs,
val title: Runs?,
val longBylineText: Runs?,
val shortBylineText: Runs,
val lengthText: Runs,
val shortBylineText: Runs?,
val lengthText: Runs?,
val navigationEndpoint: NavigationEndpoint,
val thumbnail: ThumbnailRenderer.MusicThumbnailRenderer.Thumbnail,
val videoId: String,

View file

@ -8,7 +8,7 @@ data class PlayerResponse(
val playabilityStatus: PlayabilityStatus,
val playerConfig: PlayerConfig?,
val streamingData: StreamingData?,
val videoDetails: VideoDetails,
val videoDetails: VideoDetails?,
) {
@Serializable
data class PlayabilityStatus(

View file

@ -20,20 +20,12 @@ data class ThumbnailRenderer(
@Serializable
data class Thumbnail(
val url: String,
val height: Int,
val width: Int
val height: Int?,
val width: Int?
) {
val isResizable: Boolean
get() = !url.startsWith("https://i.ytimg.com")
fun width(width: Int): String {
return when {
url.startsWith("https://lh3.googleusercontent.com") -> "$url-w$width-h${width * height / this.width}"
url.startsWith("https://yt3.ggpht.com") -> "$url-s$width"
else -> url
}
}
fun size(size: Int): String {
return when {
url.startsWith("https://lh3.googleusercontent.com") -> "$url-w$size-h$size"