Add data to respective classes.

This commit is contained in:
FireMasterK 2021-02-11 14:40:38 +05:30
parent 525e345ed8
commit 11eb4932f4
3 changed files with 112 additions and 8 deletions

View file

@ -502,7 +502,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FORMATS, ItagItem.ItagType.AUDIO).entrySet()) {
ItagItem itag = entry.getValue();
AudioStream audioStream = new AudioStream(entry.getKey(), itag.getMediaFormat(), itag.avgBitrate);
AudioStream audioStream = new AudioStream(entry.getKey(), itag.getMediaFormat(), itag.avgBitrate, itag.bitrate, itag.initStart, itag.initEnd, itag.indexStart, itag.indexEnd, itag.codec);
if (!Stream.containSimilarStream(audioStream, audioStreams)) {
audioStreams.add(audioStream);
}
@ -542,7 +542,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FORMATS, ItagItem.ItagType.VIDEO_ONLY).entrySet()) {
ItagItem itag = entry.getValue();
VideoStream videoStream = new VideoStream(entry.getKey(), itag.getMediaFormat(), itag.resolutionString, true);
VideoStream videoStream = new VideoStream(entry.getKey(), itag.getMediaFormat(), itag.resolutionString, true, itag.bitrate, itag.initStart, itag.initEnd, itag.indexStart, itag.indexEnd, itag.codec, itag.width, itag.height);
if (!Stream.containSimilarStream(videoStream, videoOnlyStreams)) {
videoOnlyStreams.add(videoStream);
}
@ -950,19 +950,19 @@ public class YoutubeStreamExtractor extends StreamExtractor {
}
int bitrate = formatData.getInt("bitrate");
int averageBitrate = formatData.getInt("averageBitrate");
int width = formatData.getInt("width");
int height = formatData.getInt("height");
int initStart = formatData.getInt("initRange.start");
int initEnd = formatData.getInt("initRange.end");
int indexStart = formatData.getInt("indexRange.start");
int indexEnd = formatData.getInt("indexRange.end");
JsonObject initRange = formatData.getObject("initRange");
JsonObject indexRange = formatData.getObject("indexRange");
int initStart = Integer.parseInt(initRange.getString("start"));
int initEnd = Integer.parseInt(initRange.getString("end"));
int indexStart = Integer.parseInt(indexRange.getString("start"));
int indexEnd = Integer.parseInt(indexRange.getString("end"));
int fps = formatData.getInt("fps");
String mimeType = formatData.getString("mimeType", EMPTY_STRING);
String codec = mimeType.contains("codecs") ? mimeType.split("\"")[1] : EMPTY_STRING;
itagItem.bitrate = bitrate;
itagItem.avgBitrate =averageBitrate;
itagItem.width = width;
itagItem.height = height;
itagItem.initStart = initStart;

View file

@ -25,6 +25,14 @@ import org.schabi.newpipe.extractor.MediaFormat;
public class AudioStream extends Stream {
public int average_bitrate = -1;
// Fields for Dash
public int bitrate;
public int initStart;
public int initEnd;
public int indexStart;
public int indexEnd;
public String codec;
/**
* Create a new audio stream
* @param url the url
@ -36,6 +44,23 @@ public class AudioStream extends Stream {
this.average_bitrate = averageBitrate;
}
/**
* Create a new audio stream
* @param url the url
* @param format the format
* @param averageBitrate the average bitrate
*/
public AudioStream(String url, MediaFormat format, int averageBitrate, int bitrate, int initStart, int initEnd, int indexStart, int indexEnd, String codec) {
super(url, format);
this.average_bitrate = averageBitrate;
this.bitrate = bitrate;
this.initStart = initStart;
this.initEnd = initEnd;
this.indexStart = indexStart;
this.indexEnd = indexEnd;
this.codec = codec;
}
@Override
public boolean equalStats(Stream cmp) {
return super.equalStats(cmp) && cmp instanceof AudioStream &&
@ -49,4 +74,28 @@ public class AudioStream extends Stream {
public int getAverageBitrate() {
return average_bitrate;
}
public int getBitrate() {
return bitrate;
}
public int getInitStart() {
return initStart;
}
public int getInitEnd() {
return initEnd;
}
public int getIndexStart() {
return indexStart;
}
public int getIndexEnd() {
return indexEnd;
}
public String getCodec() {
return codec;
}
}

View file

@ -26,6 +26,15 @@ public class VideoStream extends Stream {
public final String resolution;
public final boolean isVideoOnly;
// Fields for Dash
public int bitrate;
public int initStart;
public int initEnd;
public int indexStart;
public int indexEnd;
public int width;
public int height;
public String codec;
public VideoStream(String url, MediaFormat format, String resolution) {
this(url, format, resolution, false);
@ -37,6 +46,20 @@ public class VideoStream extends Stream {
this.isVideoOnly = isVideoOnly;
}
public VideoStream(String url, MediaFormat format, String resolution, boolean isVideoOnly, int bitrate, int initStart, int initEnd, int indexStart, int indexEnd, String codec, int width, int height) {
super(url, format);
this.resolution = resolution;
this.isVideoOnly = isVideoOnly;
this.bitrate = bitrate;
this.initStart = initStart;
this.initEnd = initEnd;
this.indexStart = indexStart;
this.indexEnd = indexEnd;
this.codec = codec;
this.height = height;
this.width = width;
}
public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) {
this(url, torrentUrl, format, resolution, false);
}
@ -73,4 +96,36 @@ public class VideoStream extends Stream {
public boolean isVideoOnly() {
return isVideoOnly;
}
public int getBitrate() {
return bitrate;
}
public int getInitStart() {
return initStart;
}
public int getInitEnd() {
return initEnd;
}
public int getIndexStart() {
return indexStart;
}
public int getIndexEnd() {
return indexEnd;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public String getCodec() {
return codec;
}
}