Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1382,11 +1382,14 @@ public void onSuccess(Response response) throws ExtractionException {
}
}

if (playerResponse == null) {
throw new ContentNotAvailableException(
"Could not fetch a usable YouTube player response. Try logging in.");
}

// Check playability status from the actual stream data source
if (playerResponse != null) {
checkPlayabilityStatus(playerResponse.getObject("playabilityStatus"), videoId);
setStreamType();
}
checkPlayabilityStatus(playerResponse.getObject("playabilityStatus"), videoId);
setStreamType();

if (streamType != StreamType.LIVE_STREAM && isSabrOnlyResponse()
&& getHlsManifestUrlFromStreamingData().isEmpty()) {
Expand Down Expand Up @@ -1418,8 +1421,6 @@ private boolean isSabrOnlyResponse() {
return false;
}



public static JsonObject checkPlayabilityStatus(@Nonnull JsonObject playabilityStatus, String videoId)
throws ParsingException {
String status = playabilityStatus.getString("status");
Expand Down Expand Up @@ -1478,6 +1479,10 @@ public static JsonObject checkPlayabilityStatus(@Nonnull JsonObject playabilityS
"This video is not available in client's country.");
} else {
if(detailedErrorMessage != null) {
if (detailedErrorMessage.contains("page needs to be reloaded")) {
throw new ContentNotAvailableException(detailedErrorMessage
+ " Try logging in.");
}
throw new ContentNotAvailableException(detailedErrorMessage);
}
throw new ContentNotAvailableException(reason);
Expand All @@ -1504,8 +1509,8 @@ public static JsonObject checkPlayabilityStatus(@Nonnull JsonObject playabilityS
* object.
*/
private CancellableCall fetchAndroidVRJsonPlayer(@Nonnull final ContentCountry contentCountry,
@Nonnull final Localization localization,
@Nonnull final String videoId)
@Nonnull final Localization localization,
@Nonnull final String videoId)
throws IOException, ExtractionException {
androidCpn = generateContentPlaybackNonce();
final InnertubeClientRequestInfo innertubeClientRequestInfo =
Expand Down Expand Up @@ -1536,15 +1541,16 @@ public void onSuccess(Response response) throws ExtractionException {
return;
}

YoutubeStreamExtractor.this.playerResponse = androidPlayerResponse;

final JsonObject streamingData = androidPlayerResponse.getObject(STREAMING_DATA);
if (!isNullOrEmpty(streamingData)) {
YoutubeStreamExtractor.this.playerResponse = androidPlayerResponse;
androidStreamingData = streamingData;
if (isNullOrEmpty(playerCaptionsTracklistRenderer)) {
playerCaptionsTracklistRenderer = androidPlayerResponse.getObject("captions")
.getObject("playerCaptionsTracklistRenderer");
}
} else if (YoutubeStreamExtractor.this.playerResponse == null) {
YoutubeStreamExtractor.this.playerResponse = androidPlayerResponse;
}
} catch (Exception e) {
e.printStackTrace();
Expand Down