mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-07 10:35: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;
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
import static app.revanced.integrations.utils.ReVancedUtils.containsAny;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import app.revanced.integrations.settings.SettingsEnum;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
import app.revanced.integrations.shared.PlayerType;
|
import app.revanced.integrations.shared.PlayerType;
|
||||||
import app.revanced.integrations.utils.LogHelper;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import app.revanced.integrations.utils.ReVancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
|
||||||
|
import static app.revanced.integrations.utils.ReVancedUtils.containsAny;
|
||||||
|
|
||||||
public class SpoofSignatureVerificationPatch {
|
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.
|
* Protobuf parameters used for autoplay in scrim.
|
||||||
* Prepend this parameter to mute video playback (for autoplay in feed)
|
* 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";
|
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.
|
* 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.
|
* Target Protobuf parameters.
|
||||||
@ -66,17 +72,18 @@ public class SpoofSignatureVerificationPatch {
|
|||||||
|
|
||||||
LogHelper.printDebug(() -> "Original protobuf parameter value: " + originalValue);
|
LogHelper.printDebug(() -> "Original protobuf parameter value: " + originalValue);
|
||||||
|
|
||||||
// Video is Short or Story.
|
if (!WORKAROUND) return PROTOBUF_PLAYER_PARAMS;
|
||||||
var isPlayingShorts = originalValue.contains(PROTOBUF_PARAMETER_SHORTS);
|
|
||||||
if (isPlayingShorts) return originalValue;
|
var isPlayingVideo = originalValue.contains(PROTOBUF_PLAYER_PARAMS);
|
||||||
|
if (isPlayingVideo) return originalValue;
|
||||||
|
|
||||||
boolean isPlayingFeed = containsAny(originalValue, PROTOBUF_PARAMETER_TARGETS) && PlayerType.getCurrent() == PlayerType.INLINE_MINIMAL;
|
boolean isPlayingFeed = containsAny(originalValue, PROTOBUF_PARAMETER_TARGETS) && PlayerType.getCurrent() == PlayerType.INLINE_MINIMAL;
|
||||||
if (isPlayingFeed) {
|
if (isPlayingFeed) {
|
||||||
// Videos in feed won't autoplay with sound.
|
// Videos in feed won't autoplay with sound.
|
||||||
return PROTOBUF_PARAMETER_SCRIM + PROTOBUF_PARAMETER_SHORTS;
|
return PROTOBUF_PARAMETER_SCRIM + PROTOBUF_PLAYER_PARAMS;
|
||||||
} else {
|
} else {
|
||||||
// Spoof the parameter to prevent playback issues.
|
// Spoof the parameter to prevent playback issues.
|
||||||
return PROTOBUF_PARAMETER_SHORTS;
|
return PROTOBUF_PLAYER_PARAMS;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(() -> "overrideProtobufParameter failure", 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).
|
// 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.
|
// 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.
|
// Check for these known default shorts captions parameters, and replace with the known correct values.
|
||||||
|
Loading…
Reference in New Issue
Block a user