Set userAgent to ANDROID client (#385)
This commit is contained in:
@@ -160,7 +160,7 @@ fun Thumbnail(
|
|||||||
is PlayableFormatNotFoundException -> "Couldn't find a playable audio format"
|
is PlayableFormatNotFoundException -> "Couldn't find a playable audio format"
|
||||||
is UnplayableException -> "The original video source of this song has been deleted"
|
is UnplayableException -> "The original video source of this song has been deleted"
|
||||||
is LoginRequiredException -> "This song cannot be played due to server restrictions"
|
is LoginRequiredException -> "This song cannot be played due to server restrictions"
|
||||||
is VideoIdMismatchException -> "The returned video id didn't match the requested one"
|
is VideoIdMismatchException -> "The returned video id doesn't match the requested one"
|
||||||
else -> "An unknown playback error has occurred"
|
else -> "An unknown playback error has occurred"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ data class Context(
|
|||||||
val platform: String,
|
val platform: String,
|
||||||
val hl: String = "en",
|
val hl: String = "en",
|
||||||
val visitorData: String? = null,
|
val visitorData: String? = null,
|
||||||
val androidSdkVersion: Int? = null
|
val androidSdkVersion: Int? = null,
|
||||||
|
val userAgent: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -37,7 +38,8 @@ data class Context(
|
|||||||
clientName = "ANDROID",
|
clientName = "ANDROID",
|
||||||
clientVersion = "17.36.4",
|
clientVersion = "17.36.4",
|
||||||
platform = "MOBILE",
|
platform = "MOBILE",
|
||||||
androidSdkVersion = 31,
|
androidSdkVersion = 30,
|
||||||
|
userAgent = "com.google.android.youtube/17.36.4 (Linux; U; Android 11) gzip"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.ktor.client.request.post
|
|||||||
import io.ktor.client.request.setBody
|
import io.ktor.client.request.setBody
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.http.contentType
|
import io.ktor.http.contentType
|
||||||
|
import io.ktor.http.userAgent
|
||||||
import it.vfsfitvnm.youtubemusic.Innertube
|
import it.vfsfitvnm.youtubemusic.Innertube
|
||||||
import it.vfsfitvnm.youtubemusic.models.Context
|
import it.vfsfitvnm.youtubemusic.models.Context
|
||||||
import it.vfsfitvnm.youtubemusic.models.PlayerResponse
|
import it.vfsfitvnm.youtubemusic.models.PlayerResponse
|
||||||
@@ -16,6 +17,7 @@ import kotlinx.serialization.Serializable
|
|||||||
suspend fun Innertube.player(body: PlayerBody) = runCatchingNonCancellable {
|
suspend fun Innertube.player(body: PlayerBody) = runCatchingNonCancellable {
|
||||||
val response = client.post(player) {
|
val response = client.post(player) {
|
||||||
setBody(body)
|
setBody(body)
|
||||||
|
body.context.client.userAgent?.let(::userAgent)
|
||||||
mask("playabilityStatus.status,playerConfig.audioConfig,streamingData.adaptiveFormats")
|
mask("playabilityStatus.status,playerConfig.audioConfig,streamingData.adaptiveFormats")
|
||||||
}.body<PlayerResponse>()
|
}.body<PlayerResponse>()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user