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.
This commit is contained in:
TiA4f8R 2021-05-31 15:57:11 +02:00
parent ae5abc0c5d
commit b52732a1c3
No known key found for this signature in database
GPG Key ID: E6D3E7F5949450DD
1 changed files with 2 additions and 4 deletions

View File

@ -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");