added torrent url in streams

This commit is contained in:
Ritvik Saraf 2018-12-30 15:00:57 +05:30
parent b1a77fa484
commit ef0ffb2229
3 changed files with 20 additions and 3 deletions

View File

@ -148,10 +148,11 @@ public class PeertubeStreamExtractor extends StreamExtractor {
if(!(s instanceof JsonObject)) continue; if(!(s instanceof JsonObject)) continue;
JsonObject stream = (JsonObject) s; JsonObject stream = (JsonObject) s;
String url = JsonUtils.getString(stream, "fileUrl"); String url = JsonUtils.getString(stream, "fileUrl");
String torrentUrl = JsonUtils.getString(stream, "torrentUrl");
String resolution = JsonUtils.getString(stream, "resolution.label"); String resolution = JsonUtils.getString(stream, "resolution.label");
String extension = url.substring(url.lastIndexOf(".") + 1); String extension = url.substring(url.lastIndexOf(".") + 1);
MediaFormat format = MediaFormat.getFromSuffix(extension); 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)) { if (!Stream.containSimilarStream(videoStream, videoStreams)) {
videoStreams.add(videoStream); videoStreams.add(videoStream);
} }

View File

@ -1,13 +1,14 @@
package org.schabi.newpipe.extractor.stream; package org.schabi.newpipe.extractor.stream;
import org.schabi.newpipe.extractor.MediaFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import org.schabi.newpipe.extractor.MediaFormat;
public abstract class Stream implements Serializable { public abstract class Stream implements Serializable {
private final MediaFormat mediaFormat; private final MediaFormat mediaFormat;
public final String url; public final String url;
public final String torrentUrl;
/** /**
* @deprecated Use {@link #getFormat()} or {@link #getFormatId()} * @deprecated Use {@link #getFormat()} or {@link #getFormatId()}
@ -16,7 +17,12 @@ public abstract class Stream implements Serializable {
public final int format; public final int format;
public Stream(String url, MediaFormat format) { public Stream(String url, MediaFormat format) {
this(url, null, format);
}
public Stream(String url, String torrentUrl, MediaFormat format) {
this.url = url; this.url = url;
this.torrentUrl = torrentUrl;
this.format = format.id; this.format = format.id;
this.mediaFormat = format; this.mediaFormat = format;
} }

View File

@ -36,6 +36,16 @@ public class VideoStream extends Stream {
this.resolution = resolution; this.resolution = resolution;
this.isVideoOnly = isVideoOnly; 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 @Override
public boolean equalStats(Stream cmp) { public boolean equalStats(Stream cmp) {