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 2b6afbc2f..7817a2ec7 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 @@ -148,10 +148,11 @@ public class PeertubeStreamExtractor extends StreamExtractor { if(!(s instanceof JsonObject)) continue; JsonObject stream = (JsonObject) s; String url = JsonUtils.getString(stream, "fileUrl"); + String torrentUrl = JsonUtils.getString(stream, "torrentUrl"); String resolution = JsonUtils.getString(stream, "resolution.label"); String extension = url.substring(url.lastIndexOf(".") + 1); MediaFormat format = MediaFormat.getFromSuffix(extension); - VideoStream videoStream = new VideoStream(url, format, resolution); + VideoStream videoStream = new VideoStream(url, torrentUrl, format, resolution); if (!Stream.containSimilarStream(videoStream, videoStreams)) { videoStreams.add(videoStream); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java index 80208be63..754df790b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java @@ -1,13 +1,14 @@ package org.schabi.newpipe.extractor.stream; -import org.schabi.newpipe.extractor.MediaFormat; - import java.io.Serializable; import java.util.List; +import org.schabi.newpipe.extractor.MediaFormat; + public abstract class Stream implements Serializable { private final MediaFormat mediaFormat; public final String url; + public final String torrentUrl; /** * @deprecated Use {@link #getFormat()} or {@link #getFormatId()} @@ -16,7 +17,12 @@ public abstract class Stream implements Serializable { public final int format; public Stream(String url, MediaFormat format) { + this(url, null, format); + } + + public Stream(String url, String torrentUrl, MediaFormat format) { this.url = url; + this.torrentUrl = torrentUrl; this.format = format.id; this.mediaFormat = format; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java index 1e877bee3..f4531d365 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java @@ -36,6 +36,16 @@ public class VideoStream extends Stream { this.resolution = resolution; this.isVideoOnly = isVideoOnly; } + + public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) { + this(url, torrentUrl, format, resolution, false); + } + + public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution, boolean isVideoOnly) { + super(url, torrentUrl, format); + this.resolution = resolution; + this.isVideoOnly = isVideoOnly; + } @Override public boolean equalStats(Stream cmp) {