Skip to content

Commit

Permalink
Fix livestream misdetection
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Sep 26, 2024
1 parent e4ec766 commit 1ef9ebf
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ private TemporalInfo(boolean isActiveStream, long durationMillis) {
// normal video? but has liveStreamability: PRRBJOn_n-Y
// livestream: jfKfPfyJRdk

// active premieres have liveStreamability and videoDetails.isLive = true, videoDetails.isLiveContent = false.
// they do retain their lengthSeconds value.

@NotNull
public static TemporalInfo fromRawData(JsonBrowser playabilityStatus, JsonBrowser videoDetails) {
JsonBrowser durationField = videoDetails.get("lengthSeconds");
long durationValue = durationField.asLong(0L);

boolean hasLivestreamability = !playabilityStatus.get("liveStreamability").isNull();
// boolean hasLivestreamability = !playabilityStatus.get("liveStreamability").isNull();
boolean isLive = videoDetails.get("isLive").asBoolean(false)
|| videoDetails.get("isLiveContent").asBoolean(false);

if (hasLivestreamability) {
if (isLive) { // hasLivestreamability
// Premieres have duration information, but act as a normal stream. When we play it, we don't know the
// current position of it since YouTube doesn't provide such information, so assume duration is unknown.
durationValue = 0;
}

return new TemporalInfo(
(isLive || hasLivestreamability) && durationValue == 0,
isLive,
durationValue == 0 ? DURATION_MS_UNKNOWN : Units.secondsToMillis(durationValue)
);
}
Expand Down

0 comments on commit 1ef9ebf

Please sign in to comment.