mirror of
https://github.com/revanced/revanced-integrations
synced 2024-11-27 11:13:38 +01:00
fix(YouTube - Spoof signature): fix error toast when viewing very old YouTube videos (#525)
This commit is contained in:
parent
9eb0471989
commit
eede028c96
@ -169,7 +169,17 @@ public class SpoofSignaturePatch {
|
|||||||
* if {@link SettingsEnum#SPOOF_STORYBOARD_RENDERER} is not enabled.
|
* if {@link SettingsEnum#SPOOF_STORYBOARD_RENDERER} is not enabled.
|
||||||
*/
|
*/
|
||||||
public static boolean getSeekbarThumbnailOverrideValue() {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package app.revanced.integrations.patches.spoof;
|
package app.revanced.integrations.patches.spoof;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class StoryboardRenderer {
|
public final class StoryboardRenderer {
|
||||||
|
@Nullable
|
||||||
private final String spec;
|
private final String spec;
|
||||||
private final boolean isLiveStream;
|
private final boolean isLiveStream;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Integer recommendedLevel;
|
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.spec = spec;
|
||||||
this.isLiveStream = isLiveStream;
|
this.isLiveStream = isLiveStream;
|
||||||
this.recommendedLevel = recommendedLevel;
|
this.recommendedLevel = recommendedLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@Nullable
|
||||||
public String getSpec() {
|
public String getSpec() {
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,14 @@ import app.revanced.integrations.utils.ReVancedUtils;
|
|||||||
|
|
||||||
public class StoryboardRendererRequester {
|
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() {
|
private StoryboardRendererRequester() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +113,10 @@ public class StoryboardRendererRequester {
|
|||||||
private static StoryboardRenderer getStoryboardRendererUsingResponse(@NonNull JSONObject playerResponse) {
|
private static StoryboardRenderer getStoryboardRendererUsingResponse(@NonNull JSONObject playerResponse) {
|
||||||
try {
|
try {
|
||||||
LogHelper.printDebug(() -> "Parsing response: " + playerResponse);
|
LogHelper.printDebug(() -> "Parsing response: " + playerResponse);
|
||||||
|
if (!playerResponse.has("storyboards")) {
|
||||||
|
LogHelper.printDebug(() -> "Using empty storyboard");
|
||||||
|
return emptyStoryboard;
|
||||||
|
}
|
||||||
final JSONObject storyboards = playerResponse.getJSONObject("storyboards");
|
final JSONObject storyboards = playerResponse.getJSONObject("storyboards");
|
||||||
final boolean isLiveStream = storyboards.has("playerLiveStoryboardSpecRenderer");
|
final boolean isLiveStream = storyboards.has("playerLiveStoryboardSpecRenderer");
|
||||||
final String storyboardsRendererTag = isLiveStream
|
final String storyboardsRendererTag = isLiveStream
|
||||||
|
Loading…
Reference in New Issue
Block a user