Skip to content

Commit

Permalink
fix(YouTube - Spoof video stream): Remove UI client type setting. All…
Browse files Browse the repository at this point in the history
…ow setting default audio language. (#4184)
  • Loading branch information
LisoUseInAIKyrios authored Dec 21, 2024
1 parent 7179f7e commit 99f3f29
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static app.revanced.extension.shared.settings.Setting.parent;

import app.revanced.extension.shared.spoof.AudioStreamLanguage;
import app.revanced.extension.shared.spoof.ClientType;

/**
* Settings shared across multiple apps.
Expand All @@ -22,6 +21,4 @@ public class BaseSettings {

public static final BooleanSetting SPOOF_VIDEO_STREAMS = new BooleanSetting("revanced_spoof_video_streams", TRUE, true, "revanced_spoof_video_streams_user_dialog_message");
public static final EnumSetting<AudioStreamLanguage> SPOOF_VIDEO_STREAMS_LANGUAGE = new EnumSetting<>("revanced_spoof_video_streams_language", AudioStreamLanguage.DEFAULT, parent(SPOOF_VIDEO_STREAMS));
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR, true, parent(SPOOF_VIDEO_STREAMS));

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,43 @@

public enum ClientType {
// https://dumps.tadiphone.dev/dumps/oculus/eureka
ANDROID_VR(
ANDROID_VR_NO_AUTH( // Must be first so a default audio language can be set.
28,
"ANDROID_VR",
"Quest 3",
"12",
"com.google.android.apps.youtube.vr.oculus/1.56.21 (Linux; U; Android 12; GB) gzip",
"32", // Android 12.1
"1.56.21",
true
),
false),
// Fall over to authenticated ('hl' is ignored and audio is same as language set in users Google account).
ANDROID_VR(
ANDROID_VR_NO_AUTH.id,
ANDROID_VR_NO_AUTH.clientName,
ANDROID_VR_NO_AUTH.deviceModel,
ANDROID_VR_NO_AUTH.osVersion,
ANDROID_VR_NO_AUTH.userAgent,
ANDROID_VR_NO_AUTH.androidSdkVersion,
ANDROID_VR_NO_AUTH.clientVersion,
true),
ANDROID_UNPLUGGED(
29,
"ANDROID_UNPLUGGED",
"Google TV Streamer",
"14",
"com.google.android.apps.youtube.unplugged/8.49.0 (Linux; U; Android 14; GB) gzip",
"34",
"8.49.0",
true
),
true), // Requires login.
ANDROID_CREATOR(
14,
"Android",
"11",
"com.google.android.apps.youtube.creator/24.45.100 (Linux; U; Android 11) gzip",
"30",
"24.45.100",
true
);
"ANDROID_CREATOR",
"Android",
"11",
"com.google.android.apps.youtube.creator/24.45.100 (Linux; U; Android 11) gzip",
"30",
"24.45.100",
true); // Requires login.

/**
* YouTube
Expand Down Expand Up @@ -75,14 +85,15 @@ public enum ClientType {
public final boolean canLogin;

ClientType(int id,
String clientName,
String deviceModel,
String osVersion,
String userAgent,
@Nullable String androidSdkVersion,
String clientVersion,
boolean canLogin) {
this.id = id;
this.clientName = name();
this.clientName = clientName;
this.deviceModel = deviceModel;
this.osVersion = osVersion;
this.userAgent = userAgent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import app.revanced.extension.shared.Logger;
import app.revanced.extension.shared.Utils;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.settings.EnumSetting;
import app.revanced.extension.shared.settings.Setting;
import app.revanced.extension.shared.spoof.requests.StreamingDataRequest;

Expand All @@ -35,8 +34,7 @@ public static final class NotSpoofingAndroidAvailability implements Setting.Avai
@Override
public boolean isAvailable() {
if (SpoofVideoStreamsPatch.isPatchIncluded()) {
EnumSetting<ClientType> setting = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE;
return !setting.isAvailable() || setting.get().androidSdkVersion == null;
return !BaseSettings.SPOOF_VIDEO_STREAMS.get();
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public class StreamingDataRequest {

private static final ClientType[] CLIENT_ORDER_TO_USE;
private static final ClientType[] CLIENT_ORDER_TO_USE = ClientType.values();
private static final String AUTHORIZATION_HEADER = "Authorization";
private static final String[] REQUEST_HEADER_KEYS = {
AUTHORIZATION_HEADER, // Available only to logged-in users.
Expand Down Expand Up @@ -67,21 +67,6 @@ protected boolean removeEldestEntry(Entry eldest) {
}
});

static {
ClientType[] allClientTypes = ClientType.values();
ClientType preferredClient = BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get();

CLIENT_ORDER_TO_USE = new ClientType[allClientTypes.length];
CLIENT_ORDER_TO_USE[0] = preferredClient;

int i = 1;
for (ClientType c : allClientTypes) {
if (c != preferredClient) {
CLIENT_ORDER_TO_USE[i++] = c;
}
}
}

private final String videoId;
private final Future<ByteBuffer> future;

Expand Down Expand Up @@ -178,7 +163,7 @@ private static ByteBuffer fetch(String videoId, Map<String, String> playerHeader
// gzip encoding doesn't response with content length (-1),
// but empty response body does.
if (connection.getContentLength() == 0) {
Logger.printDebug(() -> "Received empty response for video: " + videoId);
Logger.printDebug(() -> "Received empty response for client: " + clientType);
} else {
try (InputStream inputStream = new BufferedInputStream(connection.getInputStream());
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,11 @@ val spoofVideoStreamsPatch = spoofVideoStreamsPatch({
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
preferences = setOf(
SwitchPreference("revanced_spoof_video_streams"),
ListPreference(
"revanced_spoof_video_streams_client_type",
summaryKey = null,
),
ListPreference(
"revanced_spoof_video_streams_language",
summaryKey = null
),
NonInteractivePreference("revanced_spoof_video_streams_about_android")
NonInteractivePreference("revanced_spoof_video_streams_about")
),
),
)
Expand Down
12 changes: 0 additions & 12 deletions patches/src/main/resources/addresources/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<resources>
<app id="youtube">
<patch id="misc.fix.playback.spoofVideoStreamsPatch">
<string-array name="revanced_spoof_video_streams_client_type_entries">
<!-- Operating system names are not translatable, so no need to use strings.xml -->
<item>Android VR</item>
<item>Android TV</item>
<item>Android Creator</item>
</string-array>
<string-array name="revanced_spoof_video_streams_client_type_entry_values">
<!-- Enum names from extension -->
<item>ANDROID_VR</item>
<item>ANDROID_UNPLUGGED</item>
<item>ANDROID_CREATOR</item>
</string-array>
<string-array name="revanced_spoof_video_streams_language_entries">
<item>@string/revanced_spoof_video_streams_language_DEFAULT</item>
<item>@string/revanced_spoof_video_streams_language_AR</item>
Expand Down
4 changes: 2 additions & 2 deletions patches/src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1297,8 +1297,8 @@ Enabling this can unlock higher video qualities"</string>
Video playback may not work"</string>
<string name="revanced_spoof_video_streams_user_dialog_message">Turning off this setting may cause video playback issues.</string>
<string name="revanced_spoof_video_streams_client_type_title">Default client</string>
<string name="revanced_spoof_video_streams_about_android_title">Android spoofing side effects</string>
<string name="revanced_spoof_video_streams_about_android_summary">"• Kids videos may not play
<string name="revanced_spoof_video_streams_about_title">Spoofing side effects</string>
<string name="revanced_spoof_video_streams_about_summary">"• Kids videos may not play
• Audio track menu is missing
• Stable volume is not available
• Force original audio is not available"</string>
Expand Down

0 comments on commit 99f3f29

Please sign in to comment.