fix(YouTube - Spoof signature): fix error toast when viewing very old YouTube videos (#525)

This commit is contained in:
LisoUseInAIKyrios 2023-11-25 23:30:15 +02:00 committed by GitHub
parent 9eb0471989
commit eede028c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 4 deletions

View File

@ -169,7 +169,17 @@ public class SpoofSignaturePatch {
* if {@link SettingsEnum#SPOOF_STORYBOARD_RENDERER} is not enabled.
*/
public static boolean getSeekbarThumbnailOverrideValue() {
return SettingsEnum.SPOOF_SIGNATURE.getBoolean();
if (!SettingsEnum.SPOOF_SIGNATURE.getBoolean()) {
return false;
}
StoryboardRenderer renderer = videoRenderer;
if (renderer == null) {
// Spoof storyboard renderer is turned off,
// video is paid, or the storyboard fetch timed out.
// Show empty thumbnails so the seek time and chapters still show up.
return true;
}
return renderer.getSpec() != null;
}
/**

View File

@ -1,23 +1,23 @@
package app.revanced.integrations.patches.spoof;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
public final class StoryboardRenderer {
@Nullable
private final String spec;
private final boolean isLiveStream;
@Nullable
private final Integer recommendedLevel;
public StoryboardRenderer(String spec, boolean isLiveStream, @Nullable Integer recommendedLevel) {
public StoryboardRenderer(@Nullable String spec, boolean isLiveStream, @Nullable Integer recommendedLevel) {
this.spec = spec;
this.isLiveStream = isLiveStream;
this.recommendedLevel = recommendedLevel;
}
@NonNull
@Nullable
public String getSpec() {
return spec;
}

View File

@ -24,6 +24,14 @@ import app.revanced.integrations.utils.ReVancedUtils;
public class StoryboardRendererRequester {
/**
* For videos that have no storyboard.
* Usually for low resolution videos as old as YouTube itself.
* Does not include paid videos where the renderer fetch fails.
*/
private static final StoryboardRenderer emptyStoryboard
= new StoryboardRenderer(null, false, null);
private StoryboardRendererRequester() {
}
@ -105,6 +113,10 @@ public class StoryboardRendererRequester {
private static StoryboardRenderer getStoryboardRendererUsingResponse(@NonNull JSONObject playerResponse) {
try {
LogHelper.printDebug(() -> "Parsing response: " + playerResponse);
if (!playerResponse.has("storyboards")) {
LogHelper.printDebug(() -> "Using empty storyboard");
return emptyStoryboard;
}
final JSONObject storyboards = playerResponse.getJSONObject("storyboards");
final boolean isLiveStream = storyboards.has("playerLiveStoryboardSpecRenderer");
final String storyboardsRendererTag = isLiveStream