mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-05 17:45:49 +01:00
fix(youtube/client-spoof): use new visitor data to work around playback issues
See 81ca451480
This commit is contained in:
parent
4f66d05573
commit
be9c948ce6
@ -1,16 +1,20 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import static app.revanced.integrations.utils.ReVancedUtils.containsAny;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.shared.PlayerType;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
import static app.revanced.integrations.utils.ReVancedUtils.containsAny;
|
||||
|
||||
public class SpoofSignatureVerificationPatch {
|
||||
/**
|
||||
* Enable/disable all workarounds that are required due to signature spoofing.
|
||||
*/
|
||||
private static final boolean WORKAROUND = true;
|
||||
|
||||
/**
|
||||
* Protobuf parameters used for autoplay in scrim.
|
||||
* Prepend this parameter to mute video playback (for autoplay in feed)
|
||||
@ -18,10 +22,12 @@ public class SpoofSignatureVerificationPatch {
|
||||
private static final String PROTOBUF_PARAMETER_SCRIM = "SAFgAXgB";
|
||||
|
||||
/**
|
||||
* Protobuf parameter of shorts and YouTube stories.
|
||||
* Protobuf parameter also used by
|
||||
* <a href="https://github.com/yt-dlp/yt-dlp/blob/81ca451480051d7ce1a31c017e005358345a9149/yt_dlp/extractor/youtube.py#L3602">yt-dlp</a>
|
||||
* <br>
|
||||
* Known issue: captions are positioned on upper area in the player.
|
||||
*/
|
||||
private static final String PROTOBUF_PARAMETER_SHORTS = "8AEB"; // "8AEByAMTuAQP"
|
||||
private static final String PROTOBUF_PLAYER_PARAMS = "CgIQBg==";
|
||||
|
||||
/**
|
||||
* Target Protobuf parameters.
|
||||
@ -66,17 +72,18 @@ public class SpoofSignatureVerificationPatch {
|
||||
|
||||
LogHelper.printDebug(() -> "Original protobuf parameter value: " + originalValue);
|
||||
|
||||
// Video is Short or Story.
|
||||
var isPlayingShorts = originalValue.contains(PROTOBUF_PARAMETER_SHORTS);
|
||||
if (isPlayingShorts) return originalValue;
|
||||
if (!WORKAROUND) return PROTOBUF_PLAYER_PARAMS;
|
||||
|
||||
var isPlayingVideo = originalValue.contains(PROTOBUF_PLAYER_PARAMS);
|
||||
if (isPlayingVideo) return originalValue;
|
||||
|
||||
boolean isPlayingFeed = containsAny(originalValue, PROTOBUF_PARAMETER_TARGETS) && PlayerType.getCurrent() == PlayerType.INLINE_MINIMAL;
|
||||
if (isPlayingFeed) {
|
||||
// Videos in feed won't autoplay with sound.
|
||||
return PROTOBUF_PARAMETER_SCRIM + PROTOBUF_PARAMETER_SHORTS;
|
||||
return PROTOBUF_PARAMETER_SCRIM + PROTOBUF_PLAYER_PARAMS;
|
||||
} else {
|
||||
// Spoof the parameter to prevent playback issues.
|
||||
return PROTOBUF_PARAMETER_SHORTS;
|
||||
return PROTOBUF_PLAYER_PARAMS;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(() -> "overrideProtobufParameter failure", ex);
|
||||
@ -143,6 +150,10 @@ public class SpoofSignatureVerificationPatch {
|
||||
}
|
||||
}
|
||||
|
||||
if (!WORKAROUND) {
|
||||
return new int[]{ap, ah, av};
|
||||
}
|
||||
|
||||
// Videos with custom captions that specify screen positions appear to always have correct screen positions (even with spoofing).
|
||||
// But for auto generated and most other captions, the spoof incorrectly gives various default Shorts caption settings.
|
||||
// Check for these known default shorts captions parameters, and replace with the known correct values.
|
||||
|
Loading…
Reference in New Issue
Block a user