diff --git a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/client/AppClient.kt b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/client/AppClient.kt index d741b51c5..731203771 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/client/AppClient.kt +++ b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/client/AppClient.kt @@ -207,8 +207,14 @@ object AppClient { val clientVersion: String, /** * If the client can access the API logged in. + * If false, 'Authorization' must not be included. */ - val canLogin: Boolean = true, + val supportsCookies: Boolean = true, + /** + * If the client can only access the API logged in. + * If true, 'Authorization' must be included. + */ + val requireAuth: Boolean = false, /** * Whether a poToken is required to get playback for more than 1 minute. */ @@ -234,6 +240,7 @@ object AppClient { userAgent = USER_AGENT_ANDROID_UNPLUGGED, androidSdkVersion = ANDROID_SDK_VERSION_ANDROID_UNPLUGGED, clientVersion = CLIENT_VERSION_ANDROID_UNPLUGGED, + requireAuth = true, friendlyName = "Android TV" ), IOS_UNPLUGGED( @@ -242,6 +249,7 @@ object AppClient { osVersion = OS_VERSION_IOS, userAgent = USER_AGENT_IOS_UNPLUGGED, clientVersion = CLIENT_VERSION_IOS_UNPLUGGED, + requireAuth = true, friendlyName = if (forceAVC()) "iOS TV Force AVC" else @@ -253,7 +261,7 @@ object AppClient { osVersion = OS_VERSION_IOS, userAgent = USER_AGENT_IOS, clientVersion = CLIENT_VERSION_IOS, - canLogin = false, + supportsCookies = false, requirePoToken = true, friendlyName = if (forceAVC()) "iOS Force AVC" @@ -265,6 +273,7 @@ object AppClient { userAgent = USER_AGENT_ANDROID_MUSIC, androidSdkVersion = ANDROID_SDK_VERSION_ANDROID_MUSIC, clientVersion = CLIENT_VERSION_ANDROID_MUSIC, + requireAuth = true, friendlyName = "Android Music" ); diff --git a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/PlayerRoutes.kt b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/PlayerRoutes.kt index 36bf03e01..666e04858 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/PlayerRoutes.kt +++ b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/PlayerRoutes.kt @@ -71,7 +71,7 @@ object PlayerRoutes { client.put("deviceMake", "Apple") client.put("osName", "iOS") } - if (!clientType.canLogin) { + if (!clientType.supportsCookies) { client.put("hl", LOCALE_LANGUAGE) } diff --git a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/StreamingDataRequest.kt b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/StreamingDataRequest.kt index 1d6837b9f..3732774a4 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/StreamingDataRequest.kt +++ b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/StreamingDataRequest.kt @@ -194,7 +194,7 @@ class StreamingDataRequest private constructor( var value = playerHeaders[key] if (value != null) { if (key == AUTHORIZATION_HEADER) { - if (!clientType.canLogin) { + if (!clientType.supportsCookies) { Logger.printDebug { "Not including request header: $key" } continue } @@ -260,6 +260,11 @@ class StreamingDataRequest private constructor( // Retry with different client if empty response body is received. for (clientType in CLIENT_ORDER_TO_USE) { + if (clientType.requireAuth && + playerHeaders[AUTHORIZATION_HEADER] == null) { + Logger.printDebug { "Skipped login-required client (incognito mode or not logged in)\nClient: $clientType\nVideo: $videoId" } + continue + } send( clientType, videoId, diff --git a/patches/src/main/resources/youtube/settings/host/values/strings.xml b/patches/src/main/resources/youtube/settings/host/values/strings.xml index 8ce18e22a..746137b9d 100644 --- a/patches/src/main/resources/youtube/settings/host/values/strings.xml +++ b/patches/src/main/resources/youtube/settings/host/values/strings.xml @@ -1907,16 +1907,21 @@ Tap the continue button and allow optimization changes." "Streaming data is not spoofed. Video playback may not work." Turning off this setting may cause video playback issues. Default client - Android TV + "Android TV +(Login required)" Android VR - iOS - iOS TV + "iOS +(PoToken required)" + "iOS TV +(Login required)" Spoofing side effects "• Audio track menu is missing. • Stable volume is not available. -• Disable forced auto audio tracks is not available." - • There may be playback issues (Deprecated). - • Movies or paid videos may not play. +• Disable forced auto audio tracks is not available. +• Kids videos may not play when logged out or in incognito mode." + • There may be playback issues (PoToken required). + "• Movies or paid videos may not play. +• Kids videos may not play when logged out or in incognito mode." Force iOS AVC (H.264) Video codec is forced to AVC (H.264). Video codec is determined automatically.