From c287b76fd968f4915964e3c8961564fcd119616d Mon Sep 17 00:00:00 2001 From: Charlie Morley Date: Sun, 2 Apr 2023 13:24:19 -0600 Subject: [PATCH] Youtube premieres identified by isLive videoDetails json key --- .../source/youtube/DefaultYoutubeTrackDetails.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/youtube/DefaultYoutubeTrackDetails.java b/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/youtube/DefaultYoutubeTrackDetails.java index b573fd5bb..ce51e3c29 100644 --- a/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/youtube/DefaultYoutubeTrackDetails.java +++ b/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/youtube/DefaultYoutubeTrackDetails.java @@ -94,6 +94,7 @@ private AudioTrackInfo loadTrackInfo() { TemporalInfo temporalInfo = TemporalInfo.fromRawData( videoDetails.get("isLiveContent").asBoolean(false), + videoDetails.get("isLive").asBoolean(false), videoDetails.get("lengthSeconds") ); @@ -109,6 +110,7 @@ private AudioTrackInfo loadLegacyTrackInfo() { TemporalInfo temporalInfo = TemporalInfo.fromRawData( "1".equals(args.get("live_playback").text()), + false, args.get("length_seconds") ); @@ -129,11 +131,11 @@ private TemporalInfo(boolean isActiveStream, long durationMillis) { this.durationMillis = durationMillis; } - public static TemporalInfo fromRawData(boolean wasLiveStream, JsonBrowser durationSecondsField) { + public static TemporalInfo fromRawData(boolean wasLiveStream, boolean isSpecifiedLive, JsonBrowser durationSecondsField) { long durationValue = durationSecondsField.asLong(0L); // VODs are not really live streams, even though that field in JSON claims they are. If it is actually live, then // duration is also missing or 0. - boolean isActiveStream = wasLiveStream && durationValue == 0; + boolean isActiveStream = isSpecifiedLive || (wasLiveStream && durationValue == 0); return new TemporalInfo( isActiveStream,