Skip to content

Commit c4dcef4

Browse files
authored
Merge pull request #1319 from AudricV/peertube_support-video-only-streams-properly
[PeerTube] Detect video-only streams
2 parents c043d08 + 3042e40 commit c4dcef4

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,11 +652,17 @@ private void addNewVideoStream(@Nonnull final JsonObject streamJsonObject,
652652
final MediaFormat format = MediaFormat.getFromSuffix(extension);
653653
final String id = resolution + "-" + extension;
654654

655+
// Check if the hasAudio property is present to keep compatibility with instances < 6.3.0,
656+
// otherwise any video stream with an audio track will be marked as video only for these
657+
// instances
658+
final boolean isVideoOnly = streamJsonObject.has("hasAudio")
659+
&& !streamJsonObject.getBoolean("hasAudio");
660+
655661
// Add progressive HTTP streams first
656662
videoStreams.add(new VideoStream.Builder()
657663
.setId(id + "-" + idSuffix + "-" + DeliveryMethod.PROGRESSIVE_HTTP)
658664
.setContent(url, true)
659-
.setIsVideoOnly(false)
665+
.setIsVideoOnly(isVideoOnly)
660666
.setResolution(resolution)
661667
.setMediaFormat(format)
662668
.build());
@@ -671,7 +677,7 @@ private void addNewVideoStream(@Nonnull final JsonObject streamJsonObject,
671677
final VideoStream videoStream = new VideoStream.Builder()
672678
.setId(id + "-" + DeliveryMethod.HLS)
673679
.setContent(hlsStreamUrl, true)
674-
.setIsVideoOnly(false)
680+
.setIsVideoOnly(isVideoOnly)
675681
.setDeliveryMethod(DeliveryMethod.HLS)
676682
.setResolution(resolution)
677683
.setMediaFormat(format)
@@ -688,7 +694,7 @@ private void addNewVideoStream(@Nonnull final JsonObject streamJsonObject,
688694
videoStreams.add(new VideoStream.Builder()
689695
.setId(id + "-" + idSuffix + "-" + DeliveryMethod.TORRENT)
690696
.setContent(torrentUrl, true)
691-
.setIsVideoOnly(false)
697+
.setIsVideoOnly(isVideoOnly)
692698
.setDeliveryMethod(DeliveryMethod.TORRENT)
693699
.setResolution(resolution)
694700
.setMediaFormat(format)

0 commit comments

Comments
 (0)