Skip to content

Commit 11eb493

Browse files
committed
Add data to respective classes.
1 parent 525e345 commit 11eb493

3 files changed

Lines changed: 112 additions & 8 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public List<AudioStream> getAudioStreams() throws ExtractionException {
502502
for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FORMATS, ItagItem.ItagType.AUDIO).entrySet()) {
503503
ItagItem itag = entry.getValue();
504504

505-
AudioStream audioStream = new AudioStream(entry.getKey(), itag.getMediaFormat(), itag.avgBitrate);
505+
AudioStream audioStream = new AudioStream(entry.getKey(), itag.getMediaFormat(), itag.avgBitrate, itag.bitrate, itag.initStart, itag.initEnd, itag.indexStart, itag.indexEnd, itag.codec);
506506
if (!Stream.containSimilarStream(audioStream, audioStreams)) {
507507
audioStreams.add(audioStream);
508508
}
@@ -542,7 +542,7 @@ public List<VideoStream> getVideoOnlyStreams() throws ExtractionException {
542542
for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FORMATS, ItagItem.ItagType.VIDEO_ONLY).entrySet()) {
543543
ItagItem itag = entry.getValue();
544544

545-
VideoStream videoStream = new VideoStream(entry.getKey(), itag.getMediaFormat(), itag.resolutionString, true);
545+
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);
546546
if (!Stream.containSimilarStream(videoStream, videoOnlyStreams)) {
547547
videoOnlyStreams.add(videoStream);
548548
}
@@ -950,19 +950,19 @@ private Map<String, ItagItem> getItags(final String streamingDataKey,
950950
}
951951

952952
int bitrate = formatData.getInt("bitrate");
953-
int averageBitrate = formatData.getInt("averageBitrate");
954953
int width = formatData.getInt("width");
955954
int height = formatData.getInt("height");
956-
int initStart = formatData.getInt("initRange.start");
957-
int initEnd = formatData.getInt("initRange.end");
958-
int indexStart = formatData.getInt("indexRange.start");
959-
int indexEnd = formatData.getInt("indexRange.end");
955+
JsonObject initRange = formatData.getObject("initRange");
956+
JsonObject indexRange = formatData.getObject("indexRange");
957+
int initStart = Integer.parseInt(initRange.getString("start"));
958+
int initEnd = Integer.parseInt(initRange.getString("end"));
959+
int indexStart = Integer.parseInt(indexRange.getString("start"));
960+
int indexEnd = Integer.parseInt(indexRange.getString("end"));
960961
int fps = formatData.getInt("fps");
961962
String mimeType = formatData.getString("mimeType", EMPTY_STRING);
962963
String codec = mimeType.contains("codecs") ? mimeType.split("\"")[1] : EMPTY_STRING;
963964

964965
itagItem.bitrate = bitrate;
965-
itagItem.avgBitrate =averageBitrate;
966966
itagItem.width = width;
967967
itagItem.height = height;
968968
itagItem.initStart = initStart;

extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioStream.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
public class AudioStream extends Stream {
2626
public int average_bitrate = -1;
2727

28+
// Fields for Dash
29+
public int bitrate;
30+
public int initStart;
31+
public int initEnd;
32+
public int indexStart;
33+
public int indexEnd;
34+
public String codec;
35+
2836
/**
2937
* Create a new audio stream
3038
* @param url the url
@@ -36,6 +44,23 @@ public AudioStream(String url, MediaFormat format, int averageBitrate) {
3644
this.average_bitrate = averageBitrate;
3745
}
3846

47+
/**
48+
* Create a new audio stream
49+
* @param url the url
50+
* @param format the format
51+
* @param averageBitrate the average bitrate
52+
*/
53+
public AudioStream(String url, MediaFormat format, int averageBitrate, int bitrate, int initStart, int initEnd, int indexStart, int indexEnd, String codec) {
54+
super(url, format);
55+
this.average_bitrate = averageBitrate;
56+
this.bitrate = bitrate;
57+
this.initStart = initStart;
58+
this.initEnd = initEnd;
59+
this.indexStart = indexStart;
60+
this.indexEnd = indexEnd;
61+
this.codec = codec;
62+
}
63+
3964
@Override
4065
public boolean equalStats(Stream cmp) {
4166
return super.equalStats(cmp) && cmp instanceof AudioStream &&
@@ -49,4 +74,28 @@ public boolean equalStats(Stream cmp) {
4974
public int getAverageBitrate() {
5075
return average_bitrate;
5176
}
77+
78+
public int getBitrate() {
79+
return bitrate;
80+
}
81+
82+
public int getInitStart() {
83+
return initStart;
84+
}
85+
86+
public int getInitEnd() {
87+
return initEnd;
88+
}
89+
90+
public int getIndexStart() {
91+
return indexStart;
92+
}
93+
94+
public int getIndexEnd() {
95+
return indexEnd;
96+
}
97+
98+
public String getCodec() {
99+
return codec;
100+
}
52101
}

extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ public class VideoStream extends Stream {
2626
public final String resolution;
2727
public final boolean isVideoOnly;
2828

29+
// Fields for Dash
30+
public int bitrate;
31+
public int initStart;
32+
public int initEnd;
33+
public int indexStart;
34+
public int indexEnd;
35+
public int width;
36+
public int height;
37+
public String codec;
2938

3039
public VideoStream(String url, MediaFormat format, String resolution) {
3140
this(url, format, resolution, false);
@@ -37,6 +46,20 @@ public VideoStream(String url, MediaFormat format, String resolution, boolean is
3746
this.isVideoOnly = isVideoOnly;
3847
}
3948

49+
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) {
50+
super(url, format);
51+
this.resolution = resolution;
52+
this.isVideoOnly = isVideoOnly;
53+
this.bitrate = bitrate;
54+
this.initStart = initStart;
55+
this.initEnd = initEnd;
56+
this.indexStart = indexStart;
57+
this.indexEnd = indexEnd;
58+
this.codec = codec;
59+
this.height = height;
60+
this.width = width;
61+
}
62+
4063
public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) {
4164
this(url, torrentUrl, format, resolution, false);
4265
}
@@ -73,4 +96,36 @@ public String getResolution() {
7396
public boolean isVideoOnly() {
7497
return isVideoOnly;
7598
}
99+
100+
public int getBitrate() {
101+
return bitrate;
102+
}
103+
104+
public int getInitStart() {
105+
return initStart;
106+
}
107+
108+
public int getInitEnd() {
109+
return initEnd;
110+
}
111+
112+
public int getIndexStart() {
113+
return indexStart;
114+
}
115+
116+
public int getIndexEnd() {
117+
return indexEnd;
118+
}
119+
120+
public int getWidth() {
121+
return width;
122+
}
123+
124+
public int getHeight() {
125+
return height;
126+
}
127+
128+
public String getCodec() {
129+
return codec;
130+
}
76131
}

0 commit comments

Comments
 (0)