Skip to content

Commit

Permalink
Fail-fast extraction if the initial player response is invalid.
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Jun 2, 2023
1 parent 533121f commit f063dd1
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,10 @@ public void onFetchPage(@Nonnull final Downloader downloader)
playerMicroFormatRenderer = youtubePlayerResponse.getObject("microformat")
.getObject("playerMicroformatRenderer");

if (isPlayerResponseNotValid(playerResponse, videoId)) {
throw new ExtractionException("Initial player response is not valid");
}

final byte[] body = JsonWriter.string(
prepareDesktopJsonBuilder(localization, contentCountry)
.value(VIDEO_ID, videoId)
Expand Down Expand Up @@ -1058,6 +1062,11 @@ private void fetchTvHtml5EmbedJsonPlayer(@Nonnull final ContentCountry contentCo
final JsonObject tvHtml5EmbedPlayerResponse = getJsonPostResponse(PLAYER,
createDesktopPlayerBody(localization, contentCountry, videoId, sts, true,
html5Cpn), localization);

if (isPlayerResponseNotValid(tvHtml5EmbedPlayerResponse, videoId)) {
return;
}

final JsonObject streamingData = tvHtml5EmbedPlayerResponse.getObject(
STREAMING_DATA);
if (!isNullOrEmpty(streamingData)) {
Expand Down

0 comments on commit f063dd1

Please sign in to comment.