From b52732a1c35c48bc5d3e775676f81a1efaeb149e Mon Sep 17 00:00:00 2001 From: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com> Date: Mon, 31 May 2021 15:57:11 +0200 Subject: [PATCH] Fix the fetch of the playerCode at each time getStsFromPlayerJs is called storePlayerJs was called even if sts was not empty in the getStsFromPlayerJs method. This commit fixes it. --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 984451146..6f8758b0e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -829,14 +829,11 @@ public class YoutubeStreamExtractor extends StreamExtractor { } else { // Fallback to the desktop JSON player endpoint - if (sts == null) { - sts = getStsFromPlayerJs(); - } - // The cipher signatures from the player endpoint without a timestamp are invalid so // download it again only if we didn't have a signatureTimestamp before fetching the // data of this video (the sts string). if (!stsKnown) { + sts = getStsFromPlayerJs(); final JsonObject playerResponseWithSignatureTimestamp = getJsonPostResponse( "player", createPlayerBodyWithSts(localization, contentCountry, videoId), localization); @@ -1027,6 +1024,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { } private String getStsFromPlayerJs() throws ParsingException { + if (!isNullOrEmpty(sts)) return sts; if (playerCode == null) { storePlayerJs(); if (playerCode == null) throw new ParsingException("playerCode is null");