Skip to content

Commit 7eeffd3

Browse files
fix(YouTube Music - Spoof video streams): Remove iPadOS client
1 parent 6c33911 commit 7eeffd3

File tree

12 files changed

+59
-48
lines changed

12 files changed

+59
-48
lines changed

extensions/music/src/main/java/app/revanced/extension/music/patches/spoof/SpoofVideoStreamsPatch.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package app.revanced.extension.music.patches.spoof;
22

3+
import static app.revanced.extension.music.settings.Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE;
34
import static app.revanced.extension.shared.spoof.ClientType.ANDROID_VR_1_43_32;
45
import static app.revanced.extension.shared.spoof.ClientType.ANDROID_VR_1_61_48;
56
import static app.revanced.extension.shared.spoof.ClientType.VISIONOS;
@@ -22,6 +23,8 @@ public static void setClientOrderToUse() {
2223
VISIONOS
2324
);
2425

25-
StreamingDataRequest.setClientOrderToUse(availableClients, ANDROID_VR_1_43_32);
26+
ClientType client = SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();
27+
app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch.setPreferredClient(client);
28+
StreamingDataRequest.setClientOrderToUse(availableClients, client);
2629
}
2730
}

extensions/music/src/main/java/app/revanced/extension/music/settings/Settings.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
import static java.lang.Boolean.FALSE;
44
import static java.lang.Boolean.TRUE;
55

6+
import static app.revanced.extension.shared.settings.Setting.parent;
7+
68
import app.revanced.extension.shared.settings.BaseSettings;
79
import app.revanced.extension.shared.settings.BooleanSetting;
10+
import app.revanced.extension.shared.settings.EnumSetting;
11+
import app.revanced.extension.shared.spoof.ClientType;
812

913
public class Settings extends BaseSettings {
1014

@@ -18,4 +22,8 @@ public class Settings extends BaseSettings {
1822

1923
// Player
2024
public static final BooleanSetting PERMANENT_REPEAT = new BooleanSetting("revanced_music_play_permanent_repeat", FALSE, true);
25+
26+
// Miscellaneous
27+
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type",
28+
ClientType.ANDROID_VR_1_43_32, true, parent(SPOOF_VIDEO_STREAMS));
2129
}

extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/BaseSettings.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import static app.revanced.extension.shared.settings.Setting.parent;
66
import static app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch.AudioStreamLanguageOverrideAvailability;
77

8-
import app.revanced.extension.shared.spoof.ClientType;
9-
108
/**
119
* Settings shared across multiple apps.
1210
* <p>
@@ -30,6 +28,4 @@ public class BaseSettings {
3028
public static final BooleanSetting SPOOF_VIDEO_STREAMS = new BooleanSetting("revanced_spoof_video_streams", TRUE, true, "revanced_spoof_video_streams_user_dialog_message");
3129
public static final EnumSetting<AppLanguage> SPOOF_VIDEO_STREAMS_LANGUAGE = new EnumSetting<>("revanced_spoof_video_streams_language", AppLanguage.DEFAULT, new AudioStreamLanguageOverrideAvailability());
3230
public static final BooleanSetting SPOOF_STREAMING_DATA_STATS_FOR_NERDS = new BooleanSetting("revanced_spoof_streaming_data_stats_for_nerds", TRUE, parent(SPOOF_VIDEO_STREAMS));
33-
// Client type must be last spoof setting due to cyclic references.
34-
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR_1_61_48, true, parent(SPOOF_VIDEO_STREAMS));
3531
}

extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/ClientType.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public enum ClientType {
3131
"132.0.6808.3",
3232
"1.61.48",
3333
false,
34-
false,
3534
"Android VR 1.61"
3635
),
3736
/**
@@ -50,7 +49,6 @@ public enum ClientType {
5049
Objects.requireNonNull(ANDROID_VR_1_61_48.buildId),
5150
"107.0.5284.2",
5251
"1.43.32",
53-
ANDROID_VR_1_61_48.requiresAuth,
5452
ANDROID_VR_1_61_48.useAuth,
5553
"Android VR 1.43"
5654
),
@@ -71,7 +69,6 @@ public enum ClientType {
7169
"132.0.6779.0",
7270
"23.47.101",
7371
true,
74-
true,
7572
"Android Creator"
7673
),
7774
/**
@@ -86,7 +83,6 @@ public enum ClientType {
8683
"0.1",
8784
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15",
8885
false,
89-
false,
9086
"visionOS"
9187
),
9288
/**
@@ -111,7 +107,6 @@ public enum ClientType {
111107
"19.22.3",
112108
"com.google.ios.youtube/19.22.3 (iPad7,6; U; CPU iPadOS 17_7_10 like Mac OS X; " + Locale.getDefault() + ")",
113109
false,
114-
false,
115110
"iPadOS"
116111
);
117112

@@ -180,12 +175,6 @@ public enum ClientType {
180175
*/
181176
public final String clientVersion;
182177

