Skip to content

Commit

Permalink
feat(YouTube - Spoof streaming data): Remove `Use Android clients onl…
Browse files Browse the repository at this point in the history
…y` setting, restore `Force iOS AVC` setting
  • Loading branch information
inotia00 authored and anddea committed Jan 5, 2025
1 parent 93250cc commit 23b886c
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public static boolean SpoofStreamingData() {
return false;
}

public static boolean SpoofStreamingDataAndroidOnlyDefaultBoolean() {
// Replace this with true If the Spoof streaming data patch succeeds in YouTube
public static boolean SpoofStreamingDataMusic() {
// Replace this with true If the Spoof streaming data patch succeeds in YouTube Music
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.extension.shared.patches.client;

import static app.revanced.extension.shared.utils.ResourceUtils.getString;
import static app.revanced.extension.shared.patches.PatchStatus.SpoofStreamingDataMusic;

import android.os.Build;

Expand All @@ -24,7 +24,9 @@ public class AppClient {
* Store page of the YouTube app</a>, in the {@code What’s New} section.
* </p>
*/
private static final String CLIENT_VERSION_IOS = "19.29.1";
private static final String CLIENT_VERSION_IOS = forceAVC()
? "17.40.5"
: "19.29.1";
/**
* The device machine id for the iPhone 15 Pro Max (iPhone16,2), used to get HDR with AV1 hardware decoding.
*
Expand All @@ -33,9 +35,15 @@ public class AppClient {
* information.
* </p>
*/
private static final String DEVICE_MODEL_IOS = "iPhone16,2";
private static final String OS_VERSION_IOS = "17.7.2.21H221";
private static final String USER_AGENT_VERSION_IOS = "17_7_2";
private static final String DEVICE_MODEL_IOS = forceAVC()
? "iPhone12,5" // 11 Pro Max. (last device with iOS 13)
: "iPhone16,2"; // 15 Pro Max.
private static final String OS_VERSION_IOS = forceAVC()
? "13.7.17H35" // Last release of iOS 13.
: "17.7.2.21H221";
private static final String USER_AGENT_VERSION_IOS = forceAVC()
? "13_7"
: "17_7_2";
private static final String USER_AGENT_IOS =
iOSUserAgent(PACKAGE_NAME_IOS, CLIENT_VERSION_IOS);

Expand All @@ -55,7 +63,9 @@ public class AppClient {
* Store page of the YouTube TV app</a>, in the {@code What’s New} section.
* </p>
*/
private static final String CLIENT_VERSION_IOS_UNPLUGGED = "8.33";
private static final String CLIENT_VERSION_IOS_UNPLUGGED = forceAVC()
? "6.45"
: "8.33";
private static final String USER_AGENT_IOS_UNPLUGGED =
iOSUserAgent(PACKAGE_NAME_IOS_UNPLUGGED, CLIENT_VERSION_IOS_UNPLUGGED);

Expand Down Expand Up @@ -140,20 +150,6 @@ public class AppClient {
androidUserAgent(PACKAGE_NAME_ANDROID_UNPLUGGED, CLIENT_VERSION_ANDROID_UNPLUGGED, OS_VERSION_ANDROID_UNPLUGGED);


// ANDROID CREATOR
/**
* Video not playable: Livestream
* Note: Audio track is not available
*/
private static final String PACKAGE_NAME_ANDROID_CREATOR = "com.google.android.apps.youtube.creator";
private static final String CLIENT_VERSION_ANDROID_CREATOR = "24.14.101";
private static final String DEVICE_MODEL_ANDROID_CREATOR = Build.MODEL;
private static final String OS_VERSION_ANDROID_CREATOR = Build.VERSION.RELEASE;
private static final String ANDROID_SDK_VERSION_ANDROID_CREATOR = String.valueOf(Build.VERSION.SDK_INT);
private static final String USER_AGENT_ANDROID_CREATOR =
androidUserAgent(PACKAGE_NAME_ANDROID_CREATOR, CLIENT_VERSION_ANDROID_CREATOR, OS_VERSION_ANDROID_CREATOR);


private AppClient() {
}

Expand All @@ -178,45 +174,45 @@ private static String iOSUserAgent(String packageName, String clientVersion) {
}

public enum ClientType {
IOS(5,
DEVICE_MODEL_IOS,
OS_VERSION_IOS,
USER_AGENT_IOS,
null,
CLIENT_VERSION_IOS,
false
),
ANDROID_VR(28,
DEVICE_MODEL_ANDROID_VR,
OS_VERSION_ANDROID_VR,
USER_AGENT_ANDROID_VR,
ANDROID_SDK_VERSION_ANDROID_VR,
CLIENT_VERSION_ANDROID_VR,
true
true,
"Android VR"
),
ANDROID_UNPLUGGED(29,
DEVICE_MODEL_ANDROID_UNPLUGGED,
OS_VERSION_ANDROID_UNPLUGGED,
USER_AGENT_ANDROID_UNPLUGGED,
ANDROID_SDK_VERSION_ANDROID_UNPLUGGED,
CLIENT_VERSION_ANDROID_UNPLUGGED,
true
),
ANDROID_CREATOR(14,
DEVICE_MODEL_ANDROID_CREATOR,
OS_VERSION_ANDROID_CREATOR,
USER_AGENT_ANDROID_CREATOR,
ANDROID_SDK_VERSION_ANDROID_CREATOR,
CLIENT_VERSION_ANDROID_CREATOR,
true
true,
"Android TV"
),
IOS_UNPLUGGED(33,
DEVICE_MODEL_IOS,
OS_VERSION_IOS,
USER_AGENT_IOS_UNPLUGGED,
null,
CLIENT_VERSION_IOS_UNPLUGGED,
true
true,
forceAVC()
? "iOS TV Force AVC"
: "iOS TV"
),
IOS(5,
DEVICE_MODEL_IOS,
OS_VERSION_IOS,
USER_AGENT_IOS,
null,
CLIENT_VERSION_IOS,
false,
forceAVC()
? "iOS Force AVC"
: "iOS"
),
IOS_MUSIC(
26,
Expand All @@ -225,7 +221,8 @@ public enum ClientType {
USER_AGENT_IOS_MUSIC,
null,
CLIENT_VERSION_IOS_MUSIC,
true
true,
"iOS Music"
);

/**
Expand Down Expand Up @@ -268,13 +265,19 @@ public enum ClientType {
*/
public final boolean canLogin;

/**
* Friendly name displayed in stats for nerds.
*/
public final String friendlyName;

ClientType(int id,
String deviceModel,
String osVersion,
String userAgent,
@Nullable String androidSdkVersion,
String clientVersion,
boolean canLogin
boolean canLogin,
String friendlyName
) {
this.id = id;
this.clientName = name();
Expand All @@ -284,30 +287,29 @@ public enum ClientType {
this.androidSdkVersion = androidSdkVersion;
this.userAgent = userAgent;
this.canLogin = canLogin;
this.friendlyName = friendlyName;
}

private static final ClientType[] CLIENT_ORDER_TO_USE_ANDROID = {
private static final ClientType[] CLIENT_ORDER_TO_USE_YOUTUBE = {
ANDROID_VR,
ANDROID_UNPLUGGED,
ANDROID_CREATOR,
IOS_UNPLUGGED,
IOS,
};

private static final ClientType[] CLIENT_ORDER_TO_USE_DEFAULT = {
IOS,
private static final ClientType[] CLIENT_ORDER_TO_USE_YOUTUBE_MUSIC = {
ANDROID_VR,
ANDROID_UNPLUGGED,
IOS_UNPLUGGED,
IOS_MUSIC,
};
}

public final String getFriendlyName() {
return getString("revanced_spoof_streaming_data_type_entry_" + name().toLowerCase());
}
private static boolean forceAVC() {
return BaseSettings.SPOOF_STREAMING_DATA_IOS_FORCE_AVC.get();
}

public static ClientType[] getAvailableClientTypes() {
return BaseSettings.SPOOF_STREAMING_DATA_ANDROID_ONLY.get()
? ClientType.CLIENT_ORDER_TO_USE_ANDROID
: ClientType.CLIENT_ORDER_TO_USE_DEFAULT;
return SpoofStreamingDataMusic()
? ClientType.CLIENT_ORDER_TO_USE_YOUTUBE_MUSIC
: ClientType.CLIENT_ORDER_TO_USE_YOUTUBE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.apache.commons.lang3.ArrayUtils;
import org.json.JSONObject;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand All @@ -14,7 +17,6 @@
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -78,14 +80,14 @@ protected boolean removeEldestEntry(Entry eldest) {
public static String getLastSpoofedClientName() {
return lastSpoofedClientType == null
? "Unknown"
: lastSpoofedClientType.getFriendlyName();
: lastSpoofedClientType.friendlyName;
}

static {
ClientType[] allClientTypes = getAvailableClientTypes();
ClientType preferredClient = BaseSettings.SPOOF_STREAMING_DATA_TYPE.get();

if (Arrays.stream(allClientTypes).noneMatch(preferredClient::equals)) {
if (ArrayUtils.indexOf(allClientTypes, preferredClient) < 0) {
CLIENT_ORDER_TO_USE = allClientTypes;
} else {
CLIENT_ORDER_TO_USE = new ClientType[allClientTypes.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static app.revanced.extension.shared.patches.PatchStatus.HideFullscreenAdsDefaultBoolean;
import static app.revanced.extension.shared.patches.PatchStatus.SpoofStreamingDataAndroidOnlyDefaultBoolean;

import app.revanced.extension.shared.patches.ReturnYouTubeUsernamePatch.DisplayFormat;
import app.revanced.extension.shared.patches.client.AppClient.ClientType;
Expand Down Expand Up @@ -38,9 +37,11 @@ public class BaseSettings {
public static final StringSetting RETURN_YOUTUBE_USERNAME_YOUTUBE_DATA_API_V3_DEVELOPER_KEY = new StringSetting("revanced_return_youtube_username_youtube_data_api_v3_developer_key", "", true, false);

public static final BooleanSetting SPOOF_STREAMING_DATA = new BooleanSetting("revanced_spoof_streaming_data", TRUE, true, "revanced_spoof_streaming_data_user_dialog_message");
public static final EnumSetting<ClientType> SPOOF_STREAMING_DATA_TYPE = new EnumSetting<>("revanced_spoof_streaming_data_type", ClientType.ANDROID_VR, true);
public static final BooleanSetting SPOOF_STREAMING_DATA_ANDROID_ONLY = new BooleanSetting("revanced_spoof_streaming_data_android_only", SpoofStreamingDataAndroidOnlyDefaultBoolean(), true, "revanced_spoof_streaming_data_android_only_user_dialog_message");
public static final BooleanSetting SPOOF_STREAMING_DATA_IOS_FORCE_AVC = new BooleanSetting("revanced_spoof_streaming_data_ios_force_avc", FALSE, true,
"revanced_spoof_streaming_data_ios_force_avc_user_dialog_message");
public static final BooleanSetting SPOOF_STREAMING_DATA_STATS_FOR_NERDS = new BooleanSetting("revanced_spoof_streaming_data_stats_for_nerds", TRUE);
// Client type must be last spoof setting due to cyclic references.
public static final EnumSetting<ClientType> SPOOF_STREAMING_DATA_TYPE = new EnumSetting<>("revanced_spoof_streaming_data_type", ClientType.ANDROID_VR, true);

/**
* @noinspection DeprecatedIsStillUsed
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ protected void onPrepareForRemoval() {

private void updateUI() {
final String clientName = Settings.SPOOF_STREAMING_DATA_TYPE.get().name().toLowerCase();
String summaryTextKey = "revanced_spoof_streaming_data_side_effects_";

if (Settings.SPOOF_STREAMING_DATA_ANDROID_ONLY.get()) {
summaryTextKey += "android";
} else {
summaryTextKey += clientName;
}
final String summaryTextKey = "revanced_spoof_streaming_data_side_effects_" + clientName;

setSummary(str(summaryTextKey));
setEnabled(Settings.SPOOF_STREAMING_DATA.get());
Expand Down
Loading

0 comments on commit 23b886c

Please sign in to comment.