mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-11-30 15:52:55 +01:00
fix(youtube/spoof-signature-verification): fixed subtitles in wrong location (#343)
This commit is contained in:
parent
86bedb2183
commit
1a0a6ee90b
@ -95,4 +95,65 @@ public class SpoofSignatureVerificationPatch {
|
||||
LogHelper.printException(() -> "onResponse failure", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Last WindowsSetting constructor values. Values are checked for changes to reduce log spam.
|
||||
*/
|
||||
private static int lastAnchorPosition, lastAnchorHorizontal, lastAnchorVertical;
|
||||
private static boolean lastVs, lastSd;
|
||||
|
||||
/**
|
||||
* Injection point. Overrides values passed into SubtitleWindowSettings constructor.
|
||||
*
|
||||
* @param anchorPosition bitmask with 6 bit fields, that appears to be indicate the layout position on screen
|
||||
* @param anchorHorizontal percentage [0, 100], that appears to be a horizontal text anchor point
|
||||
* @param anchorVertical percentage [0, 100], that appears to be a vertical text anchor point
|
||||
* @param vs appears to indicate is subtitles exist, and value is always true.
|
||||
* @param sd appears to indicate if video has non standard aspect ratio (4:3, or a rotated orientation)
|
||||
* Always true for Shorts playback.
|
||||
*/
|
||||
public static int[] getSubtitleWindowSettingsOverride(int anchorPosition, int anchorHorizontal, int anchorVertical,
|
||||
boolean vs, boolean sd) {
|
||||
int[] override = {anchorPosition, anchorHorizontal, anchorVertical};
|
||||
|
||||
// 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 Shorts caption settings for all videos.
|
||||
// Override the parameters if the video is not a Short but it has Short caption settings.
|
||||
if (SettingsEnum.SIGNATURE_SPOOFING.getBoolean()
|
||||
&& !PlayerType.getCurrent().isNoneOrHidden() // video is not a Short or Story
|
||||
&& anchorPosition == 9 // but it has shorts specific subtitle parameters
|
||||
&& anchorHorizontal == 20
|
||||
&& anchorVertical == 0) {
|
||||
if (sd) {
|
||||
// values observed during playback
|
||||
override[0] = 33;
|
||||
override[1] = 20;
|
||||
override[2] = 100;
|
||||
} else {
|
||||
// Default values used for regular (non Shorts) playback of videos with a standard aspect ratio
|
||||
// Values are found in SubtitleWindowSettings static field
|
||||
override[0] = 34;
|
||||
override[1] = 50;
|
||||
override[2] = 95;
|
||||
}
|
||||
}
|
||||
|
||||
if (!SettingsEnum.DEBUG.getBoolean()) {
|
||||
return override;
|
||||
}
|
||||
if (anchorPosition != lastAnchorPosition
|
||||
|| anchorHorizontal != lastAnchorHorizontal || anchorVertical != lastAnchorVertical
|
||||
|| vs != lastVs || sd != lastSd) {
|
||||
LogHelper.printDebug(() -> "SubtitleWindowSettings anchorPosition:" + anchorPosition
|
||||
+ " anchorHorizontal:" + anchorHorizontal + " anchorVertical:" + anchorVertical
|
||||
+ " vs:" + vs + " sd:" + sd);
|
||||
lastAnchorPosition = anchorPosition;
|
||||
lastAnchorHorizontal = anchorHorizontal;
|
||||
lastAnchorVertical = anchorVertical;
|
||||
lastVs = vs;
|
||||
lastSd = sd;
|
||||
}
|
||||
|
||||
return override;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user