183-
/**
184-
* If this client requires authentication and does not work
185-
* if logged out or in incognito mode.
186-
*/
187-
public final boolean requiresAuth;
188-
189178
/**
190179
* If the client should use authentication if available.
191180
*/
@@ -210,7 +199,6 @@ public enum ClientType {
210199
@NonNull String buildId,
211200
@NonNull String cronetVersion,
212201
String clientVersion,
213-
boolean requiresAuth,
214202
boolean useAuth,
215203
String friendlyName) {
216204
this.id = id;
@@ -224,7 +212,6 @@ public enum ClientType {
224212
this.buildId = buildId;
225213
this.cronetVersion = cronetVersion;
226214
this.clientVersion = clientVersion;
227-
this.requiresAuth = requiresAuth;
228215
this.useAuth = useAuth;
229216
this.friendlyName = friendlyName;
230217

@@ -250,7 +237,6 @@ public enum ClientType {
250237
String osVersion,
251238
String clientVersion,
252239
String userAgent,
253-
boolean requiresAuth,
254240
boolean useAuth,
255241
String friendlyName) {
256242
this.id = id;
@@ -261,7 +247,6 @@ public enum ClientType {
261247
this.osVersion = osVersion;
262248
this.clientVersion = clientVersion;
263249
this.userAgent = userAgent;
264-
this.requiresAuth = requiresAuth;
265250
this.useAuth = useAuth;
266251
this.friendlyName = friendlyName;
267252
this.packageName = null;

extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import java.nio.ByteBuffer;
99
import java.util.Map;
10+
import java.util.Objects;
1011

1112
import app.revanced.extension.shared.Logger;
1213
import app.revanced.extension.shared.Utils;
@@ -17,14 +18,6 @@
1718

1819
@SuppressWarnings("unused")
1920
public class SpoofVideoStreamsPatch {
20-
private static final boolean SPOOF_STREAMING_DATA = BaseSettings.SPOOF_VIDEO_STREAMS.get();
21-
22-
private static final boolean FIX_HLS_CURRENT_TIME = SPOOF_STREAMING_DATA
23-
&& BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.VISIONOS;
24-
25-
@Nullable
26-
private static volatile AppLanguage languageOverride;
27-
2821
/**
2922
* Domain used for internet connectivity verification.
3023
* It has an empty response body and is only used to check for a 204 response code.
@@ -40,17 +33,23 @@ public class SpoofVideoStreamsPatch {
4033
private static final String INTERNET_CONNECTION_CHECK_URI_STRING = "https://www.google.com/gen_204";
4134
private static final Uri INTERNET_CONNECTION_CHECK_URI = Uri.parse(INTERNET_CONNECTION_CHECK_URI_STRING);
4235

36+
private static final boolean SPOOF_STREAMING_DATA = BaseSettings.SPOOF_VIDEO_STREAMS.get();
37+
38+
@Nullable
39+
private static volatile AppLanguage languageOverride;
40+
41+
private static volatile ClientType preferredClient = ClientType.ANDROID_VR_1_61_48;
42+
4343
/**
4444
* @return If this patch was included during patching.
4545
*/
4646
private static boolean isPatchIncluded() {
4747
return false; // Modified during patching.
4848
}
4949

50-
public static boolean spoofingToClientWithNoMultiAudioStreams() {
51-
return isPatchIncluded()
52-
&& BaseSettings.SPOOF_VIDEO_STREAMS.get()
53-
&& BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() != ClientType.IPADOS;
50+
@Nullable
51+
public static AppLanguage getLanguageOverride() {
52+
return languageOverride;
5453
}
5554

5655
/**
@@ -61,9 +60,14 @@ public static void setLanguageOverride(@Nullable AppLanguage language) {
6160
languageOverride = language;
6261
}
6362

64-
@Nullable
65-
public static AppLanguage getLanguageOverride() {
66-
return languageOverride;
63+
public static void setPreferredClient(ClientType client) {
64+
preferredClient = Objects.requireNonNull(client);
65+
}
66+
67+
public static boolean spoofingToClientWithNoMultiAudioStreams() {
68+
return isPatchIncluded()
69+
&& SPOOF_STREAMING_DATA
70+
&& preferredClient != ClientType.IPADOS;
6771
}
6872

6973
/**
@@ -278,8 +282,7 @@ public static String appendSpoofedClient(String videoFormat) {
278282
public static final class AudioStreamLanguageOverrideAvailability implements Setting.Availability {
279283
@Override
280284
public boolean isAvailable() {
281-
// Since all current clients are un-authenticated, this works for all spoof clients.
282-
return BaseSettings.SPOOF_VIDEO_STREAMS.get();
285+
return BaseSettings.SPOOF_VIDEO_STREAMS.get() && !preferredClient.useAuth;
283286
}
284287
}
285288
}

extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/PlayerRoutes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ static String createInnertubeBody(ClientType clientType, String videoId) {
4242
JSONObject context = new JSONObject();
4343

4444
AppLanguage language = SpoofVideoStreamsPatch.getLanguageOverride();
45-
if (language == null || BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ANDROID_VR_1_43_32) {
45+
if (language == null || clientType == ANDROID_VR_1_43_32) {
4646
// Force original audio has not overrode the language.
47-
// Or if YT has fallen over to the very last client (VR 1.43), then always
48-
// use the app language because forcing an audio stream of specific languages
47+
// Or if YT has fallen over to the last unauthenticated client (VR 1.43), then
48+
// always use the app language because forcing an audio stream of specific languages
4949
// can sometimes fail so it's better to try and load something rather than nothing.
5050
language = BaseSettings.SPOOF_VIDEO_STREAMS_LANGUAGE.get();
5151
}

extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/requests/StreamingDataRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private static HttpURLConnection send(ClientType clientType,
177177
}
178178
}
179179

180-
if (!authHeadersIncludes && clientType.requiresAuth) {
180+
if (!authHeadersIncludes && clientType.useAuth) {
181181
Logger.printDebug(() -> "Skipping client since user is not logged in: " + clientType
182182
+ " videoId: " + videoId);
183183
return null;

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/spoof/SpoofVideoStreamsPatch.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import java.util.List;
1010

11-
import app.revanced.extension.shared.settings.BaseSettings;
1211
import app.revanced.extension.shared.spoof.ClientType;
1312
import app.revanced.extension.shared.spoof.requests.StreamingDataRequest;
13+
import app.revanced.extension.youtube.settings.Settings;
1414

1515
@SuppressWarnings("unused")
1616
public class SpoofVideoStreamsPatch {
@@ -27,7 +27,8 @@ public static void setClientOrderToUse() {
2727
IPADOS
2828
);
2929

30-
StreamingDataRequest.setClientOrderToUse(availableClients,
31-
BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get());
30+
ClientType client = Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();
31+
app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch.setPreferredClient(client);
32+
StreamingDataRequest.setClientOrderToUse(availableClients, client);
3233
}
3334
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import app.revanced.extension.shared.settings.Setting;
4242
import app.revanced.extension.shared.settings.StringSetting;
4343
import app.revanced.extension.shared.settings.preference.SharedPrefCategory;
44+
import app.revanced.extension.shared.spoof.ClientType;
4445
import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.DeArrowAvailability;
4546
import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.StillImagesAvailability;
4647
import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.ThumbnailOption;
@@ -356,6 +357,7 @@ public class Settings extends BaseSettings {
356357
public static final BooleanSetting REMOVE_TRACKING_QUERY_PARAMETER = new BooleanSetting("revanced_remove_tracking_query_parameter", TRUE);
357358
public static final BooleanSetting SPOOF_DEVICE_DIMENSIONS = new BooleanSetting("revanced_spoof_device_dimensions", FALSE, true,
358359
"revanced_spoof_device_dimensions_user_dialog_message");
360+
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR_1_61_48, true, parent(SPOOF_VIDEO_STREAMS));
359361
public static final BooleanSetting DEBUG_PROTOBUFFER = new BooleanSetting("revanced_debug_protobuffer", FALSE, false,
360362
"revanced_debug_protobuffer_user_dialog_message", parent(BaseSettings.DEBUG));
361363

extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/preference/SpoofStreamingDataSideEffectsPreference.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import app.revanced.extension.shared.settings.BaseSettings;
1616
import app.revanced.extension.shared.settings.Setting;
1717
import app.revanced.extension.shared.spoof.ClientType;
18+
import app.revanced.extension.youtube.settings.Settings;
1819

1920
@SuppressWarnings({"deprecation", "unused"})
2021
public class SpoofStreamingDataSideEffectsPreference extends Preference {
@@ -69,7 +70,7 @@ protected void onPrepareForRemoval() {
6970
}
7071

7172
private void updateUI() {
72-
ClientType clientType = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();
73+
ClientType clientType = Settings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();
7374
if (currentClientType == clientType) {
7475
return;
7576
}

0 commit comments

Comments
 (0)