Skip to content

Commit

Permalink
skip WEB_CREATOR client for logged out users
Browse files Browse the repository at this point in the history
  • Loading branch information
gechoto authored Jan 7, 2025
1 parent cc1b8be commit 81febb4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/zionhuang/music/utils/YTPlayerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ object YTPlayerUtils {
} else {
// after main client use fallback clients
val client = STREAM_FALLBACK_CLIENTS[clientIndex]
if (client.loginRequired && YouTube.cookie == null) {
// skip client if it requires login but user is not logged in
continue
}

streamPlayerResponse =
YouTube.player(videoId, playlistId, client, signatureTimestamp).getOrNull()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class InnerTube {
append("X-YouTube-Client-Version", client.clientVersion)
append("X-Origin", YouTubeClient.ORIGIN_YOUTUBE_MUSIC)
append("Referer", YouTubeClient.REFERER_YOUTUBE_MUSIC)
if (setLogin && client.supportsLogin) {
if (setLogin && client.loginSupported) {
cookie?.let { cookie ->
append("cookie", cookie)
if ("SAPISID" !in cookieMap) return@let
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ data class YouTubeClient(
val clientId: String,
val userAgent: String,
val osVersion: String? = null,
val supportsLogin: Boolean = false,
val loginSupported: Boolean = false,
val loginRequired: Boolean = false,
val useSignatureTimestamp: Boolean = false,
// val origin: String? = null,
// val referer: String? = null,
Expand Down Expand Up @@ -47,7 +48,7 @@ data class YouTubeClient(
clientVersion = "1.20241127.01.00",
clientId = "67",
userAgent = USER_AGENT_WEB,
supportsLogin = true,
loginSupported = true,
useSignatureTimestamp = true,
)

Expand All @@ -56,7 +57,8 @@ data class YouTubeClient(
clientVersion = "1.20241203.01.00",
clientId = "62",
userAgent = USER_AGENT_WEB,
supportsLogin = true,
loginSupported = true,
loginRequired = true,
useSignatureTimestamp = true,
)

Expand All @@ -65,7 +67,7 @@ data class YouTubeClient(
clientVersion = "2.0",
clientId = "85",
userAgent = "Mozilla/5.0 (PlayStation; PlayStation 4/12.00) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15",
supportsLogin = true,
loginSupported = true,
useSignatureTimestamp = true,
)

Expand Down

0 comments on commit 81febb4

Please sign in to comment.