From 7d7cc087e2a486702d0cbd2d4da89db29b7f866c Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 18 Jun 2021 16:25:10 +0200 Subject: [PATCH] [PeerTube] Support livestreams --- .../peertube/extractors/PeertubeStreamExtractor.java | 9 +++++++-- .../extractors/PeertubeStreamInfoItemExtractor.java | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java index 46dc6379..16f46bc0 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java @@ -199,7 +199,7 @@ public class PeertubeStreamExtractor extends StreamExtractor { @Nonnull @Override public String getHlsUrl() { - return ""; + return json.getArray("streamingPlaylists").getObject(0).getString("playlistUrl"); } @Override @@ -227,6 +227,11 @@ public class PeertubeStreamExtractor extends StreamExtractor { throw new ParsingException("Could not get video streams", e); } + if (getStreamType() == StreamType.LIVE_STREAM) { + final String url = getHlsUrl(); + videoStreams.add(new VideoStream(url, MediaFormat.MPEG_4, "720p")); + } + return videoStreams; } @@ -283,7 +288,7 @@ public class PeertubeStreamExtractor extends StreamExtractor { @Override public StreamType getStreamType() { - return StreamType.VIDEO_STREAM; + return json.getBoolean("isLive") ? StreamType.LIVE_STREAM : StreamType.VIDEO_STREAM; } @Nullable diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamInfoItemExtractor.java index 7ea3e1d8..df6060bd 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamInfoItemExtractor.java @@ -82,7 +82,7 @@ public class PeertubeStreamInfoItemExtractor implements StreamInfoItemExtractor @Override public StreamType getStreamType() { - return StreamType.VIDEO_STREAM; + return item.getBoolean("isLive") ? StreamType.LIVE_STREAM : StreamType.VIDEO_STREAM; } @Override