fix(YouTube - Client spoof): Fix toast shown for live streams (#489)

This commit is contained in:
LisoUseInAIKyrios 2023-09-28 17:12:14 +04:00 committed by GitHub
parent da923a38a0
commit 27f49dfd1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 15 deletions

View File

@ -128,23 +128,26 @@ public class SpoofSignaturePatch {
*/
@Nullable
public static String getStoryboardRendererSpec(String originalStoryboardRendererSpec) {
if (!SettingsEnum.SPOOF_SIGNATURE.getBoolean()) return originalStoryboardRendererSpec;
if (SettingsEnum.SPOOF_SIGNATURE.getBoolean()) {
StoryboardRenderer renderer = getRenderer();
if (renderer != null) return renderer.getSpec();
}
StoryboardRenderer renderer = getRenderer();
if (renderer == null) return originalStoryboardRendererSpec;
return renderer.getSpec();
return originalStoryboardRendererSpec;
}
/**
* Injection point.
*/
public static int getRecommendedLevel(int originalLevel) {
if (!SettingsEnum.SPOOF_SIGNATURE.getBoolean()) return originalLevel;
if (SettingsEnum.SPOOF_SIGNATURE.getBoolean()) {
StoryboardRenderer renderer = getRenderer();
if (renderer != null) {
Integer recommendedLevel = renderer.getRecommendedLevel();
if (recommendedLevel != null) return recommendedLevel;
}
}
StoryboardRenderer renderer = getRenderer();
if (renderer == null) return originalLevel;
return renderer.getRecommendedLevel();
return originalLevel;
}
}

View File

@ -1,13 +1,16 @@
package app.revanced.integrations.patches.spoof;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
public final class StoryboardRenderer {
private final String spec;
private final int recommendedLevel;
@Nullable
private final Integer recommendedLevel;
public StoryboardRenderer(String spec, int recommendedLevel) {
public StoryboardRenderer(String spec, @Nullable Integer recommendedLevel) {
this.spec = spec;
this.recommendedLevel = recommendedLevel;
}
@ -17,7 +20,11 @@ public final class StoryboardRenderer {
return spec;
}
public int getRecommendedLevel() {
/**
* @return Recommended image quality level, or NULL if no recommendation exists.
*/
@Nullable
public Integer getRecommendedLevel() {
return recommendedLevel;
}

View File

@ -49,7 +49,7 @@ public class StoryboardRendererRequester {
try {
return playerResponse.getJSONObject("playabilityStatus").getString("status").equals("OK");
} catch (JSONException e) {
LogHelper.printException(() -> "Failed to get playabilityStatus", e);
LogHelper.printDebug(() -> "Failed to get playabilityStatus for response: " + playerResponse);
}
return false;
@ -80,7 +80,9 @@ public class StoryboardRendererRequester {
final var rendererElement = storyboards.getJSONObject(storyboardsRendererTag);
StoryboardRenderer renderer = new StoryboardRenderer(
rendererElement.getString("spec"),
rendererElement.getInt("recommendedLevel")
rendererElement.has("recommendedLevel")
? rendererElement.getInt("recommendedLevel")
: null
);
LogHelper.printDebug(() -> "Fetched: " + renderer);